From b4255790dcd474c32f0b0357d147e28ec96807fa Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Tue, 3 Dec 2024 21:18:08 +0000 Subject: [PATCH] Always consume user activation when opending a new window Per https://github.com/whatwg/html/pull/10547, we should always consume the user activation even if the popup blocker is disabled or the window has permission to open a new window. Differential Revision: https://phabricator.services.mozilla.com/D230331 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1930458 gecko-commit: a63ca42b209f7b7eb5d84a897d4f7a6efacbf98c gecko-reviewers: smaug --- .../consume-user-activation/window-open.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/html/browsers/windows/consume-user-activation/window-open.html b/html/browsers/windows/consume-user-activation/window-open.html index 8328d99a1de07c..5304c656b2d2ed 100644 --- a/html/browsers/windows/consume-user-activation/window-open.html +++ b/html/browsers/windows/consume-user-activation/window-open.html @@ -15,5 +15,19 @@ testWin.close(); }); assert_false(navigator.userActivation.isActive, "User activation should be consumed"); -}); +}, "Opening a new window should consume user activation"); + +promise_test(async function(t) { + await test_driver.bless("user activation"); + const testWin = window.open("/resources/blank.html", "testWindow"); + assert_false(navigator.userActivation.isActive, "User activation should be consumed"); + t.add_cleanup(() => { + testWin.close(); + }); + + // Open the existing window again + await test_driver.bless("user activation"); + const testWin2 = window.open("/resources/blank.html", "testWindow"); + assert_true(navigator.userActivation.isActive, "User activation should not be consumed"); +}, "Opening an existing window should not consume user activation");