Bug 1217591 - Run autocomplete tests in worker console;r=fitzgen
authorBrian Grinstead <bgrinstead@mozilla.com>
Mon, 26 Oct 2015 11:55:41 -0700
changeset 304764 5b9e910d10b36246bea85e61ff43989ecdd7775c
parent 304763 15acf2adefd0b290084399db1f4b2256cedcae62
child 304765 c428767bf698ed72291ad05623e7ade44632df1c
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1217591
milestone44.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 1217591 - Run autocomplete tests in worker console;r=fitzgen
devtools/shared/webconsole/test/chrome.ini
devtools/shared/webconsole/test/common.js
devtools/shared/webconsole/test/console-test-worker.js
devtools/shared/webconsole/test/test_basics.html
devtools/shared/webconsole/test/test_bug819670_getter_throws.html
devtools/shared/webconsole/test/test_commands_other.html
devtools/shared/webconsole/test/test_commands_registration.html
devtools/shared/webconsole/test/test_console_styling.html
devtools/shared/webconsole/test/test_consoleapi.html
devtools/shared/webconsole/test/test_consoleapi_innerID.html
devtools/shared/webconsole/test/test_jsterm.html
devtools/shared/webconsole/test/test_jsterm_autocomplete.html
devtools/shared/webconsole/test/test_jsterm_cd_iframe.html
devtools/shared/webconsole/test/test_jsterm_last_result.html
devtools/shared/webconsole/test/test_jsterm_queryselector.html
devtools/shared/webconsole/test/test_network_get.html
devtools/shared/webconsole/test/test_network_longstring.html
devtools/shared/webconsole/test/test_network_post.html
devtools/shared/webconsole/test/test_network_security-hpkp.html
devtools/shared/webconsole/test/test_network_security-hsts.html
devtools/shared/webconsole/test/test_object_actor.html
devtools/shared/webconsole/test/test_object_actor_native_getters.html
devtools/shared/webconsole/test/test_object_actor_native_getters_lenient_this.html
devtools/shared/webconsole/test/test_reflow.html
devtools/shared/webconsole/test/test_throw.html
--- a/devtools/shared/webconsole/test/chrome.ini
+++ b/devtools/shared/webconsole/test/chrome.ini
@@ -2,28 +2,30 @@
 tags = devtools
 skip-if = buildapp == 'b2g'
 support-files =
   common.js
   data.json
   data.json^headers^
   network_requests_iframe.html
   sandboxed_iframe.html
+  console-test-worker.js
 
 [test_basics.html]
 [test_bug819670_getter_throws.html]
 [test_cached_messages.html]
 [test_commands_other.html]
 [test_commands_registration.html]
 [test_consoleapi.html]
 [test_consoleapi_innerID.html]
 [test_console_styling.html]
 [test_file_uri.html]
 [test_reflow.html]
 [test_jsterm.html]
+[test_jsterm_autocomplete.html]
 [test_jsterm_cd_iframe.html]
 [test_jsterm_last_result.html]
 [test_jsterm_queryselector.html]
 [test_network_get.html]
 [test_network_longstring.html]
 [test_network_post.html]
 [test_network_security-hpkp.html]
 [test_network_security-hsts.html]
--- a/devtools/shared/webconsole/test/common.js
+++ b/devtools/shared/webconsole/test/common.js
@@ -45,17 +45,27 @@ function connectToDebugger(aCallback)
 
   let transport = DebuggerServer.connectPipe();
   let client = new DebuggerClient(transport);
 
   let dbgState = { dbgClient: client };
   client.connect(aCallback.bind(null, dbgState));
 }
 
-function attachConsole(aListeners, aCallback, aAttachToTab)
+function attachConsole(aListeners, aCallback) {
+  _attachConsole(aListeners, aCallback);
+}
+function attachConsoleToTab(aListeners, aCallback) {
+  _attachConsole(aListeners, aCallback, true);
+}
+function attachConsoleToWorker(aListeners, aCallback) {
+  _attachConsole(aListeners, aCallback, true, true);
+}
+
+function _attachConsole(aListeners, aCallback, aAttachToTab, aAttachToWorker)
 {
   function _onAttachConsole(aState, aResponse, aWebConsoleClient)
   {
     if (aResponse.error) {
       Cu.reportError("attachConsole failed: " + aResponse.error + " " +
                      aResponse.message);
     }
 
@@ -76,21 +86,36 @@ function attachConsole(aListeners, aCall
       aState.dbgClient.listTabs(function _onListTabs(aResponse) {
         if (aResponse.error) {
           Cu.reportError("listTabs failed: " + aResponse.error + " " +
                          aResponse.message);
           aCallback(aState, aResponse);
           return;
         }
         let tab = aResponse.tabs[aResponse.selected];
-        let consoleActor = tab.consoleActor;
-        aState.dbgClient.attachTab(tab.actor, function () {
-          aState.actor = consoleActor;
-          aState.dbgClient.attachConsole(consoleActor, aListeners,
-                                         _onAttachConsole.bind(null, aState));
+        aState.dbgClient.attachTab(tab.actor, function (response, tabClient) {
+          if (aAttachToWorker) {
+            var worker = new Worker("console-test-worker.js");
+            worker.addEventListener("message", function listener() {
+              worker.removeEventListener("message", listener);
+              tabClient.listWorkers(function (response) {
+                tabClient.attachWorker(response.workers[0].actor, function (response, workerClient) {
+                  workerClient.attachThread({}, function(aResponse) {
+                    aState.actor = workerClient.consoleActor;
+                    aState.dbgClient.attachConsole(workerClient.consoleActor, aListeners,
+                                                   _onAttachConsole.bind(null, aState));
+                  });
+                });
+              });
+            });
+          } else {
+            aState.actor = tab.consoleActor;
+            aState.dbgClient.attachConsole(tab.consoleActor, aListeners,
+                                           _onAttachConsole.bind(null, aState));
+          }
         });
       });
     } else {
       aState.dbgClient.getProcess().then(response => {
         aState.dbgClient.attachTab(response.form.actor, function () {
           let consoleActor = response.form.consoleActor;
           aState.actor = consoleActor;
           aState.dbgClient.attachConsole(consoleActor, aListeners,
new file mode 100644
--- /dev/null
+++ b/devtools/shared/webconsole/test/console-test-worker.js
@@ -0,0 +1,16 @@
+"use strict";
+
+function f() {
+  var a = 1;
+  var b = 2;
+  var c = 3;
+}
+
+self.onmessage = function (event) {
+  if (event.data == "ping") {
+    f()
+    postMessage("pong");
+  }
+};
+
+postMessage("load");
--- a/devtools/shared/webconsole/test/test_basics.html
+++ b/devtools/shared/webconsole/test/test_basics.html
@@ -13,30 +13,30 @@
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["PageError"], onStartPageError, true);
+  attachConsoleToTab(["PageError"], onStartPageError);
 }
 
 function onStartPageError(aState, aResponse)
 {
   is(aResponse.startedListeners.length, 1, "startedListeners.length");
   is(aResponse.startedListeners[0], "PageError", "startedListeners: PageError");
   ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
 
   closeDebugger(aState, function() {
     top.console_ = top.console;
     top.console = { lolz: "foo" };
-    attachConsole(["PageError", "ConsoleAPI", "foo"],
-                  onStartPageErrorAndConsoleAPI, true);
+    attachConsoleToTab(["PageError", "ConsoleAPI", "foo"],
+                  onStartPageErrorAndConsoleAPI);
   });
 }
 
 function onStartPageErrorAndConsoleAPI(aState, aResponse)
 {
   let startedListeners = aResponse.startedListeners;
   is(startedListeners.length, 2, "startedListeners.length");
   isnot(startedListeners.indexOf("PageError"), -1, "startedListeners: PageError");
@@ -51,17 +51,17 @@ function onStartPageErrorAndConsoleAPI(a
 }
 
 function onStopConsoleAPI(aState, aResponse)
 {
   is(aResponse.stoppedListeners.length, 1, "stoppedListeners.length");
   is(aResponse.stoppedListeners[0], "ConsoleAPI", "stoppedListeners: ConsoleAPI");
 
   closeDebugger(aState, function() {
-    attachConsole(["ConsoleAPI"], onStartConsoleAPI, true);
+    attachConsoleToTab(["ConsoleAPI"], onStartConsoleAPI);
   });
 }
 
 function onStartConsoleAPI(aState, aResponse)
 {
   is(aResponse.startedListeners.length, 1, "startedListeners.length");
   is(aResponse.startedListeners[0], "ConsoleAPI", "startedListeners: ConsoleAPI");
   ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
--- a/devtools/shared/webconsole/test/test_bug819670_getter_throws.html
+++ b/devtools/shared/webconsole/test/test_bug819670_getter_throws.html
@@ -12,17 +12,17 @@
 <p>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</p>
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
-  attachConsole([], onAttach, true);
+  attachConsoleToTab([], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onEvaluate = onEvaluate.bind(null, aState);
   aState.client.evaluateJS("document.__proto__", onEvaluate);
 }
 
--- a/devtools/shared/webconsole/test/test_commands_other.html
+++ b/devtools/shared/webconsole/test/test_commands_other.html
@@ -23,20 +23,20 @@ function evaluateJS(input) {
 
 function startTest() {
   info ("Content window opened, attaching console to it");
 
   let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
   ok (!gWin.document.nodePrincipal.equals(systemPrincipal),
       "The test document is not using the system principal");
 
-  attachConsole([], state => {
+  attachConsoleToTab([], state => {
     gState = state;
     runTests(tests, testEnd);
-  }, true);
+  });
 }
 
 tests = [
   Task.async(function* keys() {
     let response = yield evaluateJS("keys({foo: 'bar'})");
     checkObject(response, {
       from: gState.actor,
       result: {
--- a/devtools/shared/webconsole/test/test_commands_registration.html
+++ b/devtools/shared/webconsole/test/test_commands_registration.html
@@ -28,17 +28,17 @@ function* evaluateJSAndCheckResult(input
   let response = yield evaluateJS(input);
   checkObject(response, {result});
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["PageError"], onAttach, true);
+  attachConsoleToTab(["PageError"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   gState = aState;
 
   runTests(tests, testEnd);
 }
--- a/devtools/shared/webconsole/test/test_console_styling.html
+++ b/devtools/shared/webconsole/test/test_console_styling.html
@@ -78,17 +78,17 @@ function doConsoleCalls(aState)
     },
   ];
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleAPICall = onConsoleAPICall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleAPICall);
   doConsoleCalls(aState.actor);
 }
--- a/devtools/shared/webconsole/test/test_consoleapi.html
+++ b/devtools/shared/webconsole/test/test_consoleapi.html
@@ -151,17 +151,17 @@ function doConsoleCalls(aState)
     },
   ];
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleAPICall = onConsoleAPICall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleAPICall);
   doConsoleCalls(aState.actor);
 }
--- a/devtools/shared/webconsole/test/test_consoleapi_innerID.html
+++ b/devtools/shared/webconsole/test/test_consoleapi_innerID.html
@@ -116,17 +116,17 @@ function doConsoleCalls(aState)
     },
   ];
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleAPICall = onConsoleAPICall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleAPICall);
   doConsoleCalls(aState.actor);
 }
--- a/devtools/shared/webconsole/test/test_jsterm.html
+++ b/devtools/shared/webconsole/test/test_jsterm.html
@@ -32,17 +32,17 @@ function evaluateJS(input, options = {})
     }
   });
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["PageError"], onAttach, true);
+  attachConsoleToTab(["PageError"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   top.foobarObject = Object.create(null);
   top.foobarObject.foo = 1;
   top.foobarObject.foobar = 2;
   top.foobarObject.foobaz = 3;
@@ -59,117 +59,25 @@ function onAttach(aState, aResponse)
 
   top.largeObject2 = Object.create(null);
   for (let i = 0; i < MAX_AUTOCOMPLETIONS * 2; i++) {
     top.largeObject2['a' + i] = i;
   }
 
   gState = aState;
 
-  let tests = [doAutocomplete1, doAutocomplete2, doAutocomplete3,
-               doAutocomplete4, doAutocompleteLarge1, doAutocompleteLarge2,
-               doSimpleEval, doWindowEval, doEvalWithException,
+  let tests = [doSimpleEval, doWindowEval, doEvalWithException,
                doEvalWithHelper, doEvalString, doEvalLongString,
                doEvalWithBinding, doEvalWithBindingFrame].map(t => {
                  return Task.async(t);
                });
 
   runTests(tests, testEnd);
 }
 
-function doAutocomplete1() {
-  info("test autocomplete for 'window.foo'");
-  gState.client.autocomplete("window.foo", 10, onAutocomplete1);
-}
-
-function onAutocomplete1(aResponse) {
-  let matches = aResponse.matches;
-
-  is(aResponse.matchProp, "foo", "matchProp");
-  is(matches.length, 1, "matches.length");
-  is(matches[0], "foobarObject", "matches[0]");
-
-  nextTest();
-}
-
-function doAutocomplete2() {
-  info("test autocomplete for 'window.foobarObject.'");
-  gState.client.autocomplete("window.foobarObject.", 20, onAutocomplete2);
-}
-
-function onAutocomplete2(aResponse) {
-  let matches = aResponse.matches;
-
-  ok(!aResponse.matchProp, "matchProp");
-  is(matches.length, 7, "matches.length");
-  checkObject(matches,
-    ["foo", "foobar", "foobaz", "omg", "omgfoo", "omgstr", "strfoo"]);
-
-  nextTest();
-}
-
-function doAutocomplete3() {
-  // Check that completion suggestions are offered inside the string.
-  info("test autocomplete for 'dump(window.foobarObject.)'");
-  gState.client.autocomplete("dump(window.foobarObject.)", 25, onAutocomplete3);
-}
-
-function onAutocomplete3(aResponse) {
-  let matches = aResponse.matches;
-
-  ok(!aResponse.matchProp, "matchProp");
-  is(matches.length, 7, "matches.length");
-  checkObject(matches,
-    ["foo", "foobar", "foobaz", "omg", "omgfoo", "omgstr", "strfoo"]);
-
-  nextTest();
-}
-
-function doAutocomplete4() {
-  // Check that completion requests can have no suggestions.
-  info("test autocomplete for 'dump(window.foobarObject.)'");
-  gState.client.autocomplete("dump(window.foobarObject.)", 26, onAutocomplete4);
-}
-
-function onAutocomplete4(aResponse) {
-  ok(!aResponse.matchProp, "matchProp");
-  is(aResponse.matches.length, 0, "matches.length");
-
-  nextTest();
-}
-
-function doAutocompleteLarge1() {
-  // Check that completion requests with too large objects will
-  // have no suggestions.
-  info("test autocomplete for 'window.largeObject1.'");
-  gState.client.autocomplete("window.largeObject1.", 20, onAutocompleteLarge1);
-}
-
-function onAutocompleteLarge1(aResponse) {
-  ok(!aResponse.matchProp, "matchProp");
-  info (aResponse.matches.join("|"));
-  is(aResponse.matches.length, 0, "Bailed out with too many properties");
-
-  nextTest();
-}
-
-function doAutocompleteLarge2() {
-  // Check that completion requests with pretty large objects will
-  // have MAX_AUTOCOMPLETIONS suggestions
-  info("test autocomplete for 'window.largeObject2.'");
-  gState.client.autocomplete("window.largeObject2.", 20, onAutocompleteLarge2);
-}
-
-function onAutocompleteLarge2(aResponse) {
-  ok(!aResponse.matchProp, "matchProp");
-  is(aResponse.matches.length, MAX_AUTOCOMPLETIONS, "matches.length is MAX_AUTOCOMPLETIONS");
-
-  nextTest();
-}
-
 function* doSimpleEval() {
   info("test eval '2+2'");
   let response = yield evaluateJS("2+2");
   checkObject(response, {
     from: gState.actor,
     input: "2+2",
     result: 4,
   });
new file mode 100644
--- /dev/null
+++ b/devtools/shared/webconsole/test/test_jsterm_autocomplete.html
@@ -0,0 +1,183 @@
+<!DOCTYPE HTML>
+<html lang="en">
+<head>
+  <meta charset="utf8">
+  <title>Test for JavaScript terminal functionality</title>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript;version=1.8" src="common.js"></script>
+  <!-- Any copyright is dedicated to the Public Domain.
+     - http://creativecommons.org/publicdomain/zero/1.0/ -->
+</head>
+<body>
+<p>Test for JavaScript terminal autocomplete functionality</p>
+
+<script class="testbody" type="text/javascript;version=1.8">
+SimpleTest.waitForExplicitFinish();
+
+let gState;
+let {MAX_AUTOCOMPLETE_ATTEMPTS,MAX_AUTOCOMPLETIONS} = require("devtools/shared/webconsole/js-property-provider");
+
+function evaluateJS(input, options = {}) {
+  return new Promise((resolve, reject) => {
+    gState.client.evaluateJSAsync(input, resolve, options);
+  });
+}
+
+function autocompletePromise(str, cursor, frameActor) {
+  return new Promise(resolve => {
+    gState.client.autocomplete(str, cursor, resolve, frameActor);
+  });
+}
+
+// This test runs all of its assertions twice - once with
+// the tab as a target and once with a worker
+let runningInTab = true;
+function startTest({worker}) {
+  if (worker) {
+    attachConsoleToWorker(["PageError"], onAttach);
+  } else {
+    attachConsoleToTab(["PageError"], onAttach);
+  }
+};
+
+let onAttach = Task.async(function*(aState, response) {
+  gState = aState;
+
+  let longStrLength = DebuggerServer.LONG_STRING_LENGTH;
+
+  // Set up the global variables needed to test autocompletion
+  // in the target.
+  let script = `
+    // This is for workers so autocomplete acts the same
+    if (!this.window) {
+      window = this;
+    }
+
+    window.foobarObject = Object.create(null);
+    window.foobarObject.foo = 1;
+    window.foobarObject.foobar = 2;
+    window.foobarObject.foobaz = 3;
+    window.foobarObject.omg = 4;
+    window.foobarObject.omgfoo = 5;
+    window.foobarObject.strfoo = "foobarz";
+    window.foobarObject.omgstr = "foobarz" +
+      (new Array(${longStrLength})).join("abb");
+    window.largeObject1 = Object.create(null);
+    for (let i = 0; i < ${MAX_AUTOCOMPLETE_ATTEMPTS + 1}; i++) {
+      window.largeObject1['a' + i] = i;
+    }
+
+    window.largeObject2 = Object.create(null);
+    for (let i = 0; i < ${MAX_AUTOCOMPLETIONS * 2}; i++) {
+      window.largeObject2['a' + i] = i;
+    }
+  `;
+
+  yield evaluateJS(script);
+
+  let tests = [doAutocomplete1, doAutocomplete2, doAutocomplete3,
+               doAutocomplete4, doAutocompleteLarge1,
+               doAutocompleteLarge2].map(t => {
+                 return Task.async(t);
+               });
+
+  runTests(tests, testEnd);
+});
+
+function* doAutocomplete1() {
+  info("test autocomplete for 'window.foo'");
+  let response = yield autocompletePromise("window.foo", 10);
+  let matches = response.matches;
+
+  is(response.matchProp, "foo", "matchProp");
+  is(matches.length, 1, "matches.length");
+  is(matches[0], "foobarObject", "matches[0]");
+
+  nextTest();
+}
+
+function* doAutocomplete2() {
+  info("test autocomplete for 'window.foobarObject.'");
+  let response = yield autocompletePromise("window.foobarObject.", 20);
+  let matches = response.matches;
+
+  ok(!response.matchProp, "matchProp");
+  is(matches.length, 7, "matches.length");
+  checkObject(matches,
+    ["foo", "foobar", "foobaz", "omg", "omgfoo", "omgstr", "strfoo"]);
+
+  nextTest();
+}
+
+function* doAutocomplete3() {
+  // Check that completion suggestions are offered inside the string.
+  info("test autocomplete for 'dump(window.foobarObject.)'");
+  let response = yield autocompletePromise("dump(window.foobarObject.)", 25);
+  let matches = response.matches;
+
+  ok(!response.matchProp, "matchProp");
+  is(matches.length, 7, "matches.length");
+  checkObject(matches,
+    ["foo", "foobar", "foobaz", "omg", "omgfoo", "omgstr", "strfoo"]);
+
+  nextTest();
+}
+
+function* doAutocomplete4() {
+  // Check that completion requests can have no suggestions.
+  info("test autocomplete for 'dump(window.foobarObject.)'");
+  let response = yield autocompletePromise("dump(window.foobarObject.)", 26);
+  ok(!response.matchProp, "matchProp");
+  is(response.matches.length, 0, "matches.length");
+
+  nextTest();
+}
+
+function* doAutocompleteLarge1() {
+  // Check that completion requests with too large objects will
+  // have no suggestions.
+  info("test autocomplete for 'window.largeObject1.'");
+  let response = yield autocompletePromise("window.largeObject1.", 20);
+  ok(!response.matchProp, "matchProp");
+  info (response.matches.join("|"));
+  is(response.matches.length, 0, "Bailed out with too many properties");
+
+  nextTest();
+}
+
+function* doAutocompleteLarge2() {
+  // Check that completion requests with pretty large objects will
+  // have MAX_AUTOCOMPLETIONS suggestions
+  info("test autocomplete for 'window.largeObject2.'");
+  let response = yield autocompletePromise("window.largeObject2.", 20);
+  ok(!response.matchProp, "matchProp");
+  is(response.matches.length, MAX_AUTOCOMPLETIONS, "matches.length is MAX_AUTOCOMPLETIONS");
+
+  nextTest();
+}
+
+function testEnd()
+{
+  // If this is the first run, reload the page and do it again
+  // in a worker.  Otherwise, end the test.
+  closeDebugger(gState, function() {
+    gState = null;
+    if (runningInTab) {
+      runningInTab = false;
+      startTest({
+        worker: true
+      });
+    } else {
+      SimpleTest.finish();
+    }
+  });
+}
+
+addEventListener("load", () => {
+  startTest({
+    worker: false
+  });
+});
+</script>
+</body>
+</html>
--- a/devtools/shared/webconsole/test/test_jsterm_cd_iframe.html
+++ b/devtools/shared/webconsole/test/test_jsterm_cd_iframe.html
@@ -17,17 +17,17 @@
 SimpleTest.waitForExplicitFinish();
 
 let gState;
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole([], onAttach, true);
+  attachConsoleToTab([], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   top.foobarObject = Object.create(null);
   top.foobarObject.bug609872 = "parent";
 
   window.foobarObject = Object.create(null);
--- a/devtools/shared/webconsole/test/test_jsterm_last_result.html
+++ b/devtools/shared/webconsole/test/test_jsterm_last_result.html
@@ -26,21 +26,21 @@ function evaluateJS(input, callback) {
       resolve(response);
     });
   });
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
-  attachConsole([], state => {
+  attachConsoleToTab([], state => {
     gState = state;
     let tests = [checkUndefinedResult,checkAdditionResult,checkObjectResult];
     runTests(tests, testEnd);
-  }, true);
+  });
 }
 
 let checkUndefinedResult = Task.async(function*() {
   info ("$_ returns undefined if nothing has evaluated yet");
   let response = yield evaluateJS("$_");
   basicResultCheck(response, "$_", undefined);
   nextTest();
 });
--- a/devtools/shared/webconsole/test/test_jsterm_queryselector.html
+++ b/devtools/shared/webconsole/test/test_jsterm_queryselector.html
@@ -22,27 +22,27 @@ function evaluateJS(input) {
 
 function startTest() {
   info ("Content window opened, attaching console to it");
 
   let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
   ok (!gWin.document.nodePrincipal.equals(systemPrincipal),
       "The test document is not using the system principal");
 
-  attachConsole([], state => {
+  attachConsoleToTab([], state => {
     gState = state;
     let tests = [
       setupWindow,
       checkQuerySelector,
       checkQuerySelectorAll,
       checkQuerySelectorAllNotExist,
       checkQuerySelectorAllException
     ];
     runTests(tests, testEnd);
-  }, true);
+  });
 }
 
 let setupWindow = Task.async(function*() {
   info ("Shimming window functions for the content privileged tab");
   yield evaluateJS("document.querySelector = function() { throw 'should not call qS'; }");
   yield evaluateJS("document.querySelectorAll = function() { throw 'should not call qSA'; }");
   nextTest();
 });
--- a/devtools/shared/webconsole/test/test_network_get.html
+++ b/devtools/shared/webconsole/test/test_network_get.html
@@ -14,17 +14,17 @@
 <iframe src="http://example.com/chrome/devtools/shared/webconsole/test/network_requests_iframe.html"></iframe>
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
-  attachConsole(["NetworkActivity"], onAttach, true);
+  attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   info("test network GET request");
 
   onNetworkEvent = onNetworkEvent.bind(null, aState);
   aState.dbgClient.addListener("networkEvent", onNetworkEvent);
--- a/devtools/shared/webconsole/test/test_network_longstring.html
+++ b/devtools/shared/webconsole/test/test_network_longstring.html
@@ -15,17 +15,17 @@
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["NetworkActivity"], onAttach, true);
+  attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   info("enable network request and response body logging");
 
   window.ORIGINAL_LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH;
   window.ORIGINAL_LONG_STRING_INITIAL_LENGTH =
--- a/devtools/shared/webconsole/test/test_network_post.html
+++ b/devtools/shared/webconsole/test/test_network_post.html
@@ -15,17 +15,17 @@
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["NetworkActivity"], onAttach, true);
+  attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   info("enable network request and response body logging");
 
   onSetPreferences = onSetPreferences.bind(null, aState);
   aState.client.setPreferences({
--- a/devtools/shared/webconsole/test/test_network_security-hpkp.html
+++ b/devtools/shared/webconsole/test/test_network_security-hpkp.html
@@ -56,17 +56,17 @@ function startTest()
     for (let {url} of TEST_CASES) {
       let uri = gIOService.newURI(url, null, null);
       gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
     }
   });
 
   info("Test detection of Public Key Pinning.");
   removeEventListener("load", startTest);
-  attachConsole(["NetworkActivity"], onAttach, true);
+  attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onNetworkEventUpdate = onNetworkEventUpdate.bind(null, aState);
   aState.dbgClient.addListener("networkEventUpdate", onNetworkEventUpdate);
 
   runNextCase(aState);
--- a/devtools/shared/webconsole/test/test_network_security-hsts.html
+++ b/devtools/shared/webconsole/test/test_network_security-hsts.html
@@ -48,17 +48,17 @@ function startTest()
                        .getService(Ci.nsIIOService);
 
     let uri = gIOService.newURI(TEST_CASES[0].url, null, null);
     gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);
   });
 
   info("Test detection of HTTP Strict Transport Security.");
   removeEventListener("load", startTest);
-  attachConsole(["NetworkActivity"], onAttach, true);
+  attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onNetworkEventUpdate = onNetworkEventUpdate.bind(null, aState);
   aState.dbgClient.addListener("networkEventUpdate", onNetworkEventUpdate);
 
   runNextCase(aState);
--- a/devtools/shared/webconsole/test/test_object_actor.html
+++ b/devtools/shared/webconsole/test/test_object_actor.html
@@ -15,17 +15,17 @@
 SimpleTest.waitForExplicitFinish();
 
 let expectedProps = [];
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleCall = onConsoleCall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleCall);
 
   let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 3)).join("\u0629");
--- a/devtools/shared/webconsole/test/test_object_actor_native_getters.html
+++ b/devtools/shared/webconsole/test/test_object_actor_native_getters.html
@@ -16,17 +16,17 @@ SimpleTest.waitForExplicitFinish();
 
 let expectedProps = [];
 let expectedSafeGetters = [];
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleCall = onConsoleCall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleCall);
 
   top.console.log("hello", document);
--- a/devtools/shared/webconsole/test/test_object_actor_native_getters_lenient_this.html
+++ b/devtools/shared/webconsole/test/test_object_actor_native_getters_lenient_this.html
@@ -14,17 +14,17 @@
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
 
-  attachConsole(["ConsoleAPI"], onAttach, true);
+  attachConsoleToTab(["ConsoleAPI"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   onConsoleCall = onConsoleCall.bind(null, aState);
   aState.dbgClient.addListener("consoleAPICall", onConsoleCall);
 
   let docAsProto = Object.create(document);
--- a/devtools/shared/webconsole/test/test_reflow.html
+++ b/devtools/shared/webconsole/test/test_reflow.html
@@ -21,17 +21,17 @@ function generateReflow()
   top.document.documentElement.style.display = "none";
   top.document.documentElement.getBoundingClientRect();
   top.document.documentElement.style.display = "block";
 }
 
 function startTest()
 {
   removeEventListener("load", startTest);
-  attachConsole(["ReflowActivity"], onAttach, true);
+  attachConsoleToTab(["ReflowActivity"], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   client = aState.dbgClient;
 
   onReflowActivity = onReflowActivity.bind(null, aState);
   client.addListener("reflowActivity", onReflowActivity);
--- a/devtools/shared/webconsole/test/test_throw.html
+++ b/devtools/shared/webconsole/test/test_throw.html
@@ -12,17 +12,17 @@
 <p>Web Console throw tests</p>
 
 <script class="testbody" type="text/javascript;version=1.8">
 SimpleTest.waitForExplicitFinish();
 
 function startTest()
 {
   removeEventListener("load", startTest);
-  attachConsole([], onAttach, true);
+  attachConsoleToTab([], onAttach);
 }
 
 function onAttach(aState, aResponse)
 {
   let tests = [];
 
   let falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
   falsyValues.forEach(function(value) {