tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

chaining-invalid-selector.html (1894B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>CSS Shadow Parts - Chaining Invalid Selector</title>
      5    <meta href="mailto:fergal@chromium.org" rel="author" title="Fergal Daly">
      6    <link href="http://www.google.com/" rel="author" title="Google">
      7    <link href="https://drafts.csswg.org/css-shadow-parts/" rel="help">
      8    <script src="/resources/testharness.js"></script>
      9    <script src="/resources/testharnessreport.js"></script>
     10    <script src="support/shadow-helper.js"></script>
     11  </head>
     12  <body>
     13    <style>#c-e-outer::part(c-e-part)::part(partp) { color: red; }</style>
     14    <div>
     15      It's invalid to use 2 pseudoelements in a selector but if somehow it becomes valid,
     16      it should not expose the internal structure of the shadow tree.
     17    </div>
     18    <script>installCustomElement("custom-element-inner", "custom-element-inner-template");</script>
     19    <template id="custom-element-inner-template">
     20      <style>span { color: green; }</style>
     21      <span id="part" part="partp">This text</span>
     22    </template>
     23    <script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
     24    <template id="custom-element-outer-template">
     25      The following text should be green:
     26      <custom-element-inner id="c-e-inner" part="c-e-part"></custom-element-inner>
     27    </template>
     28    <custom-element-outer id="c-e-outer"></custom-element-outer>
     29    <script>
     30      "use strict";
     31      const colorGreen = "rgb(0, 128, 0)";
     32      test(function() {
     33        const el = getElementByShadowIds(document, ["c-e-outer", "c-e-inner", "part"]);
     34        assert_equals(window.getComputedStyle(el).color, colorGreen);
     35      }, "::part cannot be chained to reach elements in the inner host");
     36      test(function() {
     37        assert_equals(document.getElementsByTagName("body")[0].style.length, 0);
     38      }, "Chained ::part selectors are dropped");
     39    </script>
     40  </body>
     41 </html>