Bug 1512766 [wpt PR 14422] - [EventTiming] Report events without event handlers, a=testonly
authorNicolas Pena <npm@chromium.org>
Wed, 19 Dec 2018 11:05:23 +0000
changeset 515001 b9180576fd4f5e7e1dc20fd0ac638b4b83e575b3
parent 515000 39b4f64875f6f5e721202a13fdfc000bdd2b02e7
child 515002 12dad58d97d78b38ce3d44268360ea9112e30c24
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1512766, 14422, 823744, 1368458, 616026
milestone66.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 1512766 [wpt PR 14422] - [EventTiming] Report events without event handlers, a=testonly Automatic update from web-platform-tests [EventTiming] Report events without event handlers This CL allows reporting events without event handlers. In particular, this implies that slow clicks cause slow mousedown events, so the tests are modified accordingly. Bug: 823744 Change-Id: I9578519ae538496404bb220001d3ca97565b7bd7 Reviewed-on: https://chromium-review.googlesource.com/c/1368458 Reviewed-by: Timothy Dresser <tdresser@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#616026} -- wpt-commits: 4052654d786236b493d2df3cb80b9d3d1d0a8354 wpt-pr: 14422
testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
testing/web-platform/tests/event-timing/event-timing-crossiframe.html
testing/web-platform/tests/event-timing/event-timing-observethenonload.html
testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
testing/web-platform/tests/event-timing/event-timing-only-observe-firstInput.html
testing/web-platform/tests/event-timing/event-timing-retrievability.html
testing/web-platform/tests/event-timing/event-timing-retrieve-firstInput.html
testing/web-platform/tests/event-timing/event-timing-timingconditions.html
testing/web-platform/tests/event-timing/resources/event-timing-crossiframe-childframe.html
testing/web-platform/tests/event-timing/resources/event-timing-support.js
--- a/testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
+++ b/testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing: buffer long-latency events before onload</title>
-<button id='button' onclick='clickDelay()'>Generate a 'click' event</button>
+<button id='button' onmousedown='clickDelay()'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <img src=resources/slow-image.py>
 
@@ -22,17 +22,17 @@
     if (firstClickStart === 0)
       firstClickStart = onclickStart;
     while(performance.now() < onclickStart + 60) {}
     if (firstClickEnd === 0)
       firstClickEnd = performance.now();
   }
 
   function validateEntries() {
-    const entries = performance.getEntriesByName('click', 'event');
+    const entries = performance.getEntriesByName('mousedown', 'event');
 
     const entriesBeforeOnload = entries.filter(
         e => e.startTime < onloadStart);
     assert_equals(entriesBeforeOnload.length, 1,
         "Long latency events before onload should be buffered.");
     const entry = entriesBeforeOnload[0];
     verifyClickEvent(entry, true);
 
@@ -64,17 +64,18 @@
   */
   async_test(function(t) {
     clickTimeMin = performance.now();
     clickAndBlockMain('button');
     // Use a dummy observer to know when both clicks have been dispatched.
     const observerPromise = new Promise((resolve, reject) => {
       let entryCount = 0;
       new PerformanceObserver(entryList => {
-        entryCount += entryList.getEntries().length;
+        entryCount += entryList.getEntries().filter(
+          entry => entry.name === 'mousedown').length;
         if (entryCount >= 2)
           resolve();
       }).observe({ entryTypes: ['event'] });
     });
     // Event handlers will be dispatched asynchronously, so this will be called
     // before processing begins.
     processingStartMin = performance.now();
     on_event(window, 'load', e => {
--- a/testing/web-platform/tests/event-timing/event-timing-crossiframe.html
+++ b/testing/web-platform/tests/event-timing/event-timing-crossiframe.html
@@ -2,32 +2,32 @@
 <html>
 
 <head>
   <meta charset=utf-8 />
   <title>Event Timing: entries should be observable by its own frame.</title>
 </head>
 
 <body>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <img src=./resources/slow-image.py>
 <iframe src=resources/event-timing-crossiframe-childframe.html></iframe>
 <script>
   let clickTimeMin;
   let processingStartMin;
   let onloadStart;
 
   function validateEntries() {
-    const entries = performance.getEntriesByName('click', 'event');
+    const entries = performance.getEntriesByName('mousedown', 'event');
 
     assert_equals(entries.length, 1,
       "Observer of main frames should only capture main-frame event-timing entries."
     );
     const entry = entries[0];
     verifyClickEvent(entry, true);
 
     assert_greater_than(entry.processingStart, processingStartMin,
--- a/testing/web-platform/tests/event-timing/event-timing-observethenonload.html
+++ b/testing/web-platform/tests/event-timing/event-timing-observethenonload.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing: Performance observers can observe long-latency events
 </title>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <img src=resources/slow-image.py>
 
@@ -72,32 +72,33 @@
      Click 2 arrives
      End Busy Loop
      (Dispatch and Process Click 2 (buffered, observed))
      observer callback start
   */
   async_test(function(t) {
     const observerPromise = new Promise((resolve, reject) => {
       new PerformanceObserver(function(entryList) {
-        observedEntries = observedEntries.concat(entryList.getEntries());
+        observedEntries = observedEntries.concat(entryList.getEntries().filter(
+          entry => entry.name === 'mousedown'));
         if (observedEntries.length < 2) return;
         resolve(observedEntries);
       }).observe({ entryTypes: ['event'] });
     });
     timeBeforeFirstClick = performance.now();
     clickAndBlockMain('button').then( () => {
       timeAfterFirstClick = performance.now();
     });
     on_event(window, 'load', function(e) {
       onloadStart = performance.now();
       // After onload start and before registering observer.
       const bufferPromise = clickAndBlockMain('button').then(wait);
       Promise.all([observerPromise, bufferPromise]).then((results) => {
         timeAfterSecondClick = performance.now();
         t.step(verifyObserverEntries.bind(null, results[0]));
-        t.step(verifyBuffer.bind(null, performance.getEntriesByName('click', 'event')));
+        t.step(verifyBuffer.bind(null, performance.getEntriesByName('mousedown', 'event')));
         t.done();
       });
     });
   }, "Event Timing: click, observer, onload, click.");
 
 </script>
 </html>
--- a/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
+++ b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing: buffer long-latency events before onload</title>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 
 <script>
@@ -18,17 +18,18 @@
      Click 2
      PerformanceObserver should observe only one firstInput entry.
      (Dispatch and Process Click 2 - not buffered)
   */
   async_test(function(t) {
     let numFirstInputObserved = 0;
     let numEventsObserved = 0;
     new PerformanceObserver(t.step_func((entryList, obs) => {
-        const observedEntries = entryList.getEntries();
+        const observedEntries = entryList.getEntries().filter(
+            entry => entry.name === 'mousedown');
         numEventsObserved += observedEntries.filter(entry =>
             entry.entryType == 'event').length;
         numFirstInputObserved += observedEntries.filter(entry =>
             entry.entryType == 'firstInput').length;
         if (numEventsObserved >= 2) {
           assert_equals(performance.getEntriesByType('event').length, 0,
             "There should be no buffered event entries.");
           assert_equals(performance.getEntriesByType('firstInput').length, 1,
--- a/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
+++ b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
@@ -1,29 +1,29 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing: long-latency events after onload and before observer
 registration are lost
 </title>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <script>
   let callbackTime;
   let observerStart;
   let processingStartMin;
 
   function verifyBufferAndObserverEntries(observedEntries) {
     // Verify buffer entries
-    const bufferedEntries = performance.getEntriesByName('click', 'event');
+    const bufferedEntries = performance.getEntriesByName('mousedown', 'event');
     const bufferedEntriesBeforeObserver = bufferedEntries.filter(e => e.startTime <
       observerStart);
     assert_equals(bufferedEntries.length, 0,
       "Long latency events after onload should not be buffered."
     );
 
     // Verify observer entries
     assert_equals(observedEntries.length, 1, "Long latency task after observer start should be observed.");
@@ -37,17 +37,18 @@ registration are lost
         "The entry's start time should be later than observer start.");
     assert_greater_than(callbackTime, entry.startTime,
         "The callback time should be later than entry's start time.");
   }
 
   function startObserver(t) {
     new PerformanceObserver(t.step_func_done((entryList, obs) => {
         callbackTime = performance.now();
-        const observedEntries = entryList.getEntries();
+        const observedEntries = entryList.getEntries().filter(
+            entry => entry.name === 'mousedown');
         verifyBufferAndObserverEntries(observedEntries);
       })).observe({ entryTypes: ['event'] });
     observerStart = performance.now();
   }
 
   /* Timeline:
      Onload Event fires
      Begin Busy Loop
--- a/testing/web-platform/tests/event-timing/event-timing-only-observe-firstInput.html
+++ b/testing/web-platform/tests/event-timing/event-timing-only-observe-firstInput.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing: only observe the first input</title>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 
 <script>
@@ -19,20 +19,21 @@
      Expected result:
      PerformanceObserver should observe one and only one entry.
   */
   async_test(function(t) {
     let hasObservedFirstInput = false;
     new PerformanceObserver(t.step_func((entryList) => {
         assert_false(hasObservedFirstInput);
         hasObservedFirstInput = true;
-        const observedEntries = entryList.getEntries();
+        const observedEntries = entryList.getEntries().filter(
+            entry => entry.name === 'mousedown');
         assert_equals(observedEntries.length, 1);
         assert_equals(observedEntries[0].entryType, 'firstInput');
-        assert_equals(observedEntries[0].name, 'click');
+        assert_equals(observedEntries[0].name, 'mousedown');
     })).observe({ entryTypes: ['firstInput'] });
     on_event(window, 'load', () => {
       clickAndBlockMain('button').then(() => {
         clickAndBlockMain('button').then(wait).then( () => {
           // After some wait, the PerformanceObserver should have processed both clicks.
           // One and only one firstInput entry should have been dispatched, so
           // |hasObservedFirstInput| should be true.
           t.step_timeout( () => {
--- a/testing/web-platform/tests/event-timing/event-timing-retrievability.html
+++ b/testing/web-platform/tests/event-timing/event-timing-retrievability.html
@@ -1,24 +1,24 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8>
 <title>Event Timing: make sure event-timing entries are retrievable by existing perf APIs.</title>
-<button id='button' onclick='1'>Generate a 'click' event</button>
+<button id='button'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <img src=resources/slow-image.py>
 
 <script>
   function validateEntries() {
-    const entriesByName = performance.getEntriesByName('click', 'event');
+    const entriesByName = performance.getEntriesByName('mousedown', 'event');
     const entriesByType = performance.getEntriesByType('event');
     const allEntries = performance.getEntries();
     assert_equals(entriesByName.length, 1, 'event-timing entry should be retrievable by getEntriesByName');
     const e = entriesByName[0];
     assert_true(entriesByType.includes(e), 'event-timing entry should be retrievable by getEntries');
     assert_true(allEntries.includes(e), 'event-timing entry should be retrievable by getEntriesByType');
   }
 
--- a/testing/web-platform/tests/event-timing/event-timing-retrieve-firstInput.html
+++ b/testing/web-platform/tests/event-timing/event-timing-retrieve-firstInput.html
@@ -16,17 +16,17 @@
       // First callback is not ensured to have the entry.
       if (performance.getEntriesByType('firstInput').length === 0) {
         t.step_timeout(testEntries, 10);
         return;
       }
       assert_equals(performance.getEntriesByType('firstInput').length, 1,
         "There should be a firstInput entry in the performance timeline");
       const entry = performance.getEntriesByType('firstInput')[0];
-      assert_equals(entry.name, 'click');
+      assert_equals(entry.name, 'mousedown');
       assert_equals(entry.entryType, 'firstInput');
       assert_greater_than(entry.duration, 50,
         "The first input was a long one.");
       t.done();
     }
     clickAndBlockMain('button').then(wait).then(t.step_func(testEntries));
   },
   "Event Timing: check firstInput after onload, observer, click, click."
--- a/testing/web-platform/tests/event-timing/event-timing-timingconditions.html
+++ b/testing/web-platform/tests/event-timing/event-timing-timingconditions.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <html>
 <meta charset=utf-8 />
 <title>Event Timing only times certain types of trusted event.
 </title>
-<button id='button' onclick='mainThreadBusy(60)'
+<button id='button' onmousedown='mainThreadBusy(60)'
   onfocus='mainThreadBusy(60)'>Generate a 'click' event</button>
 <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>
 
 <script src=resources/event-timing-support.js></script>
 <script>
@@ -18,34 +18,35 @@
       trustedClickStart = performance.now();
       clickOnElement(id, resolve);
     });
   }
 
   function untrustedClickAndBlockMain(id) {
     const target = document.getElementById(id);
     // Block mainthread in the callback, as dispatchEvent() is a sync call.
-    target.dispatchEvent(new MouseEvent('click'));
+    target.dispatchEvent(new MouseEvent('mousedown'));
   }
 
   function trustedFocusAndBlockMain(id) {
     const target = document.getElementById(id);
     trustedFocusStart = performance.now();
     // Block mainthread in the callback,  as focus() is a sync call.
     target.focus();
   }
 
   async_test(function(t) {
     new PerformanceObserver(t.step_func_done(entryList => {
       const observerCallbackTime = performance.now();
-      const entries = entryList.getEntries();
+      const entries = entryList.getEntries().filter(
+          entry => entry.name === 'mousedown');
       assert_equals(entries.length, 1,
           "Should only observe one entry: " +
           JSON.stringify(entries) + ".");
-      assert_equals(entries[0].name, 'click',
+      assert_equals(entries[0].name, 'mousedown',
           "The observed entry should be a click");
       assert_less_than(entries[0].startTime, observerCallbackTime,
           "The startTime should be before observerCallbackTime");
       assert_greater_than(entries[0].startTime, trustedClickStart,
           "The startTime should be after trustedClickStart");
     })).observe({ entryTypes: ['event'] });
     // Untrusted event of a type event timing cares about.
     untrustedClickAndBlockMain('button');
--- a/testing/web-platform/tests/event-timing/resources/event-timing-crossiframe-childframe.html
+++ b/testing/web-platform/tests/event-timing/resources/event-timing-crossiframe-childframe.html
@@ -1,20 +1,20 @@
 <!DOCType html>
 <html>
 <script src=event-timing-support.js></script>
-<button id='button_child_frame' onclick='2'>Generate a 'click' event</button>
+<button id='button_child_frame'>Generate a 'click' event</button>
 <img src=slow-image.py>
 <script>
   const clickTimeMin = performance.now();
   clickAndBlockMain('button_child_frame');
   const processingStartMin = performance.now();
   const observerPromise = new Promise((resolve, reject) => {
     new PerformanceObserver((entryList) => {
-      resolve(entryList.getEntries());
+      resolve(entryList.getEntries().filter(entry => entry.name === 'mousedown'));
     }).observe({ entryTypes: ['event'] });
   });
   window.addEventListener('load', e => {
     observerPromise.then((observedEntries) => {
       const onloadStart = performance.now();
       const bufferedEntries = performance.getEntriesByType('event');
       top.postMessage({
         "bufferedEntries" : bufferedEntries,
--- a/testing/web-platform/tests/event-timing/resources/event-timing-support.js
+++ b/testing/web-platform/tests/event-timing/resources/event-timing-support.js
@@ -6,33 +6,33 @@ function clickOnElement(id, callback) {
   const rect = element.getBoundingClientRect();
   const xCenter = rect.x + rect.width / 2;
   const yCenter = rect.y + rect.height / 2;
   const leftButton = 0;
   const clickHandler = () => {
     mainThreadBusy(60);
     if (callback)
       callback();
-    element.removeEventListener("click", clickHandler);
+    element.removeEventListener("mousedown", clickHandler);
   };
-  element.addEventListener("click", clickHandler);
+  element.addEventListener("mousedown", clickHandler);
   test_driver.click(element);
 }
 
 function mainThreadBusy(duration) {
   const now = performance.now();
   while (performance.now() < now + duration);
 }
 
 // This method should receive an entry of type 'event'. |is_first| is true only
 // when the event also happens to correspond to the first event. In this case,
 // the timings of the 'firstInput' entry should be equal to those of this entry.
 function verifyClickEvent(entry, is_first=false) {
   assert_true(entry.cancelable);
-  assert_equals(entry.name, 'click');
+  assert_equals(entry.name, 'mousedown');
   assert_equals(entry.entryType, 'event');
   assert_greater_than(entry.duration, 50,
       "The entry's duration should be greater than 50ms.");
   assert_greater_than(entry.processingStart, entry.startTime,
       "The entry's processingStart should be greater than startTime.");
   assert_greater_than_equal(entry.processingEnd, entry.processingStart,
       "The entry's processingEnd must be at least as large as processingStart.");
   assert_greater_than_equal(entry.duration, entry.processingEnd - entry.startTime,