From 954d954d2839778985e1557b831d4b4e2f336300 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 3 Dec 2020 02:27:01 +0000 Subject: [PATCH] Bug 1677263 - Add a test for select event being async r=masayuki The asynchronous behavior is introduced by using SetSelectionRange inside Select(). This adds a test for that. Differential Revision: https://phabricator.services.mozilla.com/D98186 --- dom/tests/mochitest/chrome/window_focus.xhtml | 2 +- .../forms/textfieldselection/select-event.html | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dom/tests/mochitest/chrome/window_focus.xhtml b/dom/tests/mochitest/chrome/window_focus.xhtml index a07d519af862..aa536dea0b92 100644 --- a/dom/tests/mochitest/chrome/window_focus.xhtml +++ b/dom/tests/mochitest/chrome/window_focus.xhtml @@ -433,7 +433,7 @@ function startTest() expectFocusShift(() => t19.select(), null, getById("t" + 19), true, "input.select()"); t19.removeEventListener("select", selectListener, false); - ok(selectFired, "select event fires for input"); + ok(!selectFired, "select event does not fire asynchronously for input"); // mouse clicking gLastFocusMethod = fm.FLAG_BYMOUSE; diff --git a/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html b/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html index af49024aa2bd..79be87a56a20 100644 --- a/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html +++ b/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html @@ -92,6 +92,17 @@ els.forEach((el) => { // step_wait properly timeouts before the whole test collapses await t.step_wait(() => !element.onselect, "event didn't fire", 200, 10); }, `${elLabel}: ${action.label} disconnected node`); + + // Intentionally still using promise_test, as assert_unreachable does not + // make the test fail inside a listener while t.unreached_func() does. + promise_test(async t => { + const element = el.cloneNode(true); + const listener = t.unreached_func("the select event must not fire synchronously"); + + element.onselect = listener; + action.action(element); + element.onselect = null; + }, `${elLabel}: ${action.label} event queue`); }); });