Bug 1632253 [wpt PR 23180] - Reland "[EventTiming] Add shadow DOM test for first input", a=testonly
authorNicolás Peña Moreno <npm@chromium.org>
Tue, 28 Apr 2020 11:38:38 +0000
changeset 527587 0b423a6d0e95349c5ff9d424c71c9174fd86203b
parent 527586 2ff1de7ecca0db42609d6dd2d8830144af422777
child 527588 ec6d4d042778ae8d8d00c8b3ddeca04f5dd99824
push id37368
push userbtara@mozilla.com
push dateFri, 01 May 2020 21:45:51 +0000
treeherdermozilla-central@0f9c5a59e45d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1632253, 23180, 543598, 2159622, 761417
milestone77.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 1632253 [wpt PR 23180] - Reland "[EventTiming] Add shadow DOM test for first input", a=testonly Automatic update from web-platform-tests Reland "[EventTiming] Add shadow DOM test for first input" This is a reland of 9591b7074cacf1e8aeb9082dee2a4f46a171083f Original change's description: > [EventTiming] Add shadow DOM test for first input > > This CL tests event.target for first-input. The DOM elements do not have > event listeners to show that event retargetting correctly retargets to > the shadow host. > > Bug: 543598 > Change-Id: Ibd5a4a37a50f79b86d93a5c9c18c8ac7300ba723 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159622 > Reviewed-by: Steve Kobes <skobes@chromium.org> > Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> > Cr-Commit-Position: refs/heads/master@{#761417} Bug: 543598 Change-Id: I21537ddc47075a5f0acaf0b53662b4db242c66a0 -- wpt-commits: 2a3389554f038ed396be6f699414aad23e7fe581 wpt-pr: 23180
testing/web-platform/tests/event-timing/first-input-shadow-dom.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/first-input-shadow-dom.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/resources/testdriver.js></script>
+<script src=/resources/testdriver-vendor.js></script>
+
+<body>
+<div id='container'>
+  <custom-button id='custom_button'></custom-button>
+</div>
+<script>
+promise_test(t => {
+  assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+  let innerButtonClicked = false;
+  customElements.define('custom-button', class extends HTMLElement {
+    connectedCallback() {
+      this.attachShadow({mode: 'open'});
+      this.shadowRoot.innerHTML = `<button id='inner_button_id'>Click me</button>`;
+      this.shadowRoot.getElementById('inner_button_id').onmousedown = () => {
+        innerButtonClicked = true;
+      };
+    }
+  });
+  const observerPromise = new Promise(resolve => {
+    new PerformanceObserver(t.step_func(entryList => {
+      // There must only be one first-input entry.
+      assert_equals(entryList.getEntries().length, 1);
+      // entry.target must be the shadow host due to retargetting.
+      assert_equals(entryList.getEntries()[0].target,
+          document.getElementById('custom_button'));
+      assert_true(innerButtonClicked, 'Did not reach the shadow DOM event listener!');
+      resolve();
+    })).observe({entryTypes: ['first-input']});
+  });
+  const clickPromise = test_driver.click(document.getElementById('custom_button'));
+  return Promise.all([observerPromise, clickPromise]);
+}, "Event Timing: test first input on shadow DOM.");
+</script>
+</body>
+</html>