From 9760ea29537ce7753e6e0d516865e70142db5824 Mon Sep 17 00:00:00 2001 From: Roman Zaynetdinov Date: Mon, 9 Jan 2017 18:47:08 +0200 Subject: [PATCH 1/4] Test changing style tag elements --- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../tests/mozilla/reparse_style_elements.html | 18 ++++++++++++++ .../mozilla/reparse_style_elements_ref.html | 11 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html create mode 100644 tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 98dbd60fcbb..0cb9a9d9585 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6462,6 +6462,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/reparse_style_elements.html": [ + { + "path": "mozilla/reparse_style_elements.html", + "references": [ + [ + "/_mozilla/mozilla/reparse_style_elements_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/reparse_style_elements.html" + } + ], "mozilla/restyle-out-of-document.html": [ { "path": "mozilla/restyle-out-of-document.html", @@ -21840,6 +21852,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/reparse_style_elements.html": [ + { + "path": "mozilla/reparse_style_elements.html", + "references": [ + [ + "/_mozilla/mozilla/reparse_style_elements_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/reparse_style_elements.html" + } + ], "mozilla/restyle-out-of-document.html": [ { "path": "mozilla/restyle-out-of-document.html", diff --git a/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html new file mode 100644 index 00000000000..e54f5a28d13 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements.html @@ -0,0 +1,18 @@ + + +Style elements should be reparsed on change + + + + + This text should be green and the background should not be red. + + + diff --git a/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html new file mode 100644 index 00000000000..e9fd0816b9b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/reparse_style_elements_ref.html @@ -0,0 +1,11 @@ + + + + + + This text should be green and the background should not be red. + From b3ce08f1b509ddfb2325427ddc348e3863a9aa38 Mon Sep 17 00:00:00 2001 From: Roman Zaynetdinov Date: Mon, 9 Jan 2017 19:31:04 +0200 Subject: [PATCH 2/4] Remove styles when link node is removed from document --- components/script/dom/htmllinkelement.rs | 11 ++++++++- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../tests/mozilla/remove_link_styles.css | 4 ++++ .../tests/mozilla/remove_link_styles.html | 19 +++++++++++++++ .../tests/mozilla/remove_link_styles_ref.html | 11 +++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/remove_link_styles.css create mode 100644 tests/wpt/mozilla/tests/mozilla/remove_link_styles.html create mode 100644 tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 7b26fb8bbee..3386e302422 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -18,7 +18,7 @@ use dom::element::{AttributeMutation, Element, ElementCreator}; use dom::element::{cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute}; use dom::globalscope::GlobalScope; use dom::htmlelement::HTMLElement; -use dom::node::{Node, document_from_node, window_from_node}; +use dom::node::{Node, UnbindContext, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use html5ever_atoms::LocalName; @@ -213,6 +213,15 @@ impl VirtualMethods for HTMLLinkElement { } } } + + fn unbind_from_tree(&self, context: &UnbindContext) { + if let Some(ref s) = self.super_type() { + s.unbind_from_tree(context); + } + + let document = document_from_node(self); + document.invalidate_stylesheets(); + } } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 0cb9a9d9585..6a4664e0584 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6462,6 +6462,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/remove_link_styles.html": [ + { + "path": "mozilla/remove_link_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_link_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_link_styles.html" + } + ], "mozilla/reparse_style_elements.html": [ { "path": "mozilla/reparse_style_elements.html", @@ -21852,6 +21864,18 @@ "url": "/_mozilla/mozilla/iframe/resize_after_load.html" } ], + "mozilla/remove_link_styles.html": [ + { + "path": "mozilla/remove_link_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_link_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_link_styles.html" + } + ], "mozilla/reparse_style_elements.html": [ { "path": "mozilla/reparse_style_elements.html", diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css new file mode 100644 index 00000000000..1984cf7df21 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.css @@ -0,0 +1,4 @@ +body { + background-color: red; + color: white !important; +} diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html new file mode 100644 index 00000000000..6a1e592d096 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles.html @@ -0,0 +1,19 @@ + + +Removing link tag should remove associated styles + + + + + + This text should be green and the background should not be red. + + + diff --git a/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html b/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html new file mode 100644 index 00000000000..e9fd0816b9b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_link_styles_ref.html @@ -0,0 +1,11 @@ + + + + + + This text should be green and the background should not be red. + From f0c72cb7fd5372220d40cc021867350cafd84fc7 Mon Sep 17 00:00:00 2001 From: Roman Zaynetdinov Date: Mon, 9 Jan 2017 19:39:13 +0200 Subject: [PATCH 3/4] Removing style element's styles when elements is removed from dom --- components/script/dom/htmlstyleelement.rs | 11 ++++++++- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../tests/mozilla/remove_style_styles.html | 20 ++++++++++++++++ .../mozilla/remove_style_styles_ref.html | 5 ++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/remove_style_styles.html create mode 100644 tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 7401c67aa95..285c8af3087 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -15,7 +15,7 @@ use dom::document::Document; use dom::element::{Element, ElementCreator}; use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; -use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node}; +use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use html5ever_atoms::LocalName; @@ -161,6 +161,15 @@ impl VirtualMethods for HTMLStyleElement { self.parse_own_css(); } } + + fn unbind_from_tree(&self, context: &UnbindContext) { + if let Some(ref s) = self.super_type() { + s.unbind_from_tree(context); + } + + let doc = document_from_node(self); + doc.invalidate_stylesheets(); + } } impl StylesheetOwner for HTMLStyleElement { diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 6a4664e0584..d396c4d0130 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6474,6 +6474,18 @@ "url": "/_mozilla/mozilla/remove_link_styles.html" } ], + "mozilla/remove_style_styles.html": [ + { + "path": "mozilla/remove_style_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_style_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_style_styles.html" + } + ], "mozilla/reparse_style_elements.html": [ { "path": "mozilla/reparse_style_elements.html", @@ -21876,6 +21888,18 @@ "url": "/_mozilla/mozilla/remove_link_styles.html" } ], + "mozilla/remove_style_styles.html": [ + { + "path": "mozilla/remove_style_styles.html", + "references": [ + [ + "/_mozilla/mozilla/remove_style_styles_ref.html", + "==" + ] + ], + "url": "/_mozilla/mozilla/remove_style_styles.html" + } + ], "mozilla/reparse_style_elements.html": [ { "path": "mozilla/reparse_style_elements.html", diff --git a/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html b/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html new file mode 100644 index 00000000000..f8a94bb7350 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_style_styles.html @@ -0,0 +1,20 @@ + + +Removing style element should remove all associated styles + + + + + This text should be black and the background should not be red. + + + diff --git a/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html b/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html new file mode 100644 index 00000000000..d562e127203 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/remove_style_styles_ref.html @@ -0,0 +1,5 @@ + + + + This text should be black and the background should not be red. + From d4ddafd55635e06e37bf36ed2342c006f878ffaf Mon Sep 17 00:00:00 2001 From: Roman Zaynetdinov Date: Sun, 22 Jan 2017 00:09:17 +0200 Subject: [PATCH 4/4] Remove fail expectations from subresource integrity test --- .../subresource-integrity.sub.html.ini | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini b/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini index 127ce07edb5..ada4d550044 100644 --- a/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini +++ b/tests/wpt/metadata/subresource-integrity/subresource-integrity.sub.html.ini @@ -3,25 +3,3 @@ expected: OK [Style: Same-origin with correct sha256 and sha512 hash, rel='alternate stylesheet' enabled] expected: FAIL - - [Style: Same-origin with incorrect hash.] - expected: FAIL - - [Style: Same-origin with sha256 match, sha512 mismatch] - expected: FAIL - - [Style: with CORS-ineligible resource] - expected: FAIL - - [Style: Cross-origin, not CORS request, with correct hash] - expected: FAIL - - [Style: Cross-origin, not CORS request, with hash mismatch] - expected: FAIL - - [Style: with incorrect hash CORS-eligible] - expected: FAIL - - [Style: with incorrect hash, ACAO: *] - expected: FAIL -