Bug 1381684 - Fix intermittent browser/components/extensions/test/browser/browser_ext_tabs_lastAccessed.js, r=mixedpuppy
authorBob Silverberg <bsilverberg@mozilla.com>
Mon, 30 Oct 2017 13:39:53 -0400
changeset 444223 c908b2bffe6e8991ede42e196358e7db3041a9be
parent 444222 cf6c386ae59c4d5a8120eddaf06e69ba6996dc49
child 444224 bad9f2a1be214b9bc5277fe766fe0d5a7d146ad4
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1381684 - Fix intermittent browser/components/extensions/test/browser/browser_ext_tabs_lastAccessed.js, r=mixedpuppy This patch introduces two changes to the test: 1. It breaks apart the assertion that was combining three tests into individual assertions, so if this does fail again in the future it will be easier to spot the actual problem. 2. It uses addTab and browserLoaded instead of openNewForegroundTab, which seems to allow the test to wait long enough before starting the extension. When I was able to reproduce the failure, after separating the assertions, I found the one that was failing was the check that tab2.lastAccessed was less than the current time. I believe that the current time was being recorded too soon, which is why I changed the test to not record the current time until after both tabs have completed loading. This seems to fix the intermittent locally for me. MozReview-Commit-ID: I3VoYODwjgz
--- a/browser/components/extensions/test/browser/browser_ext_tabs_lastAccessed.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_lastAccessed.js
@@ -1,37 +1,37 @@
 "use strict";
 add_task(async function testLastAccessed() {
   let past = Date.now();
-  await BrowserTestUtils.openNewForegroundTab(gBrowser, "https://example.com/?1");
-  await BrowserTestUtils.openNewForegroundTab(gBrowser, "https://example.com/?2");
+  for (let url of ["https://example.com/?1", "https://example.com/?2"]) {
+    let tab = BrowserTestUtils.addTab(gBrowser, url, {skipAnimation: true});
+    await BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, url);
+  }
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["tabs"],
     async background() {
       browser.test.onMessage.addListener(async function(msg, past) {
-        if (msg !== "past") {
-          return;
-        }
         let [tab1] = await browser.tabs.query({url: "https://example.com/?1"});
         let [tab2] = await browser.tabs.query({url: "https://example.com/?2"});
         browser.test.assertTrue(tab1 && tab2, "Expected tabs were found");
         let now = Date.now();
-        browser.test.assertTrue(past < tab1.lastAccessed &&
-                                tab1.lastAccessed < tab2.lastAccessed &&
-                                tab2.lastAccessed <= now,
-                                "lastAccessed timestamps are recent and in the right order");
+        browser.test.assertTrue(past < tab1.lastAccessed,
+                                "lastAccessed of tab 1 is later than the test start time.");
+        browser.test.assertTrue(tab1.lastAccessed < tab2.lastAccessed,
+                                "lastAccessed of tab 2 is later than lastAccessed of tab 1.");
+        browser.test.assertTrue(tab2.lastAccessed <= now,
+                                "lastAccessed of tab 2 is earlier than now.");
         await browser.tabs.remove([tab1.id, tab2.id]);