Bug 1314057 - Move old debugger's multiple-windows, tab and target actors tests. r=loganfsmyth
☠☠ backed out by f5681e1f56e6 ☠ ☠
authorDavid Walsh <dwalsh@mozilla.com>
Mon, 08 Oct 2018 13:21:41 -0500
changeset 498826 f464268350266bad55c84d23f3b352b752679cad
parent 498825 90480b4b4c43db2437ec4ad7185cd6fafbf821e7
child 498827 2a7a0b6b2bbf60b5be511cffec9a56e8650d18d5
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1314057
milestone64.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 1314057 - Move old debugger's multiple-windows, tab and target actors tests. r=loganfsmyth
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser2.ini
devtools/client/debugger/test/mochitest/browser_dbg_multiple-windows.js
devtools/client/debugger/test/mochitest/browser_dbg_navigation.js
devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-01.js
devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-02.js
devtools/client/shared/test/browser.ini
devtools/client/shared/test/browser_dbg_multiple-windows.js
devtools/client/shared/test/browser_dbg_navigation.js
devtools/client/shared/test/browser_dbg_target-scoped-actor-01.js
devtools/client/shared/test/browser_dbg_target-scoped-actor-02.js
devtools/client/shared/test/doc_script-switching-01.html
devtools/client/shared/test/doc_script-switching-02.html
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -190,11 +190,8 @@ skip-if = e10s && debug
 skip-if = e10s && debug
 [browser_dbg_jump-to-function-definition.js]
 skip-if = e10s && debug
 [browser_dbg_iframes.js]
 skip-if = e10s # TODO
 [browser_dbg_interrupts.js]
 skip-if = e10s && debug
 [browser_dbg_listworkers.js]
-[browser_dbg_multiple-windows.js]
-[browser_dbg_navigation.js]
-skip-if = e10s && debug
--- a/devtools/client/debugger/test/mochitest/browser2.ini
+++ b/devtools/client/debugger/test/mochitest/browser2.ini
@@ -151,18 +151,16 @@ uses-unsafe-cpows = true
 [browser_dbg_sources-iframe-reload.js]
 uses-unsafe-cpows = true
 skip-if = (os == "linux" && debug && bits == 64) #Bug 1455225, disable on Linux x64 debug for frequent failures
 [browser_dbg_sources-bookmarklet.js]
 uses-unsafe-cpows = true
 skip-if = e10s && debug
 [browser_dbg_split-console-paused-reload.js]
 skip-if = true # Bug 1288348 - previously e10s && debug
-[browser_dbg_target-scoped-actor-01.js]
-[browser_dbg_target-scoped-actor-02.js]
 [browser_dbg_terminate-on-tab-close.js]
 uses-unsafe-cpows = true
 skip-if = e10s && debug
 [browser_dbg_worker-console-01.js]
 skip-if = true # bug 1368569
 [browser_dbg_worker-console-02.js]
 skip-if = e10s && debug
 [browser_dbg_worker-console-03.js]
--- a/devtools/client/shared/test/browser.ini
+++ b/devtools/client/shared/test/browser.ini
@@ -20,16 +20,18 @@ support-files =
   doc_html_tooltip_doorhanger-01.xul
   doc_html_tooltip_doorhanger-02.xul
   doc_html_tooltip_hover.xul
   doc_html_tooltip_rtl.xul
   doc_inplace-editor_autocomplete_offset.xul
   doc_layoutHelpers-getBoxQuads.html
   doc_layoutHelpers.html
   doc_options-view.xul
+  doc_script-switching-01.html
+  doc_script-switching-02.html
   doc_spectrum.html
   doc_tableWidget_basic.html
   doc_tableWidget_keyboard_interaction.xul
   doc_tableWidget_mouse_interaction.xul
   doc_templater_basic.html
   dummy.html
   frame-script-utils.js
   head.js
@@ -214,8 +216,13 @@ skip-if = verify
 [browser_dbg_listaddons.js]
 skip-if = e10s && debug
 tags = addons
 [browser_dbg_listtabs-01.js]
 [browser_dbg_listtabs-02.js]
 skip-if = true # Never worked for remote frames, needs a mock DebuggerServerConnection
 [browser_dbg_listtabs-03.js]
 skip-if = e10s && debug
+[browser_dbg_multiple-windows.js]
+[browser_dbg_navigation.js]
+skip-if = e10s && debug
+[browser_dbg_target-scoped-actor-01.js]
+[browser_dbg_target-scoped-actor-02.js]
\ No newline at end of file
rename from devtools/client/debugger/test/mochitest/browser_dbg_multiple-windows.js
rename to devtools/client/shared/test/browser_dbg_multiple-windows.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_multiple-windows.js
+++ b/devtools/client/shared/test/browser_dbg_multiple-windows.js
@@ -1,18 +1,23 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Make sure that the debugger attaches to the right tab when multiple windows
  * are open.
  */
 
+var { DebuggerServer } = require("devtools/server/main");
+var { DebuggerClient } = require("devtools/shared/client/debugger-client");
+
 const TAB1_URL = EXAMPLE_URL + "doc_script-switching-01.html";
 const TAB2_URL = EXAMPLE_URL + "doc_script-switching-02.html";
 
 add_task(async function() {
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
   const transport = DebuggerServer.connectPipe();
@@ -82,21 +87,29 @@ async function testFocusFirst(client) {
 async function testRemoveTab(client, win, tab) {
   win.close();
 
   // give it time to close
   await new Promise(resolve => executeSoon(resolve));
   await continue_remove_tab(client, tab);
 }
 
-async function continue_remove_tab(client, tab)
-{
+async function continue_remove_tab(client, tab) {
   removeTab(tab);
 
   const response = await client.listTabs();
   // Verify that tabs are no longer included in listTabs.
   const foundTab1 = response.tabs.some(grip => grip.url == TAB1_URL);
   const foundTab2 = response.tabs.some(grip => grip.url == TAB2_URL);
   ok(!foundTab1, "Tab1 should be gone.");
   ok(!foundTab2, "Tab2 should be gone.");
 
   is(response.selected, 0, "The original tab is selected.");
 }
+
+function addWindow(url) {
+  info("Adding window: " + url);
+  return promise.resolve(getChromeWindow(window.open(url)));
+}
+
+function getChromeWindow(win) {
+  return win.docShell.rootTreeItem.domWindow;
+}
rename from devtools/client/debugger/test/mochitest/browser_dbg_navigation.js
rename to devtools/client/shared/test/browser_dbg_navigation.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_navigation.js
+++ b/devtools/client/shared/test/browser_dbg_navigation.js
@@ -1,73 +1,99 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Check tab attach/navigation.
  */
 
+var { DebuggerServer } = require("devtools/server/main");
+var { DebuggerClient } = require("devtools/shared/client/debugger-client");
+
 const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
-const TAB2_URL = EXAMPLE_URL + "doc_empty-tab-02.html";
+const TAB2_FILE = "doc_empty-tab-02.html";
+const TAB2_URL = EXAMPLE_URL + TAB2_FILE;
 
 var gClient;
 
 function test() {
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
-  let transport = DebuggerServer.connectPipe();
+  const transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
   gClient.connect().then(([aType, aTraits]) => {
     is(aType, "browser",
       "Root actor should identify itself as a browser.");
 
     addTab(TAB1_URL)
       .then(() => attachTargetActorForUrl(gClient, TAB1_URL))
       .then(testNavigate)
       .then(testDetach)
       .then(finish)
-      .catch(aError => {
-        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      .catch(error => {
+        ok(false, "Got an error: " + error.message + "\n" + error.stack);
       });
   });
 }
 
 function testNavigate([aGrip, aResponse]) {
-  let outstanding = [promise.defer(), promise.defer()];
+  const outstanding = [promise.defer(), promise.defer()];
 
-  gClient.addListener("tabNavigated", function onTabNavigated(aEvent, aPacket) {
-    is(aPacket.url, TAB2_URL,
+  gClient.addListener("tabNavigated", function onTabNavigated(event, packet) {
+    is(packet.url.split("/").pop(), TAB2_FILE,
       "Got a tab navigation notification.");
 
-    if (aPacket.state == "start") {
+    info(JSON.stringify(packet));
+    info(JSON.stringify(event));
+
+    if (packet.state == "start") {
       ok(true, "Tab started to navigate.");
       outstanding[0].resolve();
     } else {
       ok(true, "Tab finished navigating.");
       gClient.removeListener("tabNavigated", onTabNavigated);
       outstanding[1].resolve();
     }
   });
 
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TAB2_URL);
   return promise.all(outstanding.map(e => e.promise))
                 .then(() => aGrip.actor);
 }
 
-function testDetach(aActor) {
-  let deferred = promise.defer();
+function testDetach(actor) {
+  const deferred = promise.defer();
 
-  gClient.addOneTimeListener("tabDetached", (aType, aPacket) => {
+  gClient.addOneTimeListener("tabDetached", (type, packet) => {
     ok(true, "Got a tab detach notification.");
-    is(aPacket.from, aActor, "tab detach message comes from the expected actor");
+    is(packet.from, actor, "tab detach message comes from the expected actor");
     deferred.resolve(gClient.close());
   });
 
   removeTab(gBrowser.selectedTab);
   return deferred.promise;
 }
 
-registerCleanupFunction(function () {
+registerCleanupFunction(function() {
   gClient = null;
 });
+
+async function attachTargetActorForUrl(client, url) {
+  const grip = await getTargetActorForUrl(client, url);
+  const [ response ] = await client.attachTarget(grip.actor);
+  return [grip, response];
+}
+
+function getTargetActorForUrl(client, url) {
+  const deferred = promise.defer();
+
+  client.listTabs().then(response => {
+    const targetActor = response.tabs.filter(grip => grip.url == url).pop();
+    deferred.resolve(targetActor);
+  });
+
+  return deferred.promise;
+}
rename from devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-01.js
rename to devtools/client/shared/test/browser_dbg_target-scoped-actor-01.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-01.js
+++ b/devtools/client/shared/test/browser_dbg_target-scoped-actor-01.js
@@ -1,18 +1,23 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Check target-scoped actor lifetimes.
  */
 
-const ACTORS_URL = CHROME_URL + "testactors.js";
+var { DebuggerServer } = require("devtools/server/main");
+var { DebuggerClient } = require("devtools/shared/client/debugger-client");
+
+const ACTORS_URL = EXAMPLE_URL + "testactors.js";
 const TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
 
 add_task(async function test() {
   await addTab(TAB_URL);
 
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
@@ -37,8 +42,25 @@ async function testTargetScopedActor(cli
   ok(grip.testOneActor,
     "Found the test target-scoped actor.");
   ok(grip.testOneActor.includes("testOne"),
     "testOneActor's actorPrefix should be used.");
 
   const response = await client.request({ to: grip.testOneActor, type: "ping" });
   is(response.pong, "pong", "Actor should respond to requests.");
 }
+
+async function attachTargetActorForUrl(client, url) {
+  const grip = await getTargetActorForUrl(client, url);
+  const [ response ] = await client.attachTarget(grip.actor);
+  return [grip, response];
+}
+
+function getTargetActorForUrl(client, url) {
+  const deferred = promise.defer();
+
+  client.listTabs().then(response => {
+    const targetActor = response.tabs.filter(grip => grip.url == url).pop();
+    deferred.resolve(targetActor);
+  });
+
+  return deferred.promise;
+}
rename from devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-02.js
rename to devtools/client/shared/test/browser_dbg_target-scoped-actor-02.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_target-scoped-actor-02.js
+++ b/devtools/client/shared/test/browser_dbg_target-scoped-actor-02.js
@@ -1,18 +1,23 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Check target-scoped actor lifetimes.
  */
 
-const ACTORS_URL = CHROME_URL + "testactors.js";
+var { DebuggerServer } = require("devtools/server/main");
+var { DebuggerClient } = require("devtools/shared/client/debugger-client");
+
+const ACTORS_URL = EXAMPLE_URL + "testactors.js";
 const TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
 
 add_task(async function() {
   await addTab(TAB_URL);
 
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
@@ -48,8 +53,25 @@ async function testTargetScopedActor(cli
 async function closeTab(client, grip) {
   await removeTab(gBrowser.selectedTab);
   await Assert.rejects(
     client.request({ to: grip.testOneActor, type: "ping" }),
     err => err.message === `'ping' active request packet to '${grip.testOneActor}' ` +
                            `can't be sent as the connection just closed.`,
     "testOneActor went away.");
 }
+
+async function attachTargetActorForUrl(client, url) {
+  const grip = await getTargetActorForUrl(client, url);
+  const [ response ] = await client.attachTarget(grip.actor);
+  return [grip, response];
+}
+
+function getTargetActorForUrl(client, url) {
+  const deferred = promise.defer();
+
+  client.listTabs().then(response => {
+    const targetActor = response.tabs.filter(grip => grip.url == url).pop();
+    deferred.resolve(targetActor);
+  });
+
+  return deferred.promise;
+}
copy from devtools/client/debugger/test/mochitest/doc_script-switching-01.html
copy to devtools/client/shared/test/doc_script-switching-01.html
copy from devtools/client/debugger/test/mochitest/doc_script-switching-02.html
copy to devtools/client/shared/test/doc_script-switching-02.html