tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ceff2c4667375bcdf88af5c172ca0d43ad60e4bc
parent 586624bd07be7092174cdbc99f616279f668dcb4
Author: Orko Garai <orko@igalia.com>
Date:   Fri, 19 Dec 2025 09:14:50 +0000

Bug 2002354 [wpt PR 56270] - Fix focus related failures due to URL bar being focused on launch, a=testonly

Automatic update from web-platform-tests
Fix focus related failures due to URL bar being focused on launch

Chromium-based browsers automatically focus the URL bar on launch which can prevent focus events from firing. Fix this by ensuring the page has focus first and in some cases simply change the expectation to use document.activeElement instead.
--

wpt-commits: 744d45bafb0ca4f75f19941da2d4a4d9d85b7748
wpt-pr: 56270

Diffstat:
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html | 2++
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html | 2++
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-focus-in-frames.html | 5+++++
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html | 7+++++--
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document.html | 8+++++++-
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js | 4++--
Mtesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html | 2++
Mtesting/web-platform/tests/inert/inert-node-is-unfocusable.html | 19+++++++++++++------
8 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html @@ -1,6 +1,8 @@ <!DOCTYPE html> <html> <head> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="./resources/common.js"></script> diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html @@ -1,6 +1,8 @@ <!DOCTYPE html> <html> <head> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="./resources/common.js"></script> diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-focus-in-frames.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-focus-in-frames.html @@ -3,6 +3,8 @@ <link rel=author href="mailto:falken@chromium.org"> <link rel=help href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element"> <link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=242848"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> @@ -32,6 +34,9 @@ window.onload = frameLoaded; promise_test(async () => { await framesLoadedPromise; + // Chrome and edge auto-focus the URL bar when the browser is launched. + // This is needed to ensure the 'focus' events fire below. + await test_driver.click(document.documentElement); function testFocus(element, expectFocus) { let focusedElement = null; diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable.html @@ -3,6 +3,8 @@ <head> <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#blocked-by-a-modal-dialog"> <meta name="assert" content="Checks that, when opening modal dialogs, inert nodes are not focusable."> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> </head> @@ -33,7 +35,7 @@ dialog { // The test passses if only the topmost dialog and its button are focusable. function testFocus(element, expectFocus) { - test(function() { + promise_test(async function() { var focusedElement = null; element.addEventListener('focus', function() { focusedElement = element; }, false); element.focus(); @@ -56,7 +58,8 @@ function testTree(element, expectFocus) { var bottomDialog = document.getElementById('bottom-dialog'); var topDialog = document.getElementById('top-dialog'); -setup(function() { +promise_setup(async function() { + await test_driver.click(document.documentElement); bottomDialog.showModal(); topDialog.showModal(); add_completion_callback(function() { diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document.html @@ -1,6 +1,8 @@ <!DOCTYPE html> <html> <head> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> </head> @@ -19,7 +21,11 @@ function testFocus(element, expectFocus) { assert_equals(focusedElement === theElement, expectFocus, element.id); } -test(function() { +promise_setup(async function() { + await test_driver.click(document.documentElement); +}) + +promise_test(async function() { var dialog = document.querySelector('dialog'); dialog.showModal(); diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js @@ -14,5 +14,6 @@ function waitUntilLoadedAndAutofocused() { if (loaded) resolve(); }, false); + test_driver.click(document.documentElement); }); -} -\ No newline at end of file +} diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/show-modal-focusing-steps.html @@ -1,6 +1,8 @@ <!DOCTYPE html> <html> <head> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="./resources/common.js"></script> diff --git a/testing/web-platform/tests/inert/inert-node-is-unfocusable.html b/testing/web-platform/tests/inert/inert-node-is-unfocusable.html @@ -4,6 +4,8 @@ <meta charset="utf-8" /> <title>inert nodes are unfocusable</title> <link rel="author" title="Alice Boxhall" href="aboxhall@chromium.org"> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> </head> @@ -43,30 +45,35 @@ function testTree(element, expectFocus, excludeCurrent) { testTree(childNodes[i], expectFocus); } +promise_setup(async () => { + // Chrome and edge auto-focus the URL bar when the browser is launched. + // This is needed to ensure the 'focus' events fire below. + await test_driver.click(document.documentElement); +}); -test(function() { +promise_test(async function() { testFocus(document.getElementById('focusable'), true); }, "Button outside of inert container is focusable."); -test(function() { +promise_test(async function() { testFocus(document.getElementById('inert'), false); }, "Button with inert atribute is unfocusable."); -test(function() { +promise_test(async function() { testTree(document.getElementById('container'), false); }, "All focusable elements inside inert subtree are unfocusable"); -test(function() { +promise_test(async function() { assert_false(document.getElementById("focusable").inert, "Inert not set explicitly is false") assert_true(document.getElementById("inert").inert, "Inert set explicitly is true"); assert_true(document.getElementById("container").inert, "Inert set on container is true"); }, "Can get inert via property"); -test(function() { +promise_test(async function() { assert_false(document.getElementById("text").inert, "Elements inside of inert subtrees return false when getting inert"); }, "Elements inside of inert subtrees return false when getting 'inert'"); -test(function() { +promise_test(async function() { document.getElementById('focusable').inert = true; testFocus(document.getElementById('focusable'), false); document.getElementById('inert').inert = false;