From d7d15d402a2ac08a7c3aeca5446e6e18e46cda7e Mon Sep 17 00:00:00 2001 From: Anny Gakhokidze Date: Tue, 30 Nov 2021 16:31:35 +0000 Subject: [PATCH] Bug 1721217 - Part 4: Fix search tests to wait for a stop event a bit longer, r=nika Differential Revision: https://phabricator.services.mozilla.com/D126844 --- .../tabs/browser_progress_keyword_search_handling.js | 4 ++++ .../search/test/browser/browser_google_behavior.js | 9 ++++----- .../test/browser/browser_searchEngine_behaviors.js | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/browser/base/content/test/tabs/browser_progress_keyword_search_handling.js b/browser/base/content/test/tabs/browser_progress_keyword_search_handling.js index 32b8f124b7f6..99af24ac8f1e 100644 --- a/browser/base/content/test/tabs/browser_progress_keyword_search_handling.js +++ b/browser/base/content/test/tabs/browser_progress_keyword_search_handling.js @@ -50,6 +50,10 @@ add_task(async function test_unknown_host() { EventUtils.synthesizeKey("KEY_Enter"); await searchPromise; + // With parent initiated loads, we need to give XULBrowserWindow + // time to process the STATE_START event and set the attribute to true. + await new Promise(resolve => executeSoon(resolve)); + ok(kButton.hasAttribute("displaystop"), "Should be showing stop"); await TestUtils.waitForCondition( diff --git a/browser/components/search/test/browser/browser_google_behavior.js b/browser/components/search/test/browser/browser_google_behavior.js index e02124fd2caf..726d23418d9b 100644 --- a/browser/components/search/test/browser/browser_google_behavior.js +++ b/browser/components/search/test/browser/browser_google_behavior.js @@ -193,12 +193,11 @@ async function testSearchEngine(engineDetails) { await test.preTest(tab); } + let googleUrl = + "https://www.google.com/search?client=" + test.code + "&q=foo"; let promises = [ - BrowserTestUtils.waitForDocLoadAndStopIt( - "https://www.google.com/search?client=" + test.code + "&q=foo", - tab - ), - BrowserTestUtils.browserStopped(tab.linkedBrowser, null, true), + BrowserTestUtils.waitForDocLoadAndStopIt(googleUrl, tab), + BrowserTestUtils.browserStopped(tab.linkedBrowser, googleUrl, true), ]; await test.run(tab); diff --git a/browser/components/search/test/browser/browser_searchEngine_behaviors.js b/browser/components/search/test/browser/browser_searchEngine_behaviors.js index 527f70f22bab..819bf92caf9b 100644 --- a/browser/components/search/test/browser/browser_searchEngine_behaviors.js +++ b/browser/components/search/test/browser/browser_searchEngine_behaviors.js @@ -173,8 +173,8 @@ async function testSearchEngine(engineDetails) { async preTest(tab) { let browser = tab.linkedBrowser; BrowserTestUtils.loadURI(browser, "about:newtab"); - await BrowserTestUtils.browserLoaded(browser, false, "about:newtab"); + await BrowserTestUtils.browserLoaded(browser, false, "about:newtab"); await promiseContentSearchReady(browser); }, async run(tab) { @@ -199,7 +199,7 @@ async function testSearchEngine(engineDetails) { let promises = [ BrowserTestUtils.waitForDocLoadAndStopIt(test.searchURL, tab), - BrowserTestUtils.browserStopped(tab.linkedBrowser, null, true), + BrowserTestUtils.browserStopped(tab.linkedBrowser, test.searchURL, true), ]; await test.run(tab);