tor-browser

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

observe-shadow-text.html (1406B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Element Timing: do not observe text in shadow tree</title>
      4 <style>
      5 body {
      6  margin: 0;
      7 }
      8 </style>
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src="resources/element-timing-helpers.js"></script>
     12 <div id='target'></div>
     13 <script>
     14  async_test(function (t) {
     15    assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
     16    const observer = new PerformanceObserver(
     17      t.step_func_done(function(entryList) {
     18        assert_unreached('Should not observe text elements in shadow trees!');
     19      })
     20    );
     21    observer.observe({entryTypes: ['element']});
     22    // We add the text during onload to be sure that the observer is registered
     23    // in time for it to observe the element timing.
     24    window.onload = () => {
     25      // Add text of width equal to 100 and height equal to 100.
     26      const text = document.createElement('p');
     27      text.innerHTML = 'Text';
     28      text.setAttribute('elementtiming', 'my_text');
     29      const shadowRoot = document.getElementById('target').attachShadow({mode: 'open'});
     30      shadowRoot.appendChild(text);
     31      t.step_timeout(() => {
     32        // Assume entry was not dispatched, so test passes.
     33        t.done();
     34      }, 500);
     35    };
     36  }, 'Text in shadow tree with elementtiming attribute is not observable.');
     37 </script>