Bug 939496 - Emit tabs open event for the first tab in a new. r=zer0
authorJacobo Aragunde Pérez <jaragunde@igalia.com>
Fri, 15 Jan 2016 08:38:10 -0800
changeset 280144 f032711da68fb3812e7956a8d5fa31caa794e5a3
parent 280143 f427e163a30417600d5f9547ac8abc2b7847cc69
child 280145 2b2ebbe0754d7c773347ca012a4be47d6a1e2936
push id17044
push userdtownsend@mozilla.com
push dateFri, 15 Jan 2016 16:38:22 +0000
treeherderfx-team@f032711da68f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszer0
bugs939496
milestone46.0a1
Bug 939496 - Emit tabs open event for the first tab in a new. r=zer0
addon-sdk/source/lib/sdk/tabs/tabs-firefox.js
addon-sdk/source/test/tabs/test-firefox-tabs.js
--- a/addon-sdk/source/lib/sdk/tabs/tabs-firefox.js
+++ b/addon-sdk/source/lib/sdk/tabs/tabs-firefox.js
@@ -106,16 +106,17 @@ const allTabs = new Tabs();
 module.exports = Object.create(allTabs);
 pipe(tabEvents, module.exports);
 
 function addWindowTab(window, tabElement) {
   let tab = new Tab(tabElement);
   if (window)
     addListItem(window.tabs, tab);
   addListItem(allTabs, tab);
+  emit(allTabs, "open", tab);
 }
 
 // Find tabs in already open windows
 for (let tabElement of getTabs())
   addWindowTab(null, tabElement);
 
 // Detect tabs in new windows
 windowObserver.on('open', domWindow => {
--- a/addon-sdk/source/test/tabs/test-firefox-tabs.js
+++ b/addon-sdk/source/test/tabs/test-firefox-tabs.js
@@ -1236,16 +1236,31 @@ exports["test ready event after window.o
 
   tabs.activeTab.attach({
     contentScript: "window.open('about:blank');" +
                    "window.open('about:blank', '', " +
                    "'width=800,height=600,resizable=no,status=no,location=no');"
   });
 }
 
+// related to bug #939496
+exports["test tab open event for new window"] = function(assert, done) {
+  // ensure popups open in a new window and disable popup blocker
+  setPref(OPEN_IN_NEW_WINDOW_PREF, 2);
+  setPref(DISABLE_POPUP_PREF, false);
+
+  tabs.once('open', function onOpen(window) {
+    assert.pass("tab open has occured");
+    window.close(done);
+  });
+
+  // open window to trigger observers
+  browserWindows.open("about:logo");
+};
+
 after(exports, function*(name, assert) {
   resetPopupPrefs();
   yield cleanUI();
 });
 
 const resetPopupPrefs = () => {
   resetPref(OPEN_IN_NEW_WINDOW_PREF);
   resetPref(DISABLE_POPUP_PREF);