From 80dee7a65f8b4b7d1d93c92e4641c70633734803 Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Wed, 7 Jun 2017 10:22:49 -0700 Subject: [PATCH] Force HTMLStyleElement to create a new CSSStyleSheet when re-parsing. We already call Document::invalidate_style_sheets and set the stylesheet member to a new Stylesheet. This matches the behavior of Firefox, and means the new CSSStyleSheet you get from accessing .sheet from JS will be correct instead of stale. (::get_cssom_stylesheet already tries to use the new Stylesheet, but MutNullableJS::or_init is called, so if we already created a CSSStyleSheet we will continue to return that one). --- components/script/dom/htmlstyleelement.rs | 1 + tests/wpt/metadata/MANIFEST.json | 2 +- .../attribute-case/semantics.html.ini | 29 --- .../attribute-case/syntax.html.ini | 218 ------------------ .../cssom/style-sheet-interfaces-001.html | 11 + 5 files changed, 13 insertions(+), 248 deletions(-) delete mode 100644 tests/wpt/metadata/selectors/attribute-selectors/attribute-case/semantics.html.ini delete mode 100644 tests/wpt/metadata/selectors/attribute-selectors/attribute-case/syntax.html.ini diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index bf4266e1875..bbce33f3d52 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -111,6 +111,7 @@ impl HTMLStyleElement { win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap(); *self.stylesheet.borrow_mut() = Some(sheet); + self.cssom_stylesheet.set(None); doc.invalidate_stylesheets(); } diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index a7628638b6f..cc8e73994dd 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -553998,7 +553998,7 @@ "testharness" ], "cssom/style-sheet-interfaces-001.html": [ - "15509e87505d5a22d4f6dbbffcc90c24fcee642a", + "e77ec7de74baa901cc15a3b90d2b29125c282562", "testharness" ], "cssom/style-sheet-interfaces-002.html": [ diff --git a/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/semantics.html.ini b/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/semantics.html.ini deleted file mode 100644 index 804d84f3514..00000000000 --- a/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/semantics.html.ini +++ /dev/null @@ -1,29 +0,0 @@ -[semantics.html] - type: testharness - [@namespace x 'http://www.w3.org/XML/1998/namespace'; [x|lang='A' i\]
in standards mode] - expected: FAIL - - [@namespace x 'a'; [x|foo='' i\]
in standards mode] - expected: FAIL - - [@namespace x 'A'; [x|foo='' i\]
in standards mode] - expected: FAIL - - [@namespace x 'http://www.w3.org/XML/1998/namespace'; [x|lang='A' i\]
in quirks mode] - expected: FAIL - - [@namespace x 'a'; [x|foo='' i\]
in quirks mode] - expected: FAIL - - [@namespace x 'A'; [x|foo='' i\]
in quirks mode] - expected: FAIL - - [@namespace x 'http://www.w3.org/XML/1998/namespace'; [x|lang='A' i\]
in XML] - expected: FAIL - - [@namespace x 'a'; [x|foo='' i\]
in XML] - expected: FAIL - - [@namespace x 'A'; [x|foo='' i\]
in XML] - expected: FAIL - diff --git a/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/syntax.html.ini b/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/syntax.html.ini deleted file mode 100644 index 3b4aa0649a8..00000000000 --- a/tests/wpt/metadata/selectors/attribute-selectors/attribute-case/syntax.html.ini +++ /dev/null @@ -1,218 +0,0 @@ -[syntax.html] - type: testharness - [[foo='BAR'\] /* sanity check (valid) */ in standards mode] - expected: FAIL - - [[foo='bar' i\] in standards mode] - expected: FAIL - - [[foo='bar' I\] in standards mode] - expected: FAIL - - [[foo=bar i\] in standards mode] - expected: FAIL - - [[foo="bar" i\] in standards mode] - expected: FAIL - - [[foo='bar'i\] in standards mode] - expected: FAIL - - [[foo='bar'i \] in standards mode] - expected: FAIL - - [[foo='bar' i \] in standards mode] - expected: FAIL - - [[foo='bar' /**/ i\] in standards mode] - expected: FAIL - - [[foo='bar' i /**/ \] in standards mode] - expected: FAIL - - [[foo='bar'/**/i/**/\] in standards mode] - expected: FAIL - - [[foo=bar/**/i\] in standards mode] - expected: FAIL - - [[foo='bar'\ti\t\] /* \\t */ in standards mode] - expected: FAIL - - [[foo='bar'\ni\n\] /* \\n */ in standards mode] - expected: FAIL - - [[foo='bar'\ri\r\] /* \\r */ in standards mode] - expected: FAIL - - [[foo='bar' \\i\] in standards mode] - expected: FAIL - - [[foo='bar' \\69\] in standards mode] - expected: FAIL - - [[foo~='bar' i\] in standards mode] - expected: FAIL - - [[foo^='bar' i\] in standards mode] - expected: FAIL - - [[foo$='bar' i\] in standards mode] - expected: FAIL - - [[foo*='bar' i\] in standards mode] - expected: FAIL - - [[foo|='bar' i\] in standards mode] - expected: FAIL - - [[|foo='bar' i\] in standards mode] - expected: FAIL - - [[*|foo='bar' i\] in standards mode] - expected: FAIL - - [[foo='BAR'\] /* sanity check (valid) */ in quirks mode] - expected: FAIL - - [[foo='bar' i\] in quirks mode] - expected: FAIL - - [[foo='bar' I\] in quirks mode] - expected: FAIL - - [[foo=bar i\] in quirks mode] - expected: FAIL - - [[foo="bar" i\] in quirks mode] - expected: FAIL - - [[foo='bar'i\] in quirks mode] - expected: FAIL - - [[foo='bar'i \] in quirks mode] - expected: FAIL - - [[foo='bar' i \] in quirks mode] - expected: FAIL - - [[foo='bar' /**/ i\] in quirks mode] - expected: FAIL - - [[foo='bar' i /**/ \] in quirks mode] - expected: FAIL - - [[foo='bar'/**/i/**/\] in quirks mode] - expected: FAIL - - [[foo=bar/**/i\] in quirks mode] - expected: FAIL - - [[foo='bar'\ti\t\] /* \\t */ in quirks mode] - expected: FAIL - - [[foo='bar'\ni\n\] /* \\n */ in quirks mode] - expected: FAIL - - [[foo='bar'\ri\r\] /* \\r */ in quirks mode] - expected: FAIL - - [[foo='bar' \\i\] in quirks mode] - expected: FAIL - - [[foo='bar' \\69\] in quirks mode] - expected: FAIL - - [[foo~='bar' i\] in quirks mode] - expected: FAIL - - [[foo^='bar' i\] in quirks mode] - expected: FAIL - - [[foo$='bar' i\] in quirks mode] - expected: FAIL - - [[foo*='bar' i\] in quirks mode] - expected: FAIL - - [[foo|='bar' i\] in quirks mode] - expected: FAIL - - [[|foo='bar' i\] in quirks mode] - expected: FAIL - - [[*|foo='bar' i\] in quirks mode] - expected: FAIL - - [[foo='BAR'\] /* sanity check (valid) */ in XML] - expected: FAIL - - [[foo='bar' i\] in XML] - expected: FAIL - - [[foo='bar' I\] in XML] - expected: FAIL - - [[foo=bar i\] in XML] - expected: FAIL - - [[foo="bar" i\] in XML] - expected: FAIL - - [[foo='bar'i\] in XML] - expected: FAIL - - [[foo='bar'i \] in XML] - expected: FAIL - - [[foo='bar' i \] in XML] - expected: FAIL - - [[foo='bar' /**/ i\] in XML] - expected: FAIL - - [[foo='bar' i /**/ \] in XML] - expected: FAIL - - [[foo='bar'/**/i/**/\] in XML] - expected: FAIL - - [[foo=bar/**/i\] in XML] - expected: FAIL - - [[foo='bar'\ti\t\] /* \\t */ in XML] - expected: FAIL - - [[foo='bar'\ni\n\] /* \\n */ in XML] - expected: FAIL - - [[foo='bar'\ri\r\] /* \\r */ in XML] - expected: FAIL - - [[foo='bar' \\i\] in XML] - expected: FAIL - - [[foo='bar' \\69\] in XML] - expected: FAIL - - [[foo~='bar' i\] in XML] - expected: FAIL - - [[foo^='bar' i\] in XML] - expected: FAIL - - [[foo$='bar' i\] in XML] - expected: FAIL - - [[foo*='bar' i\] in XML] - expected: FAIL - - [[foo|='bar' i\] in XML] - expected: FAIL - - [[|foo='bar' i\] in XML] - expected: FAIL - - [[*|foo='bar' i\] in XML] - expected: FAIL - diff --git a/tests/wpt/web-platform-tests/cssom/style-sheet-interfaces-001.html b/tests/wpt/web-platform-tests/cssom/style-sheet-interfaces-001.html index 3f4956cb3ad..fb1fde86eff 100644 --- a/tests/wpt/web-platform-tests/cssom/style-sheet-interfaces-001.html +++ b/tests/wpt/web-platform-tests/cssom/style-sheet-interfaces-001.html @@ -61,6 +61,17 @@ assert: [ "styleElement.sheet exists", "styleElement.sheet is a CSSStyleSheet", "linkElement.sheet exists", "linkElement.sheet is a CSSStyleSheet"] }); + test(function () { + var style = document.createElement("style"); + document.querySelector("head").appendChild(style); + var sheet1 = style.sheet; + assert_equals(sheet1.cssRules.length, 0); + style.appendChild(document.createTextNode("a { color: green; }")); + assert_equals(style.sheet.cssRules.length, 1); + }, "sheet_property_updates", + { help: "https://www.w3.org/TR/cssom-1/#the-linkstyle-interface", + assert: "The sheet property on LinkStyle should always return the current associated style sheet." }); + test(function() { assert_own_property(styleSheet, "ownerRule"); assert_own_property(styleSheet, "cssRules");