Bug 1236737 - Stop intermittent timeouts in browser_cmd_screenshot.js. r=me, a=test-only
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 03 Aug 2016 12:09:43 +0100
changeset 347694 002e71897e08600cbf7fd8c71e2ea2d46c71d28f
parent 347693 bb547a13e6230a742054af026048571b8686687d
child 347695 185eea0d3e023a0ddf27be25889e1c22e1445d9a
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme, test-only
bugs1236737
milestone50.0a2
Bug 1236737 - Stop intermittent timeouts in browser_cmd_screenshot.js. r=me, a=test-only MozReview-Commit-ID: DLlHhPMWIB5
devtools/client/commandline/test/browser_cmd_screenshot.js
--- a/devtools/client/commandline/test/browser_cmd_screenshot.js
+++ b/devtools/client/commandline/test/browser_cmd_screenshot.js
@@ -1,20 +1,27 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* global helpers, btoa, whenDelayedStartupFinished, OpenBrowserWindow */
 
 // Test that screenshot command works properly
+
+"use strict";
+
 const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
                  "test/browser_cmd_screenshot.html";
 
 var FileUtils = (Cu.import("resource://gre/modules/FileUtils.jsm", {})).FileUtils;
 
 function test() {
+  // This test gets bombarded by a cascade of GCs and often takes 50s so lets be
+  // safe and give the test 90s to run.
+  requestLongerTimeout(3);
+
   return Task.spawn(spawnTest).then(finish, helpers.handleError);
 }
 
 function* spawnTest() {
   waitForExplicitFinish();
 
   info("RUN TEST: non-private window");
   let normWin = yield addWindow({ private: false });
@@ -32,61 +39,61 @@ function* addTabWithToolbarRunTests(win)
   let browser = options.browser;
   yield helpers.openToolbar(options);
 
   // Test input status
   yield helpers.audit(options, [
     {
       setup: "screenshot",
       check: {
-        input:  "screenshot",
+        input: "screenshot",
         markup: "VVVVVVVVVV",
         status: "VALID",
         args: {
         }
       },
     },
     {
       setup: "screenshot abc.png",
       check: {
-        input:  "screenshot abc.png",
+        input: "screenshot abc.png",
         markup: "VVVVVVVVVVVVVVVVVV",
         status: "VALID",
         args: {
           filename: { value: "abc.png"},
         }
       },
     },
     {
       setup: "screenshot --fullpage",
       check: {
-        input:  "screenshot --fullpage",
+        input: "screenshot --fullpage",
         markup: "VVVVVVVVVVVVVVVVVVVVV",
         status: "VALID",
         args: {
           fullpage: { value: true},
         }
       },
     },
     {
       setup: "screenshot abc --delay 5",
       check: {
-        input:  "screenshot abc --delay 5",
+        input: "screenshot abc --delay 5",
         markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
         status: "VALID",
         args: {
           filename: { value: "abc"},
           delay: { value: 5 },
         }
       },
     },
     {
       setup: "screenshot --selector img#testImage",
       check: {
-        input:  "screenshot --selector img#testImage",
+        input: "screenshot --selector img#testImage",
         markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
         status: "VALID",
       },
     },
   ]);
 
   // Test capture to file
   let file = FileUtils.getFile("TmpD", [ "TestScreenshotFile.png" ]);
@@ -123,37 +130,39 @@ function* addTabWithToolbarRunTests(win)
         args: {
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
-          Assert.equal(imgSize.width, content.innerWidth, "Image width matches window size");
-          Assert.equal(imgSize.height, content.innerHeight, "Image height matches window size");
+        let imgSize1 = yield getImageSizeFromClipboard();
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
+          Assert.equal(imgSize.width, content.innerWidth,
+                       "Image width matches window size");
+          Assert.equal(imgSize.height, content.innerHeight,
+                       "Image height matches window size");
         });
       })
     },
     {
       setup: "screenshot --fullpage --clipboard",
       check: {
         args: {
           fullpage: { value: true },
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
+        let imgSize1 = yield getImageSizeFromClipboard();
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
           Assert.equal(imgSize.width,
             content.innerWidth + content.scrollMaxX - content.scrollMinX,
             "Image width matches page size");
           Assert.equal(imgSize.height,
             content.innerHeight + content.scrollMaxY - content.scrollMinY,
             "Image height matches page size");
         });
       })
@@ -164,18 +173,18 @@ function* addTabWithToolbarRunTests(win)
         args: {
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
+        let imgSize1 = yield getImageSizeFromClipboard();
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
           let img = content.document.querySelector("img#testImage");
           Assert.equal(imgSize.width, img.clientWidth,
              "Image width matches element size");
           Assert.equal(imgSize.height, img.clientHeight,
              "Image height matches element size");
         });
       })
     },
@@ -212,20 +221,20 @@ function* addTabWithToolbarRunTests(win)
         args: {
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        imgSize.scrollbarWidth = scrollbarSize.width;
-        imgSize.scrollbarHeight = scrollbarSize.height;
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
+        let imgSize1 = yield getImageSizeFromClipboard();
+        imgSize1.scrollbarWidth = scrollbarSize.width;
+        imgSize1.scrollbarHeight = scrollbarSize.height;
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
           Assert.equal(imgSize.width, content.innerWidth - imgSize.scrollbarWidth,
              "Image width matches window size minus scrollbar size");
           Assert.equal(imgSize.height, content.innerHeight - imgSize.scrollbarHeight,
              "Image height matches window size minus scrollbar size");
         });
       })
     },
     {
@@ -235,42 +244,44 @@ function* addTabWithToolbarRunTests(win)
           fullpage: { value: true },
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        imgSize.scrollbarWidth = scrollbarSize.width;
-        imgSize.scrollbarHeight = scrollbarSize.height;
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
+        let imgSize1 = yield getImageSizeFromClipboard();
+        imgSize1.scrollbarWidth = scrollbarSize.width;
+        imgSize1.scrollbarHeight = scrollbarSize.height;
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
           Assert.equal(imgSize.width,
-            (content.innerWidth + content.scrollMaxX - content.scrollMinX) - imgSize.scrollbarWidth,
+            (content.innerWidth + content.scrollMaxX -
+             content.scrollMinX) - imgSize.scrollbarWidth,
             "Image width matches page size minus scrollbar size");
           Assert.equal(imgSize.height,
-            (content.innerHeight + content.scrollMaxY - content.scrollMinY) - imgSize.scrollbarHeight,
+            (content.innerHeight + content.scrollMaxY -
+             content.scrollMinY) - imgSize.scrollbarHeight,
             "Image height matches page size minus scrollbar size");
         });
       })
     },
     {
       setup: "screenshot --selector img#testImage --clipboard",
       check: {
         args: {
           clipboard: { value: true },
         },
       },
       exec: {
         output: new RegExp("^Copied to clipboard.$"),
       },
       post: Task.async(function* () {
-        let imgSize = yield getImageSizeFromClipboard();
-        yield ContentTask.spawn(browser, imgSize, function* (imgSize) {
+        let imgSize1 = yield getImageSizeFromClipboard();
+        yield ContentTask.spawn(browser, imgSize1, function* (imgSize) {
           let img = content.document.querySelector("img#testImage");
           Assert.equal(imgSize.width, img.clientWidth,
              "Image width matches element size");
           Assert.equal(imgSize.height, img.clientHeight,
              "Image height matches element size");
         });
       })
     },