Skip to content

Commit

Permalink
FF 119 / FF ESR 115
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 29, 2023
1 parent 92d3237 commit c77fe4d
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 "";
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public CssStyleSheet getCssStyleSheet() {
* Returns the owner node.
* @return the owner node
*/
@JsxGetter
@JsxGetter(IE)
public HTMLElement getOwnerNode() {
return ownerNode_;
}
Expand All @@ -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();
}
Expand All @@ -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();
Expand Down
103 changes: 103 additions & 0 deletions src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ private void testString(final String preparation, final String string) throws Ex
+ " <svg xmlns='http://www.w3.org/2000/svg' version='1.1'>\n"
+ " <invalid id='mySvg'/>\n"
+ " </svg>\n"

+ " <style>\n"
+ " @page { margin: 1cm; }\n"
+ " </style>\n"
+ " <style>\n"
+ " @media screen { p { background-color:#FFFFFF; }};\n"
+ " </style>\n"
+ " <style>\n"
+ " @font-face { font-family: Delicious; src: url('Delicious-Bold.otf'); };\n"
+ " </style>\n"
+ " <style>\n"
+ " h3 { color: blue; }\n"
+ " </style>\n"

+ LOG_TEXTAREA
+ "</body></html>";

Expand Down Expand Up @@ -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]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ private void testString(final String preparation, final String string) throws Ex
+ " <svg xmlns='http://www.w3.org/2000/svg' version='1.1'>\n"
+ " <invalid id='mySvg'/>\n"
+ " </svg>\n"

+ " <style>\n"
+ " @page { margin: 1cm; }\n"
+ " </style>\n"
+ " <style>\n"
+ " @media screen { p { background-color:#FFFFFF; }};\n"
+ " </style>\n"
+ " <style>\n"
+ " @font-face { font-family: Delicious; src: url('Delicious-Bold.otf'); };\n"
+ " </style>\n"
+ " <style>\n"
+ " h3 { color: blue; }\n"
+ " </style>\n"

+ LOG_TEXTAREA
+ "</body></html>";

Expand Down Expand Up @@ -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]");
}
}
125 changes: 125 additions & 0 deletions src/test/java/org/htmlunit/general/ElementPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ private void testString(final String preparation, final String string) throws Ex
+ " <svg xmlns='http://www.w3.org/2000/svg' version='1.1'>\n"
+ " <invalid id='mySvg'/>\n"
+ " </svg>\n"

+ " <style>\n"
+ " @page { margin: 1cm; }\n"
+ " </style>\n"
+ " <style>\n"
+ " @media screen { p { background-color:#FFFFFF; }};\n"
+ " </style>\n"
+ " <style>\n"
+ " @font-face { font-family: Delicious; src: url('Delicious-Bold.otf'); };\n"
+ " </style>\n"
+ " <style>\n"
+ " h3 { color: blue; }\n"
+ " </style>\n"

+ LOG_TEXTAREA
+ "</body></html>";

Expand Down Expand Up @@ -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]");
}
}

0 comments on commit c77fe4d

Please sign in to comment.