From fdf9e231c9d608a4308281b71181a702bdd9ccc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=A1s=20Pe=C3=B1a?=
Date: Fri, 30 Nov 2018 18:01:37 +0000
Subject: [PATCH] Bug 1509598 [wpt PR 14215] - Move EventTiming tests to WPT,
a=testonly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Automatic update from web-platform-tests
Move EventTiming tests to WPT
This CL moves the tests in http/tests/event-timing to external/wpt/event-timing.
The slow image is change from php based to python based. The click is now
handled by test driver. and setTimeout is replaced with step_timeout.
Bug: 841224
Change-Id: I035c087550a2d9a67cda1aed88553c16967d04b6
Reviewed-on: https://chromium-review.googlesource.com/c/1349451
Commit-Queue: Nicolás Peña Moreno
Reviewed-by: Timothy Dresser
Cr-Commit-Position: refs/heads/master@{#610669}
--
wpt-commits: 42061028f3951380908b400fb1b23a2d6e16bb22
wpt-pr: 14215
---
.../event-timing-bufferbeforeonload.html | 75 +++++++++++++++
.../event-timing-crossiframe.html | 90 ++++++++++++++++++
.../event-timing-observer-manual.html | 79 ++++++++++++++++
.../event-timing-observethenonload.html | 91 +++++++++++++++++++
...t-timing-onloadthenobserve-firstInput.html | 52 +++++++++++
.../event-timing-onloadthenobserve.html | 75 +++++++++++++++
.../event-timing-only-observe-firstInput.html | 47 ++++++++++
.../event-timing-retrievability.html | 37 ++++++++
.../event-timing-timingconditions.html | 60 ++++++++++++
.../event-timing-crossiframe-childframe.html | 29 ++++++
...ent-timing-observer-manual-childframe.html | 43 +++++++++
.../resources/event-timing-support.js | 58 ++++++++++++
.../event-timing/resources/slow-image.py | 7 ++
13 files changed, 743 insertions(+)
create mode 100644 testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-crossiframe.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-observer-manual.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-observethenonload.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-only-observe-firstInput.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-retrievability.html
create mode 100644 testing/web-platform/tests/event-timing/event-timing-timingconditions.html
create mode 100644 testing/web-platform/tests/event-timing/resources/event-timing-crossiframe-childframe.html
create mode 100644 testing/web-platform/tests/event-timing/resources/event-timing-observer-manual-childframe.html
create mode 100644 testing/web-platform/tests/event-timing/resources/event-timing-support.js
create mode 100644 testing/web-platform/tests/event-timing/resources/slow-image.py
diff --git a/testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html b/testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
new file mode 100644
index 000000000000..ef71608e0c08
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-bufferbeforeonload.html
@@ -0,0 +1,75 @@
+
+
+
+Event Timing: buffer long-latency events before onload
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-crossiframe.html b/testing/web-platform/tests/event-timing/event-timing-crossiframe.html
new file mode 100644
index 000000000000..877901257b4e
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-crossiframe.html
@@ -0,0 +1,90 @@
+
+
+
+
+
+ Event Timing: entries should be observable by its own frame.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-observer-manual.html b/testing/web-platform/tests/event-timing/event-timing-observer-manual.html
new file mode 100644
index 000000000000..c0bd6f3feec0
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-observer-manual.html
@@ -0,0 +1,79 @@
+
+
+
+
+ Event Timing: entries should be observable by its own frame.
+
+
+
+
+
Description:
+
+
+ The goal of this manual test is to verify that observers that have
+ registered "event" entry type can observe the long-latency input events,
+ and verify the same behavior within iframe and in cross-frame scenario.
+
+
+
Manual test steps:
+
+
+ Step 1: Click the "make busy" button to make main-thread busy for 2 seconds.
+
+
+ Step 2: do several clicks on "click while busy" while busy to generate long-latency inputs.
+
+
+ Step 3: observe in the "timeline" section that the long-latency clicks are captured by the observer.
+
+
+ Step 4: do step 1 to step 3 for the iframe. Observe that the observers only observe input events within its frame.
+
+
+
+
Actions:
+
+
+
+
iframe:
+
+
+
+
Timeline:
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-observethenonload.html b/testing/web-platform/tests/event-timing/event-timing-observethenonload.html
new file mode 100644
index 000000000000..14aec7731820
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-observethenonload.html
@@ -0,0 +1,91 @@
+
+
+
+Event Timing: Performance observers can observe long-latency events
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
new file mode 100644
index 000000000000..e1639304008a
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve-firstInput.html
@@ -0,0 +1,52 @@
+
+
+
+Event Timing: buffer long-latency events before onload
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
new file mode 100644
index 000000000000..a29bc3a27f8c
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-onloadthenobserve.html
@@ -0,0 +1,75 @@
+
+
+
+Event Timing: long-latency events after onload and before observer
+registration are lost
+
+
+
+
+
+
+
+
+
diff --git 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
new file mode 100644
index 000000000000..0300ebe48ec6
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-only-observe-firstInput.html
@@ -0,0 +1,47 @@
+
+
+
+Event Timing: only observe the first input
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-retrievability.html b/testing/web-platform/tests/event-timing/event-timing-retrievability.html
new file mode 100644
index 000000000000..0efda9d44f78
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-retrievability.html
@@ -0,0 +1,37 @@
+
+
+
+Event Timing: make sure event-timing entries are retrievable by existing perf APIs.
+
+
+
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/event-timing-timingconditions.html b/testing/web-platform/tests/event-timing/event-timing-timingconditions.html
new file mode 100644
index 000000000000..24965f4169dd
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/event-timing-timingconditions.html
@@ -0,0 +1,60 @@
+
+
+
+Event Timing only times certain types of trusted event.
+
+
+
+
+
+
+
+
+
diff --git 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
new file mode 100644
index 000000000000..cd292a14da5d
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/resources/event-timing-crossiframe-childframe.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/testing/web-platform/tests/event-timing/resources/event-timing-observer-manual-childframe.html b/testing/web-platform/tests/event-timing/resources/event-timing-observer-manual-childframe.html
new file mode 100644
index 000000000000..99853661bde3
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/resources/event-timing-observer-manual-childframe.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
Actions:
+
+
+
+
+
Timeline:
+
+
+
diff --git a/testing/web-platform/tests/event-timing/resources/event-timing-support.js b/testing/web-platform/tests/event-timing/resources/event-timing-support.js
new file mode 100644
index 000000000000..63827639b8b5
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/resources/event-timing-support.js
@@ -0,0 +1,58 @@
+function clickOnElement(id, resolve) {
+ const element = document.getElementById(id);
+ const clickHandler = () => {
+ element.removeEventListener("click", clickHandler);
+ resolve();
+ };
+ element.addEventListener("click", 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.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,
+ "The entry's duration must be at least as large as processingEnd - startTime.");
+ if (is_first) {
+ let firstInputs = performance.getEntriesByType('firstInput');
+ assert_equals(firstInputs.length, 1, 'There should be a single firstInput entry');
+ let firstInput = firstInputs[0];
+ assert_equals(firstInput.name, entry.name);
+ assert_equals(firstInput.entryType, 'firstInput');
+ assert_equals(firstInput.startTime, entry.startTime);
+ assert_equals(firstInput.duration, entry.duration);
+ assert_equals(firstInput.processingStart, entry.processingStart);
+ assert_equals(firstInput.processingEnd, entry.processingEnd);
+ assert_equals(firstInput.cancelable, entry.cancelable);
+ }
+}
+
+function wait() {
+ return new Promise((resolve, reject) => {
+ step_timeout(() => {
+ resolve();
+ }, 0);
+ });
+}
+
+function clickAndBlockMain(id) {
+ return new Promise((resolve, reject) => {
+ clickOnElement(id, resolve);
+ mainThreadBusy(300);
+ });
+}
diff --git a/testing/web-platform/tests/event-timing/resources/slow-image.py b/testing/web-platform/tests/event-timing/resources/slow-image.py
new file mode 100644
index 000000000000..5c2d1b1fc5d8
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/resources/slow-image.py
@@ -0,0 +1,7 @@
+import time
+
+def main(request, response):
+ # Sleep for 500ms to delay onload.
+ time.sleep(0.5)
+ response.headers.set("Cache-Control", "no-cache, must-revalidate");
+ response.headers.set("Location", "data:image/gif;base64,R0lGODlhAQABAJAAAMjIyAAAACwAAAAAAQABAAACAgQBADs%3D");