Bug 1137694 - Avoid calling content methods directly in browser_net_sort-03.js; r=past
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 02 Mar 2015 12:06:41 +0100
changeset 249005 37409aced15c32b9ad23ee530ab17a99140e69ce
parent 249004 e6839726fe1df0aa5d0ce7450d9972d08aea099c
child 249006 784963e853520164caa46b735c559ccab10797b5
push id966
push usermleibovic@mozilla.com
push dateTue, 10 Mar 2015 01:36:33 +0000
reviewerspast
bugs1137694
milestone39.0a1
Bug 1137694 - Avoid calling content methods directly in browser_net_sort-03.js; r=past
browser/devtools/netmonitor/test/browser.ini
browser/devtools/netmonitor/test/browser_net_sort-02.js
browser/devtools/netmonitor/test/browser_net_sort-03.js
browser/devtools/netmonitor/test/html_sorting-test-page.html
--- a/browser/devtools/netmonitor/test/browser.ini
+++ b/browser/devtools/netmonitor/test/browser.ini
@@ -95,16 +95,15 @@ skip-if = e10s # Bug 1091612
 [browser_net_security-warnings.js]
 [browser_net_simple-init.js]
 [browser_net_simple-request-data.js]
 [browser_net_simple-request-details.js]
 [browser_net_simple-request.js]
 [browser_net_sort-01.js]
 [browser_net_sort-02.js]
 [browser_net_sort-03.js]
-skip-if = (os == 'linux' && e10s && !debug) # bug 1137694
 [browser_net_statistics-01.js]
 [browser_net_statistics-02.js]
 [browser_net_statistics-03.js]
 [browser_net_status-codes.js]
 [browser_net_timeline_ticks.js]
 [browser_net_timing-division.js]
 [browser_net_persistent_logs.js]
--- a/browser/devtools/netmonitor/test/browser_net_sort-02.js
+++ b/browser/devtools/netmonitor/test/browser_net_sort-02.js
@@ -11,16 +11,36 @@ function test() {
 
     // It seems that this test may be slow on debug builds. This could be because
     // of the heavy dom manipulation associated with sorting.
     requestLongerTimeout(2);
 
     let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
     let { RequestsMenu } = NetMonitorView;
 
+    // Loading the frame script and preparing the xhr request URLs so we can
+    // generate some requests later.
+    loadCommonFrameScript();
+    let requests = [{
+      url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
+      method: "GET1"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
+      method: "GET5"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
+      method: "GET2"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
+      method: "GET4"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
+      method: "GET3"
+    }];
+
     RequestsMenu.lazyUpdate = false;
 
     waitForNetworkEvents(aMonitor, 5).then(() => {
       EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
 
       isnot(RequestsMenu.selectedItem, null,
         "There should be a selected item in the requests menu.");
       is(RequestsMenu.selectedIndex, 0,
@@ -264,11 +284,13 @@ function test() {
           transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.05),
           size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.05),
           time: true
         });
 
       return promise.resolve(null);
     }
 
-    aDebuggee.performRequests();
+    performRequestsInContent(requests).then(null, e => {
+      ok(false, e);
+    });
   });
 }
--- a/browser/devtools/netmonitor/test/browser_net_sort-03.js
+++ b/browser/devtools/netmonitor/test/browser_net_sort-03.js
@@ -11,16 +11,36 @@ function test() {
 
     // It seems that this test may be slow on debug builds. This could be because
     // of the heavy dom manipulation associated with sorting.
     requestLongerTimeout(2);
 
     let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
     let { RequestsMenu } = NetMonitorView;
 
+    // Loading the frame script and preparing the xhr request URLs so we can
+    // generate some requests later.
+    loadCommonFrameScript();
+    let requests = [{
+      url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
+      method: "GET1"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
+      method: "GET5"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
+      method: "GET2"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
+      method: "GET4"
+    }, {
+      url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
+      method: "GET3"
+    }];
+
     RequestsMenu.lazyUpdate = false;
 
     waitForNetworkEvents(aMonitor, 5).then(() => {
       EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
 
       isnot(RequestsMenu.selectedItem, null,
         "There should be a selected item in the requests menu.");
       is(RequestsMenu.selectedIndex, 0,
@@ -33,33 +53,33 @@ function test() {
         .then(() => {
           info("Testing status sort, ascending.");
           EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
           testHeaders("status", "ascending");
           return testContents([0, 1, 2, 3, 4], 0);
         })
         .then(() => {
           info("Performing more requests.");
-          aDebuggee.performRequests();
+          performRequestsInContent(requests);
           return waitForNetworkEvents(aMonitor, 5);
         })
         .then(() => {
           info("Testing status sort again, ascending.");
           testHeaders("status", "ascending");
           return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
         })
         .then(() => {
           info("Testing status sort, descending.");
           EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
           testHeaders("status", "descending");
           return testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9);
         })
         .then(() => {
           info("Performing more requests.");
-          aDebuggee.performRequests();
+          performRequestsInContent(requests);
           return waitForNetworkEvents(aMonitor, 5);
         })
         .then(() => {
           info("Testing status sort again, descending.");
           testHeaders("status", "descending");
           return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
         })
         .then(() => {
@@ -72,17 +92,21 @@ function test() {
           info("Testing status sort yet again, descending.");
           EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
           testHeaders("status", "descending");
           return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
         })
         .then(() => {
           return teardown(aMonitor);
         })
-        .then(finish);
+        .then(finish, e => {
+          ok(false, e);
+        });
+    }, e => {
+      ok(false, e);
     });
 
     function testHeaders(aSortType, aDirection) {
       let doc = aMonitor.panelWin.document;
       let target = doc.querySelector("#requests-menu-" + aSortType + "-button");
       let headers = doc.querySelectorAll(".requests-menu-header-button");
 
       for (let header of headers) {
@@ -186,11 +210,11 @@ function test() {
             size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.05),
             time: true
           });
       }
 
       return promise.resolve(null);
     }
 
-    aDebuggee.performRequests();
+    performRequestsInContent(requests).then(null, Cu.reportError);
   });
 }
--- a/browser/devtools/netmonitor/test/html_sorting-test-page.html
+++ b/browser/devtools/netmonitor/test/html_sorting-test-page.html
@@ -8,40 +8,11 @@
     <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
     <meta http-equiv="Pragma" content="no-cache" />
     <meta http-equiv="Expires" content="0" />
     <title>Network Monitor test page</title>
   </head>
 
   <body>
     <p>Sorting test</p>
-
-    <script type="text/javascript">
-      function get(aAddress, aIndex, aCallback) {
-        var xhr = new XMLHttpRequest();
-        // Use a random parameter to defeat caching.
-        xhr.open("GET" + aIndex, aAddress + "?index=" + aIndex + "&" + Math.random(), true);
-
-        xhr.onreadystatechange = function() {
-          if (this.readyState == this.DONE) {
-            aCallback();
-          }
-        };
-        xhr.send(null);
-      }
-
-      function performRequests() {
-        get("sjs_sorting-test-server.sjs", 1, function() {
-          get("sjs_sorting-test-server.sjs", 5, function() {
-            get("sjs_sorting-test-server.sjs", 2, function() {
-              get("sjs_sorting-test-server.sjs", 4, function() {
-                get("sjs_sorting-test-server.sjs", 3, function() {
-                  // Done.
-                });
-              });
-            });
-          });
-        });
-      }
-    </script>
   </body>
 
 </html>