Bug 1234308 - Fix tabs.onCreated callback to receive bare tabs object (bug 1234308); r=kmag
authorMatthew Wein <mwein@mozilla.com>
Wed, 27 Jan 2016 16:33:32 -0800
changeset 282469 1b4278d9c84c5b9c59869bb4bc21db5e08be448d
parent 282468 af13bfd0725a6df6302134690afbaa618161f187
child 282470 2f865781bb37bbf788d4b3dbdf8d0c07870d8f00
push id29965
push usercbook@mozilla.com
push dateMon, 01 Feb 2016 14:39:59 +0000
treeherdermozilla-central@3edf1b852388 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1234308
milestone47.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 1234308 - Fix tabs.onCreated callback to receive bare tabs object (bug 1234308); r=kmag
browser/components/extensions/ext-tabs.js
browser/components/extensions/test/browser/browser_ext_tabs_create.js
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -115,22 +115,22 @@ extensions.registerSchemaAPI("tabs", nul
         let tabId = TabManager.getId(tab);
         let windowId = WindowManager.getId(tab.ownerDocument.defaultView);
         fire({tabId, windowId});
       }).api(),
 
       onCreated: new EventManager(context, "tabs.onCreated", fire => {
         let listener = event => {
           let tab = event.originalTarget;
-          fire({tab: TabManager.convert(extension, tab)});
+          fire(TabManager.convert(extension, tab));
         };
 
         let windowListener = window => {
           for (let tab of window.gBrowser.tabs) {
-            fire({tab: TabManager.convert(extension, tab)});
+            fire(TabManager.convert(extension, tab));
           }
         };
 
         WindowListManager.addOpenListener(windowListener);
         AllWindowEvents.addListener("TabOpen", listener);
         return () => {
           WindowListManager.removeOpenListener(windowListener);
           AllWindowEvents.removeListener("TabOpen", listener);
--- a/browser/components/extensions/test/browser/browser_ext_tabs_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_create.js
@@ -118,17 +118,28 @@ add_task(function* () {
                 if (changedTabId === tabId && changed.url) {
                   browser.tabs.onUpdated.removeListener(onUpdated);
                   resolve(changed.url);
                 }
               };
               browser.tabs.onUpdated.addListener(onUpdated);
             });
 
-            promiseTabs.create(test.create).then(tab => {
+            let createdPromise = new Promise(resolve => {
+              let onCreated = tab => {
+                browser.test.assertTrue("id" in tab, `Expected tabs.onCreated callback to receive tab object`);
+                resolve();
+              };
+              browser.tabs.onCreated.addListener(onCreated);
+            });
+
+            Promise.all([
+              promiseTabs.create(test.create),
+              createdPromise,
+            ]).then(([tab]) => {
               tabId = tab.id;
 
               for (let key of Object.keys(expected)) {
                 if (key === "url") {
                   // FIXME: This doesn't get updated until later in the load cycle.
                   continue;
                 }