Skip to content

Commit

Permalink
Unload: reject promise on pagehide instead of unload
Browse files Browse the repository at this point in the history
This test fails in Chrome because it depends on the promise triggered
by unload event. This CL changes it to pagehide handler so it would be
triggered as expected even after unload is deprecated in Chrome.
In other browsers, pagehide is also triggered for the case that is
tested by the test (detecting navigation), and is more reliable than
unload.

Bug: 1488371
Change-Id: If44b78e5ff89b1d5ba8901be48cb9ad118a67650
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5070653
Reviewed-by: Rakina Zata Amni <[email protected]>
Reviewed-by: Kent Tamura <[email protected]>
Commit-Queue: Nonoka Muraki <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1233805}
  • Loading branch information
nononokam authored and chromium-wpt-export-bot committed Dec 6, 2023
1 parent e6679c0 commit 746807e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

// If the newly-opened window tries to navigate, fail the test.
const failPromise = new Promise((resolve, reject) => {
win.onunload = () =>
win.onpagehide = () =>
reject(new Error("Navigation was attempted to unparseable URL"));
});

Expand Down

0 comments on commit 746807e

Please sign in to comment.