From 02ffd74c11d3826a80a99ad3c62dbb18b72f0706 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Wed, 15 Jan 2020 18:27:10 +0000 Subject: [PATCH] Bug 1602991 - Fix intermittent browser/components/urlbar/tests/browser/browser_urlbar_locationchange_urlbar_edit_dos.js r=Gijs The test messages the content script to trigger a web-progress change and waits for the change. The problem is that those two actions race each other. In the intermittent failures, the web-progress change happens before the test adds a listener for it. The test first should add its listener and then message the content script to trigger the change. This try run is all green with many retriggers: https://treeherder.mozilla.org/#/jobs?repo=try&revision=6990ce980eff124ef28c41195ae57e0fd2b1f25b&group_state=expanded Differential Revision: https://phabricator.services.mozilla.com/D59976 --HG-- extra : moz-landing-system : lando --- ...r_urlbar_locationchange_urlbar_edit_dos.js | 19 +++++++++++++------ .../tests/browser/file_urlbar_edit_dos.html | 9 ++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_locationchange_urlbar_edit_dos.js b/browser/components/urlbar/tests/browser/browser_urlbar_locationchange_urlbar_edit_dos.js index d4e22e1e1f96..925f8b0ac5bc 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbar_locationchange_urlbar_edit_dos.js +++ b/browser/components/urlbar/tests/browser/browser_urlbar_locationchange_urlbar_edit_dos.js @@ -18,7 +18,13 @@ async function checkURLBarValueStays(browser) { ); gBrowser.selectedBrowser.removeProgressListener(filter); filter = null; - resolve(); + // Wait an extra tick before resolving. We want to make sure that other + // web progress listeners queued after this one are called before we + // continue the test, in case the remainder of the test depends on those + // listeners. That should happen anyway since promises are resolved on + // the next tick, but do this to be a little safer. In particular we + // want to avoid having the test pass when it should fail. + executeSoon(resolve); }, }; let filter = Cc[ @@ -46,15 +52,16 @@ add_task(async function() { url: TEST_URL, }, async function(browser) { - await SpecialPowers.spawn(browser, [""], function() { + let promise1 = checkURLBarValueStays(browser); + SpecialPowers.spawn(browser, [""], function() { content.wrappedJSObject.dos_hash(); }); - await checkURLBarValueStays(browser); - await SpecialPowers.spawn(browser, [""], function() { - content.clearTimeout(content.wrappedJSObject.dos_timeout); + await promise1; + let promise2 = checkURLBarValueStays(browser); + SpecialPowers.spawn(browser, [""], function() { content.wrappedJSObject.dos_pushState(); }); - await checkURLBarValueStays(browser); + await promise2; } ); }); diff --git a/browser/components/urlbar/tests/browser/file_urlbar_edit_dos.html b/browser/components/urlbar/tests/browser/file_urlbar_edit_dos.html index 5a6e7d109a78..e02242f6a16e 100644 --- a/browser/components/urlbar/tests/browser/file_urlbar_edit_dos.html +++ b/browser/components/urlbar/tests/browser/file_urlbar_edit_dos.html @@ -6,17 +6,12 @@