diff --git a/src/main/java/org/htmlunit/javascript/host/css/CSSPageRule.java b/src/main/java/org/htmlunit/javascript/host/css/CSSPageRule.java index f47c9f4977b..343cdaf9601 100644 --- a/src/main/java/org/htmlunit/javascript/host/css/CSSPageRule.java +++ b/src/main/java/org/htmlunit/javascript/host/css/CSSPageRule.java @@ -21,7 +21,6 @@ import static org.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static org.htmlunit.javascript.configuration.SupportedBrowser.FF; import static org.htmlunit.javascript.configuration.SupportedBrowser.FF_ESR; -import static org.htmlunit.javascript.configuration.SupportedBrowser.IE; import java.util.Locale; @@ -74,7 +73,7 @@ protected CSSPageRule(final CSSStyleSheet stylesheet, final CSSPageRuleImpl rule * Returns the textual representation of the selector for the rule set. * @return the textual representation of the selector for the rule set */ - @JsxGetter({CHROME, EDGE, FF, IE}) + @JsxGetter public String getSelectorText() { if (getBrowserVersion().hasFeature(JS_PAGERULE_SELECTORTEXT_EMPTY)) { return ""; @@ -91,7 +90,7 @@ public String getSelectorText() { * Sets the textual representation of the selector for the rule set. * @param selectorText the textual representation of the selector for the rule set */ - @JsxSetter({CHROME, EDGE, FF}) + @JsxSetter({CHROME, EDGE, FF, FF_ESR}) public void setSelectorText(final String selectorText) { try { getPageRule().setSelectorText(selectorText); diff --git a/src/main/java/org/htmlunit/javascript/host/css/CSSStyleSheet.java b/src/main/java/org/htmlunit/javascript/host/css/CSSStyleSheet.java index ffdda40031b..cb1d58c5da8 100644 --- a/src/main/java/org/htmlunit/javascript/host/css/CSSStyleSheet.java +++ b/src/main/java/org/htmlunit/javascript/host/css/CSSStyleSheet.java @@ -157,7 +157,7 @@ public CssStyleSheet getCssStyleSheet() { * Returns the owner node. * @return the owner node */ - @JsxGetter + @JsxGetter(IE) public HTMLElement getOwnerNode() { return ownerNode_; } @@ -175,7 +175,7 @@ public HTMLElement getOwningElement() { * Retrieves the collection of rules defined in this style sheet. * @return the collection of rules defined in this style sheet */ - @JsxGetter({CHROME, EDGE, IE}) + @JsxGetter public CSSRuleList getRules() { return getCssRules(); } @@ -194,7 +194,7 @@ public CSSRuleList getCssRules() { * Returns the URL of the stylesheet. * @return the URL of the stylesheet */ - @JsxGetter + @JsxGetter(IE) public String getHref() { if (ownerNode_ != null) { final DomNode node = ownerNode_.getDomNodeOrDie(); diff --git a/src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java b/src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java index 8c78afc93dd..a3a0d2afd20 100644 --- a/src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java +++ b/src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java @@ -137,6 +137,20 @@ private void testString(final String preparation, final String string) throws Ex + " \n" + " \n" + " \n" + + + " \n" + + " \n" + + " \n" + + " \n" + + LOG_TEXTAREA + ""; @@ -18487,4 +18501,93 @@ public void mutationObserver() throws Exception { public void webKitMutationObserver() throws Exception { testString("", "new WebKitMutationObserver(function(m) {})"); } + + /** + * Test StyleSheet. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "addRule(),constructor(),cssRules[GCE],deleteRule(),insertRule()," + + "ownerRule[GCE],removeRule(),replace(),replaceSync(),rules[GCE]", + IE = "addRule(),constructor[],cssRules[GCE],deleteRule(),href[GCE],insertRule()," + + "ownerNode[GCE],owningElement[GCE],removeRule(),rules[GCE]") + @HtmlUnitNYI(CHROME = "addRule(),constructor(),cssRules[GCE],deleteRule()," + + "insertRule(),removeRule(),rules[GCE]", + EDGE = "addRule(),constructor(),cssRules[GCE],deleteRule()," + + "insertRule(),removeRule(),rules[GCE]", + FF = "addRule(),constructor(),cssRules[GCE],deleteRule()," + + "insertRule(),removeRule(),rules[GCE]", + FF_ESR = "addRule(),constructor(),cssRules[GCE],deleteRule()," + + "insertRule(),removeRule(),rules[GCE]") + public void cssStyleSheet() throws Exception { + testString("", "document.styleSheets[0]"); + } + + /** + * Test CSSPageRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "constructor(),selectorText[GSCE],style[GSCE]", + IE = "constructor[],selectorText[GCE],style[GCE]") + @HtmlUnitNYI(CHROME = "constructor(),selectorText[GSCE],style[GCE]", + EDGE = "constructor(),selectorText[GSCE],style[GCE]", + FF = "constructor(),selectorText[GSCE],style[GCE]", + FF_ESR = "constructor(),selectorText[GSCE],style[GCE]") + public void cssPageRule() throws Exception { + testString("", "document.styleSheets[0].cssRules[0]"); + } + + /** + * Test CSSMediaRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "constructor(),media[GSCE]", + IE = "constructor[],media[GCE]") + @HtmlUnitNYI(CHROME = "constructor(),media[GCE]", + EDGE = "constructor(),media[GCE]", + FF = "constructor(),media[GCE]", + FF_ESR = "constructor(),media[GCE]") + public void cssMediaRule() throws Exception { + testString("", "document.styleSheets[1].cssRules[0]"); + } + + /** + * Test CSSFontFaceRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "constructor(),style[GCE]", + IE = "constructor[]") + @HtmlUnitNYI(CHROME = "constructor()", + EDGE = "constructor()", + FF = "constructor()", + FF_ESR = "constructor()") + public void cssFontFaceRule() throws Exception { + testString("", "document.styleSheets[2].cssRules[0]"); + } + + /** + * Test CSSRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "constructor(),cssRules[GCE],deleteRule(),insertRule()," + + "selectorText[GSCE],style[GSCE],styleMap[GCE]", + FF = "constructor(),selectorText[GSCE],style[GSCE]", + FF_ESR = "constructor(),selectorText[GSCE],style[GSCE]", + IE = "constructor[],readOnly[GCE],selectorText[GSCE],style[GCE]") + @HtmlUnitNYI(CHROME = "constructor(),selectorText[GSCE],style[GCE]", + EDGE = "constructor(),selectorText[GSCE],style[GCE]", + FF = "constructor(),selectorText[GSCE],style[GCE]", + FF_ESR = "constructor(),selectorText[GSCE],style[GCE]") + public void cssStyleRule() throws Exception { + testString("", "document.styleSheets[3].cssRules[0]"); + } } diff --git a/src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java b/src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java index dcbb9aacc9b..42cc3bacc76 100644 --- a/src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java +++ b/src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java @@ -130,6 +130,20 @@ private void testString(final String preparation, final String string) throws Ex + " \n" + " \n" + " \n" + + + " \n" + + " \n" + + " \n" + + " \n" + + LOG_TEXTAREA + ""; @@ -3788,4 +3802,64 @@ public void mutationObserver() throws Exception { public void webKitMutationObserver() throws Exception { testString("", "new WebKitMutationObserver(function(m) {})"); } + + /** + * Test StyleSheet. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "Symbol(Symbol.toStringTag) [CSSStyleSheet]", + IE = "exception") + public void cssStyleSheet() throws Exception { + testString("", "document.styleSheets[0]"); + } + + /** + * Test CSSPageRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "Symbol(Symbol.toStringTag) [CSSPageRule]", + IE = "exception") + public void cssPageRule() throws Exception { + testString("", "document.styleSheets[0].cssRules[0]"); + } + + /** + * Test CSSMediaRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "Symbol(Symbol.toStringTag) [CSSMediaRule]", + IE = "exception") + public void cssMediaRule() throws Exception { + testString("", "document.styleSheets[1].cssRules[0]"); + } + + /** + * Test CSSFontFaceRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "Symbol(Symbol.toStringTag) [CSSFontFaceRule]", + IE = "exception") + public void cssFontFaceRule() throws Exception { + testString("", "document.styleSheets[2].cssRules[0]"); + } + + /** + * Test CSSRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "Symbol(Symbol.toStringTag) [CSSStyleRule]", + IE = "exception") + public void cssStyleRule() throws Exception { + testString("", "document.styleSheets[3].cssRules[0]"); + } } diff --git a/src/test/java/org/htmlunit/general/ElementPropertiesTest.java b/src/test/java/org/htmlunit/general/ElementPropertiesTest.java index 98136cefefc..fd05eb10a93 100644 --- a/src/test/java/org/htmlunit/general/ElementPropertiesTest.java +++ b/src/test/java/org/htmlunit/general/ElementPropertiesTest.java @@ -137,6 +137,20 @@ private void testString(final String preparation, final String string) throws Ex + " \n" + " \n" + " \n" + + + " \n" + + " \n" + + " \n" + + " \n" + + LOG_TEXTAREA + ""; @@ -9449,4 +9463,115 @@ public void mutationObserver() throws Exception { public void webKitMutationObserver() throws Exception { testString("", "new WebKitMutationObserver(function(m) {})"); } + + /** + * Test StyleSheet. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "addRule(),cssRules,deleteRule(),disabled,href,insertRule(),media,ownerNode," + + "ownerRule,parentStyleSheet,removeRule(),replace(),replaceSync(),rules,title,type", + IE = "addRule(),cssRules,deleteRule(),href,insertRule(),ownerNode," + + "owningElement,removeRule(),rules") + @HtmlUnitNYI(CHROME = "addRule(),cssRules,deleteRule(),insertRule(),removeRule(),rules", + EDGE = "addRule(),cssRules,deleteRule(),insertRule(),removeRule(),rules", + FF = "addRule(),cssRules,deleteRule(),insertRule(),removeRule(),rules", + FF_ESR = "addRule(),cssRules,deleteRule(),insertRule(),removeRule(),rules") + public void cssStyleSheet() throws Exception { + testString("", "document.styleSheets[0]"); + } + + /** + * Test CSSPageRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,selectorText,style,STYLE_RULE,SUPPORTS_RULE,type", + IE = "CHARSET_RULE,cssText,FONT_FACE_RULE,IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE," + + "NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet,selectorText,style,STYLE_RULE," + + "type,UNKNOWN_RULE,VIEWPORT_RULE") + public void cssPageRule() throws Exception { + testString("", "document.styleSheets[0].cssRules[0]"); + } + + /** + * Test CSSMediaRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "CHARSET_RULE,conditionText,COUNTER_STYLE_RULE,cssRules,cssText,deleteRule()," + + "FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE,IMPORT_RULE,insertRule(),KEYFRAME_RULE," + + "KEYFRAMES_RULE,media,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet," + + "STYLE_RULE,SUPPORTS_RULE,type", + IE = "CHARSET_RULE,cssRules,cssText,deleteRule(),FONT_FACE_RULE,IMPORT_RULE,insertRule()," + + "KEYFRAME_RULE,KEYFRAMES_RULE,media,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,STYLE_RULE,type,UNKNOWN_RULE,VIEWPORT_RULE") + public void cssMediaRule() throws Exception { + testString("", "document.styleSheets[1].cssRules[0]"); + } + + /** + * Test CSSFontFaceRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE," + + "parentRule,parentStyleSheet,style,STYLE_RULE,SUPPORTS_RULE,type", + IE = "CHARSET_RULE,cssText,FONT_FACE_RULE,IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE," + + "NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet,STYLE_RULE,type,UNKNOWN_RULE,VIEWPORT_RULE") + @HtmlUnitNYI(CHROME = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,STYLE_RULE,SUPPORTS_RULE,type", + EDGE = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,STYLE_RULE,SUPPORTS_RULE,type", + FF = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,STYLE_RULE,SUPPORTS_RULE,type", + FF_ESR = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,STYLE_RULE,SUPPORTS_RULE,type") + public void cssFontFaceRule() throws Exception { + testString("", "document.styleSheets[2].cssRules[0]"); + } + + /** + * Test CSSRule. + * + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "CHARSET_RULE,COUNTER_STYLE_RULE,cssRules,cssText,deleteRule(),FONT_FACE_RULE," + + "FONT_FEATURE_VALUES_RULE,IMPORT_RULE,insertRule(),KEYFRAME_RULE,KEYFRAMES_RULE," + + "MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet,selectorText," + + "style,STYLE_RULE,styleMap,SUPPORTS_RULE,type", + FF = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,selectorText,style,STYLE_RULE,SUPPORTS_RULE,type", + FF_ESR = "CHARSET_RULE,COUNTER_STYLE_RULE,cssRules,cssText,deleteRule(),FONT_FACE_RULE," + + "FONT_FEATURE_VALUES_RULE,IMPORT_RULE,insertRule(),KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE," + + "NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet,selectorText,style," + + "STYLE_RULE,SUPPORTS_RULE,type", + IE = "CHARSET_RULE,cssText,FONT_FACE_RULE,IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE," + + "NAMESPACE_RULE,PAGE_RULE,parentRule,parentStyleSheet,readOnly,selectorText,style," + + "STYLE_RULE,type,UNKNOWN_RULE,VIEWPORT_RULE") + @HtmlUnitNYI(CHROME = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,selectorText,style,STYLE_RULE,SUPPORTS_RULE,type", + EDGE = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,selectorText,style,STYLE_RULE,SUPPORTS_RULE,type", + FF_ESR = "CHARSET_RULE,COUNTER_STYLE_RULE,cssText,FONT_FACE_RULE,FONT_FEATURE_VALUES_RULE," + + "IMPORT_RULE,KEYFRAME_RULE,KEYFRAMES_RULE,MEDIA_RULE,NAMESPACE_RULE,PAGE_RULE,parentRule," + + "parentStyleSheet,selectorText,style,STYLE_RULE,SUPPORTS_RULE,type") + public void cssStyleRule() throws Exception { + testString("", "document.styleSheets[3].cssRules[0]"); + } }