Skip to content

Commit

Permalink
fix for when activeTab.url is not yet defined
Browse files Browse the repository at this point in the history
  • Loading branch information
zombie committed Feb 24, 2014
1 parent 10ff3dd commit 1d3ea34
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions core/extensions/firefox/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@ const { data, uri } = require('sdk/self');
const { PageMod } = require('sdk/page-mod');
const tabs = require('sdk/tabs');

function attach(tab) {
let mod = PageMod({
include: tab.url,
contentScriptFile: [data.url('load.js')],
contentScriptWhen: 'start',
contentScriptOptions: {
myJS: [data.url('shim.js'), data.url('gli.all.js')],
myCSS: [data.url('gli.all.css')]
}
});
tab.once('load', function () {
mod.destroy();
});
tab.reload();
}

require('menuitems').Menuitem({
id: 'webgl-inspector',
label: 'WebGL Inspector',
onCommand: function () {
let tab = tabs.activeTab;
let mod = PageMod({
include: tab.url,
contentScriptFile: [data.url('load.js')],
contentScriptWhen: 'start',
contentScriptOptions: {
myJS: [data.url('shim.js'), data.url('gli.all.js')],
myCSS: [data.url('gli.all.css')]
}
});
tab.once('load', function () {
mod.destroy();
});
tab.reload();
if (tab.url) {
attach(tab);
} else {
tab.once('ready', function() {
attach(tab);
})
}
},
menuid: 'menuWebDeveloperPopup',
insertbefore: 'devToolsEndSeparator',
Expand Down

0 comments on commit 1d3ea34

Please sign in to comment.