Bug 957952 - Hopefully fix browser_net_timing-division.js by waiting for the first request to finish. r=vporof, a=test-only
authorVictor Porof <vporof@mozilla.com>
Thu, 12 Jun 2014 12:16:59 -0400
changeset 208388 5cb9be441de9e1e18a45c66e31f1fc7497b08c5f
parent 208387 a1f8113488973b6bf1fe1cac013694a43265a38d
child 208389 55155b4af80d1ddd2f5aead4ed36ab130ba1ae30
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof, test-only
bugs957952
milestone32.0a2
Bug 957952 - Hopefully fix browser_net_timing-division.js by waiting for the first request to finish. r=vporof, a=test-only
browser/devtools/netmonitor/test/browser_net_timing-division.js
--- a/browser/devtools/netmonitor/test/browser_net_timing-division.js
+++ b/browser/devtools/netmonitor/test/browser_net_timing-division.js
@@ -10,22 +10,55 @@ function test() {
     info("Starting test... ");
 
     let { $all, NetMonitorView } = aMonitor.panelWin;
     let { RequestsMenu } = NetMonitorView;
 
     RequestsMenu.lazyUpdate = false;
 
     waitForNetworkEvents(aMonitor, 2).then(() => {
-      let divisions = $all(".requests-menu-timings-division[division-scale=second]");
+      let millisecondDivs = $all(".requests-menu-timings-division[division-scale=millisecond]");
+      let secondDivs = $all(".requests-menu-timings-division[division-scale=second]");
+      let minuteDivs = $all(".requests-menu-timings-division[division-scale=minute]");
+
+      info("Number of millisecond divisions: " + millisecondDivs.length);
+      info("Number of second divisions: " + secondDivs.length);
+      info("Number of minute divisions: " + minuteDivs.length);
 
-      ok(divisions.length,
+      for (let div of millisecondDivs) {
+        info("Millisecond division: " + div.getAttribute("value"));
+      }
+      for (let div of secondDivs) {
+        info("Second division: " + div.getAttribute("value"));
+      }
+      for (let div of minuteDivs) {
+        info("Minute division: " + div.getAttribute("value"));
+      }
+
+      is(RequestsMenu.itemCount, 2,
+        "There should be only two requests made.");
+
+      let firstRequest = RequestsMenu.getItemAtIndex(0);
+      let lastRequest = RequestsMenu.getItemAtIndex(1);
+
+      info("First request happened at: " +
+        firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
+      info("Last request happened at: " +
+        lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
+
+      ok(secondDivs.length,
         "There should be at least one division on the seconds time scale.");
-      ok(divisions[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/),
+      ok(secondDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/),
         "The division on the seconds time scale looks legit.");
 
       teardown(aMonitor).then(finish);
     });
 
-    aDebuggee.performRequests(1);
-    window.setTimeout(() => aDebuggee.performRequests(1), 2000);
+    aDebuggee.get(Math.random(), () => {
+      // Timeout needed for having enough divisions on the time scale.
+      setTimeout(() => {
+        aDebuggee.get(Math.random(), () => {
+          // Done.
+        });
+      }, 3000);
+    });
   });
 }