tor-browser

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

event-retarget.html (1437B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script src=/resources/testdriver.js></script>
      7 <script src=/resources/testdriver-vendor.js></script>
      8 
      9 <script src=resources/event-timing-test-utils.js></script>
     10 
     11 <custom-button id='custom_button'></custom-button>
     12 
     13 <script>
     14 async_test(function(t) {
     15  assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     16  let innerButtonClicked = false;
     17  customElements.define('custom-button', class extends HTMLElement {
     18    connectedCallback() {
     19      this.attachShadow({mode: 'open'});
     20      this.shadowRoot.innerHTML = `<button id='inner_button_id'>Click me</button>`;
     21      this.shadowRoot.getElementById('inner_button_id').onclick = () => {
     22        innerButtonClicked = true;
     23      };
     24    }
     25  });
     26  const observer = new PerformanceObserver(t.step_func((entryList) => {
     27    const entries = entryList.getEntriesByName('pointerdown');
     28    if (entries.length === 0)
     29      return;
     30 
     31    // There must only be one pointerdown entry.
     32    assert_equals(entries.length, 1);
     33    verifyClickEvent(entries[0], 'custom_button', true);
     34    assert_true(innerButtonClicked);
     35    t.done()
     36  }));
     37  observer.observe({entryTypes: ['event']});
     38  clickAndBlockMain('custom_button');
     39 }, "Event Timing: target reports the last Event Target, i.e. nothing from shadow DOM.");
     40 </script>
     41 </html>