Commit 38786b89 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Fix http/tests/event-timing/event-timing-onloadthenobserve.html

Changes this test to properly wait for the first synthetic click
event to fire before proceeding with the rest of the test and validating
its expectations.

Bug: 872081
Change-Id: I0954ef7deff8415600effbc79cca7402a1b51583
Reviewed-on: https://chromium-review.googlesource.com/1170173
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582184}
parent f0ba93e4
......@@ -59,7 +59,7 @@ registration are lost
*/
async_test(function(t) {
on_event(window, 'load', () => {
clickAndBlockMain('button').then(wait).then(() => {
clickAndBlockMain('button').then(() => {
startObserver(t);
clickAndBlockMain('button').then(wait);
processingStartMin = performance.now();
......
function clickOnElement(id) {
const rect = document.getElementById(id).getBoundingClientRect();
function clickOnElement(id, callback) {
const element = document.getElementById(id);
const rect = element.getBoundingClientRect();
const xCenter = rect.x + rect.width / 2;
const yCenter = rect.y + rect.height / 2;
var pointerActions = [{
......@@ -9,6 +10,12 @@ function clickOnElement(id) {
{ name: "pointerUp" },
]
}];
var clickHandler = () => {
if (callback)
callback();
element.removeEventListener("click", clickHandler);
};
element.addEventListener("click", clickHandler);
if (!chrome || !chrome.gpuBenchmarking) {
reject();
} else {
......@@ -60,8 +67,7 @@ function wait() {
function clickAndBlockMain(id) {
return new Promise((resolve, reject) => {
clickOnElement(id);
clickOnElement(id, resolve);
mainThreadBusy(300);
resolve();
});
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment