From 93d2bb3408ef3c6745d689c4bee81a7d2d1c2c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 19 Sep 2022 21:57:12 +0000 Subject: [PATCH] Bug 1781434 - Clean-up dialog initial focus code. r=pbz,Gijs Make it a bit easier to read and less prone to race conditions. Remove a setTimeout referencing bug 103197 which I'm pretty sure it's not an issue. Differential Revision: https://phabricator.services.mozilla.com/D156543 --- dom/xul/test/test_bug398289.html | 21 +-- toolkit/components/prompts/test/chrome.ini | 5 +- .../prompts/test/test_modal_prompts.html | 8 +- .../tests/chrome/dialog_dialogfocus.xhtml | 60 ++++----- toolkit/content/widgets/dialog.js | 127 +++++++++--------- 5 files changed, 116 insertions(+), 105 deletions(-) diff --git a/dom/xul/test/test_bug398289.html b/dom/xul/test/test_bug398289.html index eae7f2d923b9..c4873fe2b261 100644 --- a/dom/xul/test/test_bug398289.html +++ b/dom/xul/test/test_bug398289.html @@ -6,33 +6,34 @@ - - + + - diff --git a/toolkit/components/prompts/test/chrome.ini b/toolkit/components/prompts/test/chrome.ini index 54c8617a3b4c..e0dfad35ea21 100644 --- a/toolkit/components/prompts/test/chrome.ini +++ b/toolkit/components/prompts/test/chrome.ini @@ -4,9 +4,8 @@ support-files = chromeScript.js [test_modal_prompts.html] -skip-if = - toolkit == 'android' +skip-if = + toolkit == 'android' os == 'linux' && (debug || asan) #android: TIMED_OUT (For Linux : 950636) - win10_2004 # Bug 1781434 [test_modal_select.html] skip-if = toolkit == 'android' #android: TIMED_OUT diff --git a/toolkit/components/prompts/test/test_modal_prompts.html b/toolkit/components/prompts/test/test_modal_prompts.html index cd4ac7f8c000..df3438dbba53 100644 --- a/toolkit/components/prompts/test/test_modal_prompts.html +++ b/toolkit/components/prompts/test/test_modal_prompts.html @@ -1063,13 +1063,19 @@ async function runTests(util) { passValue: "", checkMsg: "", checked: false, - focused: "infoBody", + focused: null, // Nothing focused until the delay triggers. defButton: "button0", butt0Label: "OK", butt1Label: "Cancel", butt0Disabled: true, }; + if (isOSX) { + // OS X doesn't initially focus the button, but rather the infoBody. + // The focus stays there even after the button-enable delay has fired. + state.focused = "infoBody"; + } + action = { buttonClick: "pollOK", }; diff --git a/toolkit/content/tests/chrome/dialog_dialogfocus.xhtml b/toolkit/content/tests/chrome/dialog_dialogfocus.xhtml index 29e3c2d85625..bcd303b52f32 100644 --- a/toolkit/content/tests/chrome/dialog_dialogfocus.xhtml +++ b/toolkit/content/tests/chrome/dialog_dialogfocus.xhtml @@ -1,7 +1,6 @@ - @@ -24,38 +23,37 @@