Bug 1451593 [wpt PR 10325] - Remove stylesheet of link element when rel != stylesheet, a=testonly
authorRakina Zata Amni <rakina@chromium.org>
Mon, 09 Apr 2018 22:11:29 +0000
changeset 467283 78401ceeed7cca57a887ee5d3ea65e4d4cf23bd3
parent 467282 b41dda24827687462fef6c89dc212f5242e39897
child 467284 a7d012115a440ea36dce922d5354c37cd1cec002
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1451593, 10325, 817355, 995116, 548357
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451593 [wpt PR 10325] - Remove stylesheet of link element when rel != stylesheet, a=testonly Automatic update from web-platform-testsRemove stylesheet of link element when rel != stylesheet Stylesheets from link elements that previously have rel = "stylesheet" but then changed to something else should be removed/not considered anymore until the rel attribute is changed back to "stylesheet" again. Currently this works correctly for link elements in the document tree, but fails in link elements within a shadow tree because link elements in shadow tree with rel attribute != "stylesheet" are skipped from processing. Because of that, the stylesheet in the link element was never cleared and no style recalc happened. JSBin from bug: http://jsbin.com/bojunajaju/edit?html,console,output Bug: 817355 Change-Id: I57c71c79c0cc471d36eb988b8a81eef82c33548a Reviewed-on: https://chromium-review.googlesource.com/995116 Commit-Queue: Rakina Zata Amni <rakina@chromium.org> Reviewed-by: Hayato Ito <hayato@chromium.org> Cr-Commit-Position: refs/heads/master@{#548357} wpt-commits: 5c9b2cf251344dd18522bd3fc88742533ce54d5a wpt-pr: 10325 wpt-commits: 5c9b2cf251344dd18522bd3fc88742533ce54d5a wpt-pr: 10325
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/semantics/document-metadata/the-link-element/link-rel-attribute.html
testing/web-platform/tests/html/semantics/document-metadata/the-link-element/resources/link-rel-attribute.css
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -282059,16 +282059,21 @@
      {}
     ]
    ],
    "html/semantics/document-metadata/the-link-element/resources/link-load-error-events.sub.js": [
     [
      {}
     ]
    ],
+   "html/semantics/document-metadata/the-link-element/resources/link-rel-attribute.css": [
+    [
+     {}
+    ]
+   ],
    "html/semantics/document-metadata/the-link-element/resources/stylesheet.css": [
     [
      {}
     ]
    ],
    "html/semantics/document-metadata/the-link-element/style.css": [
     [
      {}
@@ -331242,16 +331247,22 @@
     ]
    ],
    "html/semantics/document-metadata/the-link-element/link-load-event.html": [
     [
      "/html/semantics/document-metadata/the-link-element/link-load-event.html",
      {}
     ]
    ],
+   "html/semantics/document-metadata/the-link-element/link-rel-attribute.html": [
+    [
+     "/html/semantics/document-metadata/the-link-element/link-rel-attribute.html",
+     {}
+    ]
+   ],
    "html/semantics/document-metadata/the-link-element/link-rellist.html": [
     [
      "/html/semantics/document-metadata/the-link-element/link-rellist.html",
      {}
     ]
    ],
    "html/semantics/document-metadata/the-link-element/link-style-error-01.html": [
     [
@@ -565397,16 +565408,20 @@
   "html/semantics/document-metadata/the-link-element/link-load-error-events.https.html": [
    "8835935f157e5c227a8ce62f1a4fafcb46c50914",
    "testharness"
   ],
   "html/semantics/document-metadata/the-link-element/link-load-event.html": [
    "628527090c78d90d831cb80ea8eee7ffa66722f5",
    "testharness"
   ],
+  "html/semantics/document-metadata/the-link-element/link-rel-attribute.html": [
+   "45824076fb8696f775582c7bcfab093ebfb3055c",
+   "testharness"
+  ],
   "html/semantics/document-metadata/the-link-element/link-rellist.html": [
    "e18655ffb90bb039c50b262d145d63ca5efc22ca",
    "testharness"
   ],
   "html/semantics/document-metadata/the-link-element/link-style-error-01.html": [
    "285208d6cf3113ec16bedd107c0740b8c7c8a9d8",
    "testharness"
   ],
@@ -565421,16 +565436,20 @@
   "html/semantics/document-metadata/the-link-element/resources/good.css": [
    "04a3a89fe805fc930dc3adfa3a4134b950779697",
    "support"
   ],
   "html/semantics/document-metadata/the-link-element/resources/link-load-error-events.sub.js": [
    "1c5d8fe0b94b033b8e6ee7bcf54bd35ba2febd36",
    "support"
   ],
+  "html/semantics/document-metadata/the-link-element/resources/link-rel-attribute.css": [
+   "7439a846bece4561d9b17494aaae4c7b2aef6a2f",
+   "support"
+  ],
   "html/semantics/document-metadata/the-link-element/resources/stylesheet.css": [
    "2829167c82bafef6cfea06071007a231aa4277f6",
    "support"
   ],
   "html/semantics/document-metadata/the-link-element/style.css": [
    "e4a66764ea94d51b42d485d75a3305ea2ab79226",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/link-rel-attribute.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<script src = "/resources/testharness.js"></script>
+<script src = "/resources/testharnessreport.js"></script>
+
+<link id="light-link" rel="stylesheet" href="resources/link-rel-attribute.css">
+<div id="light-div" class="green">I"m green when light DOM link is on</div>
+
+<div id="host">
+  I"m green when Shadow DOM link is on
+  <template id="shadow-dom">
+    <link id="shadow-link" rel="stylesheet" href="resources/link-rel-attribute.css">
+    <div id="shadow-div" class="green">
+      <slot></slot>
+    </div>
+  </template>
+</div>
+
+<script>
+var host = document.querySelector("#host");
+var shadow = host.attachShadow({ mode: "open" });
+var tmpl = document.querySelector("template#shadow-dom");
+var clone = document.importNode(tmpl.content, true);
+shadow.appendChild(clone);
+
+function testLinkRelModification(testDiv, testLink) {
+  assert_equals(getComputedStyle(testDiv).color, "rgb(0, 128, 0)");
+  testLink.setAttribute("rel", "no-stylesheet");
+  assert_equals(getComputedStyle(testDiv).color, "rgb(0, 0, 0)");
+  testLink.setAttribute("rel", "stylesheet");
+  assert_equals(getComputedStyle(testDiv).color, "rgb(0, 128, 0)");
+  testLink.removeAttribute("rel");
+  assert_equals(getComputedStyle(testDiv).color, "rgb(0, 0, 0)");
+}
+
+test (() => {
+  testLinkRelModification(document.querySelector("#light-div"),
+                          document.querySelector("#light-link"));
+}, "Removing stylesheet from link rel attribute should remove the stylesheet for light DOM");
+
+test (() => {
+  testLinkRelModification(shadow.querySelector("#shadow-div"),
+                          shadow.querySelector("#shadow-link"));
+}, "Removing stylesheet from link rel attribute should remove the stylesheet for shadow DOM");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/resources/link-rel-attribute.css
@@ -0,0 +1,3 @@
+.green {
+  color: green;
+}