Bug 997315: Verify that multiple calls to listTabs doesn't prematurely disconnect actors. r=panos
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 18 Apr 2014 08:20:49 -0700
changeset 197779 db31631ce10ce8afb43e54c7f39bc3a6be92c7fc
parent 197778 669dff46362f638112c7c910a3c0804c5b9af706
child 197780 f7320bbfb006e75eacb5d92d59673bbd1855dc60
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspanos
bugs997315
milestone31.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 997315: Verify that multiple calls to listTabs doesn't prematurely disconnect actors. r=panos
browser/devtools/debugger/test/browser.ini
browser/devtools/debugger/test/browser_dbg_listtabs-03.js
--- a/browser/devtools/debugger/test/browser.ini
+++ b/browser/devtools/debugger/test/browser.ini
@@ -144,16 +144,17 @@ support-files =
 [browser_dbg_global-method-override.js]
 [browser_dbg_globalactor.js]
 [browser_dbg_host-layout.js]
 [browser_dbg_iframes.js]
 [browser_dbg_instruments-pane-collapse.js]
 [browser_dbg_listaddons.js]
 [browser_dbg_listtabs-01.js]
 [browser_dbg_listtabs-02.js]
+[browser_dbg_listtabs-03.js]
 [browser_dbg_location-changes-01-simple.js]
 [browser_dbg_location-changes-02-blank.js]
 [browser_dbg_location-changes-03-new.js]
 [browser_dbg_location-changes-04-breakpoint.js]
 [browser_dbg_multiple-windows.js]
 [browser_dbg_navigation.js]
 [browser_dbg_no-page-sources.js]
 [browser_dbg_on-pause-highlight.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_listtabs-03.js
@@ -0,0 +1,80 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Make sure the listTabs request works as specified.
+ */
+
+const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
+
+let gTab1, gTab1Actor, gTab2, gTab2Actor, gClient;
+
+function listTabs() {
+  let deferred = promise.defer();
+
+  gClient.listTabs(aResponse => {
+    deferred.resolve(aResponse.tabs);
+  });
+
+  return deferred.promise;
+}
+
+function request(params) {
+  let deferred = promise.defer();
+  gClient.request(params, deferred.resolve);
+  return deferred.promise;
+}
+
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
+
+  let transport = DebuggerServer.connectPipe();
+  gClient = new DebuggerClient(transport);
+  gClient.connect(Task.async(function*(aType, aTraits) {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+    let tab = yield addTab(TAB1_URL);
+
+    let tabs = yield listTabs();
+    is(tabs.length, 2, "Should be two tabs");
+    let tabGrip = tabs.filter(a => a.url ==TAB1_URL).pop();
+    ok(tabGrip, "Should have an actor for the tab");
+
+    let response = yield request({ to: tabGrip.actor, type: "attach" });
+    is(response.type, "tabAttached", "Should have attached");
+
+    tabs = yield listTabs();
+
+    response = yield request({ to: tabGrip.actor, type: "detach" });
+    is(response.type, "detached", "Should have detached");
+
+    let newGrip = tabs.filter(a => a.url ==TAB1_URL).pop();
+    is(newGrip.actor, tabGrip.actor, "Should have the same actor for the same tab");
+
+    response = yield request({ to: tabGrip.actor, type: "attach" });
+    is(response.type, "tabAttached", "Should have attached");
+    response = yield request({ to: tabGrip.actor, type: "detach" });
+    is(response.type, "detached", "Should have detached");
+
+    yield removeTab(tab);
+    yield closeConnection();
+    finish();
+  }));
+}
+
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
+}
+
+registerCleanupFunction(function() {
+  gTab1 = null;
+  gTab1Actor = null;
+  gTab2 = null;
+  gTab2Actor = null;
+  gClient = null;
+});