Bug 1106181 - Don't wait for TAB_UPDATED in browser_net_details-no-duplicated-content.js if there's not going to be one. r=vporof
authorSami Jaktholm <sjakthol@outlook.com>
Sat, 03 Jan 2015 18:47:32 +0200
changeset 248214 7b4b861a642e79c1731945d75181252b592e6b0e
parent 248213 6001258c480c27faa1b48adb6498b2cf5dc6a49a
child 248215 ff084cf799446340125a44ff0008d34d6b0e0568
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1106181
milestone37.0a1
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 1106181 - Don't wait for TAB_UPDATED in browser_net_details-no-duplicated-content.js if there's not going to be one. r=vporof
browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js
--- a/browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js
+++ b/browser/devtools/netmonitor/test/browser_net_details-no-duplicated-content.js
@@ -97,20 +97,59 @@ let test = Task.async(function* () {
 
     ok(true, "Received NETWORK_EVENT. Selecting the item.");
     let item = RequestsMenu.getItemAtIndex(0);
     RequestsMenu.selectedItem = item;
 
     info("Item selected. Waiting for NETWORKDETAILSVIEW_POPULATED");
     yield onDetailsPopulated;
 
-    info("Selecting tab at index " + tabIndex);
+    info("Received populated event. Selecting tab at index " + tabIndex);
     NetworkDetails.widget.selectedIndex = tabIndex;
 
-    ok(true, "Received NETWORKDETAILSVIEW_POPULATED. Waiting for request to finish");
+    info("Waiting for request to finish.");
     yield onRequestFinished;
 
-    ok(true, "Request finished. Waiting for tab update to complete");
-    let onDetailsUpdateFinished = waitFor(panel, EVENTS.TAB_UPDATED);
-    yield onDetailsUpdateFinished;
-    ok(true, "Details were updated");
+    ok(true, "Request finished.");
+
+    /**
+     * Because this test uses lazy updates there's four scenarios to consider:
+     * #1: Everything is updated and test is ready to continue.
+     * #2: There's updates that are waiting to be flushed.
+     * #3: Updates are flushed but the tab update is still running.
+     * #4: There's pending updates and a tab update is still running.
+     *
+     * For case #1 there's not going to be a TAB_UPDATED event so don't wait for
+     * it (bug 1106181).
+     *
+     * For cases #2 and #3 it's enough to wait for one TAB_UPDATED event as for
+     * - case #2 the next flush will perform the final update and single
+     *   TAB_UPDATED event is emitted.
+     * - case #3 the running update is the final update that'll emit one
+     *   TAB_UPDATED event.
+     *
+     * For case #4 we must wait for the updates to be flushed before we can
+     * start waiting for TAB_UPDATED event or we'll continue the test right
+     * after the pending update finishes.
+     */
+    let hasQueuedUpdates = RequestsMenu._updateQueue.length !== 0;
+    let hasRunningTabUpdate = NetworkDetails._viewState.updating[tabIndex];
+
+    if (hasQueuedUpdates || hasRunningTabUpdate) {
+      info("There's pending updates - waiting for them to finish.");
+      info("  hasQueuedUpdates: " + hasQueuedUpdates);
+      info("  hasRunningTabUpdate: " + hasRunningTabUpdate);
+
+      if (hasQueuedUpdates && hasRunningTabUpdate) {
+        info("Waiting for updates to be flushed.");
+        // _flushRequests calls .populate which emits the following event
+        yield waitFor(panel, EVENTS.NETWORKDETAILSVIEW_POPULATED);
+
+        info("Requests flushed.");
+      }
+
+      info("Waiting for final tab update.");
+      yield waitFor(panel, EVENTS.TAB_UPDATED);
+    }
+
+    info("All updates completed.");
   }
 });