Skip to content

Commit

Permalink
Fix usage of onload = t.step_timeout in WPT tests
Browse files Browse the repository at this point in the history
t.step_timeout directly invokes setTimeout, so this pattern doesn't
actually wait for onload. The pattern, as used elsewhere, should be
something like:

  onload = () => t.step_timeout

One app-history test in particular was causing issues as it became
dependent timer task ordering.

Bug: 1220223
Change-Id: I2a8c74e485833a3bc15cc53320c791ecb80452af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3499359
Auto-Submit: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/main@{#976889}
  • Loading branch information
shaseley authored and chromium-wpt-export-bot committed Mar 3, 2022
1 parent f8c76b1 commit c88357f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Expand Up @@ -5,7 +5,7 @@
promise_test(async t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0));
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
await appHistory.navigate("#foo").committed;
assert_equals(appHistory.entries().length, 2);

Expand Down
Expand Up @@ -5,7 +5,7 @@
promise_test(async t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0));
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));

let oncurrentchange_called = false;
let original_entry = appHistory.current;
Expand Down
Expand Up @@ -5,7 +5,7 @@
promise_test(async t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0));
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));

let oncurrentchange_called = false;
appHistory.oncurrentchange = t.step_func(e => {
Expand Down
Expand Up @@ -5,7 +5,7 @@
promise_test(async t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = t.step_timeout(resolve, 0));
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
await appHistory.navigate("#foo");
assert_equals(appHistory.entries().length, 2);

Expand Down
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
window.onload = t.step_timeout(() => {
window.onload = () => t.step_timeout(() => {
let start_length = history.length;
let target_key = appHistory.current.key;
let target_id = appHistory.current.id;
Expand Down
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
window.onload = t.step_timeout(() => {
window.onload = () => t.step_timeout(() => {
let start_length = history.length;
let target_key = appHistory.current.key;
let target_id = appHistory.current.id;
Expand Down
Expand Up @@ -16,7 +16,7 @@

<script>
async_test(t => {
window.onload = t.step_timeout(() => {
window.onload = () => t.step_timeout(() => {
let state = document.getElementById('emptyOnFirstVisit');
let selectMenu = document.getElementById("selectmenu0");

Expand Down

0 comments on commit c88357f

Please sign in to comment.