Bug 1256846 - Switch to add_task for browser_webconsole_bug_601352_scroll.js. r=tromey, a=test-only
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 05 May 2016 11:37:46 -0700
changeset 333108 61411310ed8af6c7dc6d5442c6617dfa9ac377b6
parent 333107 d81a217b8759fa910321a7e1fddb0adf55615853
child 333109 8ebfcbda759ef1d642ca82a26170a5bebe6671dd
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey, test-only
bugs1256846
milestone48.0a2
Bug 1256846 - Switch to add_task for browser_webconsole_bug_601352_scroll.js. r=tromey, a=test-only MozReview-Commit-ID: KfE0WOKeLGW
devtools/client/webconsole/test/browser_webconsole_bug_601352_scroll.js
--- a/devtools/client/webconsole/test/browser_webconsole_bug_601352_scroll.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_601352_scroll.js
@@ -3,86 +3,82 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the console output scrolls to JS eval results when there are many
 // messages displayed. See bug 601352.
 
 "use strict";
 
-function test() {
-  Task.spawn(runner).then(finishTest);
-
-  function* runner() {
-    let {tab} = yield loadTab("data:text/html;charset=utf-8,Web Console test " +
-                              "for bug 601352");
-    let hud = yield openConsole(tab);
-    hud.jsterm.clearOutput();
+add_task(function* () {
+  let {tab} = yield loadTab("data:text/html;charset=utf-8,Web Console test " +
+                            "for bug 601352");
+  let hud = yield openConsole(tab);
+  hud.jsterm.clearOutput();
 
-    yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
-      let longMessage = "";
-      for (let i = 0; i < 50; i++) {
-        longMessage += "LongNonwrappingMessage";
-      }
+  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
+    let longMessage = "";
+    for (let i = 0; i < 50; i++) {
+      longMessage += "LongNonwrappingMessage";
+    }
 
-      for (let i = 0; i < 50; i++) {
-        content.console.log("test1 message " + i);
-      }
+    for (let i = 0; i < 50; i++) {
+      content.console.log("test1 message " + i);
+    }
 
-      content.console.log(longMessage);
+    content.console.log(longMessage);
 
-      for (let i = 0; i < 50; i++) {
-        content.console.log("test2 message " + i);
-      }
-    });
+    for (let i = 0; i < 50; i++) {
+      content.console.log("test2 message " + i);
+    }
+  });
 
-    yield waitForMessages({
-      webconsole: hud,
-      messages: [{
-        text: "test1 message 0",
-      }, {
-        text: "test1 message 49",
-      }, {
-        text: "LongNonwrappingMessage",
-      }, {
-        text: "test2 message 0",
-      }, {
-        text: "test2 message 49",
-      }],
-    });
+  yield waitForMessages({
+    webconsole: hud,
+    messages: [{
+      text: "test1 message 0",
+    }, {
+      text: "test1 message 49",
+    }, {
+      text: "LongNonwrappingMessage",
+    }, {
+      text: "test2 message 0",
+    }, {
+      text: "test2 message 49",
+    }],
+  });
 
-    let node = yield hud.jsterm.execute("1+1");
+  let node = yield hud.jsterm.execute("1+1");
 
-    let scrollNode = hud.ui.outputWrapper;
-    let rectNode = node.getBoundingClientRect();
-    let rectOutput = scrollNode.getBoundingClientRect();
+  let scrollNode = hud.ui.outputWrapper;
+  let rectNode = node.getBoundingClientRect();
+  let rectOutput = scrollNode.getBoundingClientRect();
 
-    yield ContentTask.spawn(gBrowser.selectedBrowser, {
-      rectNode,
-      rectOutput,
-      scrollHeight: scrollNode.scrollHeight,
-      scrollTop: scrollNode.scrollTop,
-      clientHeight: scrollNode.clientHeight,
-    }, function* (args) {
-      console.debug("rectNode", args.rectNode, "rectOutput", args.rectOutput);
-      console.log("scrollNode scrollHeight", args.scrollHeight,
-                  "scrollTop", args.scrollTop, "clientHeight",
-                  args.clientHeight);
-    });
+  yield ContentTask.spawn(gBrowser.selectedBrowser, {
+    rectNode,
+    rectOutput,
+    scrollHeight: scrollNode.scrollHeight,
+    scrollTop: scrollNode.scrollTop,
+    clientHeight: scrollNode.clientHeight,
+  }, function* (args) {
+    console.debug("rectNode", args.rectNode, "rectOutput", args.rectOutput);
+    console.log("scrollNode scrollHeight", args.scrollHeight,
+                "scrollTop", args.scrollTop, "clientHeight",
+                args.clientHeight);
+  });
 
-    isnot(scrollNode.scrollTop, 0, "scroll location is not at the top");
+  isnot(scrollNode.scrollTop, 0, "scroll location is not at the top");
 
-    // The bounding client rect .top/left coordinates are relative to the
-    // console iframe.
+  // The bounding client rect .top/left coordinates are relative to the
+  // console iframe.
 
-    // Visible scroll viewport.
-    let height = rectOutput.height;
+  // Visible scroll viewport.
+  let height = rectOutput.height;
 
-    // Top and bottom coordinates of the last message node, relative to the
-    // outputNode.
-    let top = rectNode.top - rectOutput.top;
-    let bottom = top + rectNode.height;
-    info("node top " + top + " node bottom " + bottom + " node clientHeight " +
-         node.clientHeight);
+  // Top and bottom coordinates of the last message node, relative to the
+  // outputNode.
+  let top = rectNode.top - rectOutput.top;
+  let bottom = top + rectNode.height;
+  info("node top " + top + " node bottom " + bottom + " node clientHeight " +
+       node.clientHeight);
 
-    ok(top >= 0 && bottom <= height, "last message is visible");
-  }
-}
+  ok(top >= 0 && bottom <= height, "last message is visible");
+});