Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #630 from ZER0/window.tabs/bug804935
Browse files Browse the repository at this point in the history
Fix Bug 804935 - TypeError: window.tabs is undefined r=@erikvold
  • Loading branch information
erikvold committed Jan 3, 2013
2 parents b205f22 + 08e9d03 commit f2c93bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lib/sdk/tabs/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@

const { getTabForContentWindow } = require('./utils');
const { Tab } = require('./tab');
const { getOwnerWindow } = require('./utils');
const { BrowserWindow } = require('../windows');

function getTabForWindow(win) {
let tab = getTabForContentWindow(win);
// We were unable to find the related tab!
if (!tab)
return null;

return Tab({ tab: tab });
let topWindow = getOwnerWindow(tab);

return Tab({
tab: tab,
// Bring back this line for consistency. However it's actually not needed,
// as soon as the `windows` module is included - even if it's not used -
// the Tab will have the proper browser window assigned. That will be
// eventually fixed when deprecated Trackers will be removed.
//
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=804935
window: BrowserWindow({ window: topWindow })
});
}
exports.getTabForWindow = getTabForWindow;
2 changes: 1 addition & 1 deletion lib/sdk/tabs/tab-firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TabTrait = Trait.compose(EventEmitter, {
constructor: function Tab(options) {
this._onReady = this._onReady.bind(this);
this._tab = options.tab;
let window = this.window = options.window || getOwnerWindow(this._tab);
let window = this.window = options.window;

// Setting event listener if was passed.
for each (let type in EVENTS) {
Expand Down

0 comments on commit f2c93bd

Please sign in to comment.