Identify Tab That Made Request In Firefox Addon SDK
Solution 1:
You have to keep using the internal packages. From what I can tell, getTabForWindow()
function in api-utils/lib/tabs/tab.js
package does exactly what you want. Untested code:
var tabsLib = require("sdk/tabs/tab.js");
return tabsLib.getTabForWindow(domWin.top);
Solution 2:
The API has changed since this was originally asked/answered... It should now (as of 1.15) be:
return require("sdk/tabs/utils").getTabForWindow(domWin.top);
Solution 3:
As of Addon SDK version 1.13 change:
var tabsLib = require("tabs/tab.js");
to
var tabsLib = require("sdk/tabs/helpers.js");
Solution 4:
If anyone still cares about this:
Although the Addon SDK is being deprecated in support of the newer WebExtensions API, I want to point out that
var a_tab = require("sdk/tabs/utils").getTabForContentWindow(window)
returns a different 'tab' object than the one you would typically get by using
worker.tab in a PageMod.
For example, a_tab will not have the 'id' attribute, but would have linkedPanel property that's similar to the 'id' attribute.
Post a Comment for "Identify Tab That Made Request In Firefox Addon SDK"