diff options
author | Deathamns <deathamns@gmail.com> | 2015-01-16 11:42:34 +0100 |
---|---|---|
committer | Deathamns <deathamns@gmail.com> | 2015-01-16 11:42:34 +0100 |
commit | 48134d94695b833083405927318413dc261f5aab (patch) | |
tree | 6c9675f31e80e5a7b88eee2175c88516b99a6174 /platform | |
parent | f6e996c25a5a9cb293bf38158efb5544f0a9ac3d (diff) | |
download | uBlock-48134d94695b833083405927318413dc261f5aab.zip uBlock-48134d94695b833083405927318413dc261f5aab.tar.gz uBlock-48134d94695b833083405927318413dc261f5aab.tar.bz2 |
Firefox: minimal effort to support older versions
Diffstat (limited to 'platform')
-rw-r--r-- | platform/firefox/frameModule.js | 15 | ||||
-rw-r--r-- | platform/firefox/install.rdf | 4 | ||||
-rw-r--r-- | platform/firefox/vapi-background.js | 20 |
3 files changed, 28 insertions, 11 deletions
diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index ad24e49..8288fcf 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -153,13 +153,24 @@ const contentObserver = { // so check context.top instead of context if ( context.top && context.location ) { // https://bugzil.la/1092216 - getMessageManager(context).sendRpcMessage(this.cpMessageName, { + let messageManager = getMessageManager(context); + let details = { openerURL: openerURL || null, url: location.spec, type: type, frameId: type === this.MAIN_FRAME ? -1 : (context === context.top ? 0 : 1), parentFrameId: context === context.top ? -1 : 0 - }); + }; + + // TODO: frameId from outerWindowID? + // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindowUtils + + if ( typeof messageManager.sendRpcMessage === 'function' ) { + messageManager.sendRpcMessage(this.cpMessageName, details); + } else { + // Compatibility for older versions + messageManager.sendSyncMessage(this.cpMessageName, details); + } } return this.ACCEPT; diff --git a/platform/firefox/install.rdf b/platform/firefox/install.rdf index 9cbbd7f..c1534e1 100644 --- a/platform/firefox/install.rdf +++ b/platform/firefox/install.rdf @@ -17,7 +17,7 @@ <targetApplication> <r:Description> <id>{{ec8030f7-c20a-464f-9b0e-13a3a9e97384}}</id> - <minVersion>29.0</minVersion> + <minVersion>24.0</minVersion> <maxVersion>38.0</maxVersion> </r:Description> </targetApplication> @@ -26,7 +26,7 @@ <targetApplication> <r:Description> <id>{{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}}</id> - <minVersion>2.26</minVersion> + <minVersion>2.21</minVersion> <maxVersion>2.35</maxVersion> </r:Description> </targetApplication> diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index ae799b0..994aa7f 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -45,7 +45,7 @@ vAPI.firefox = true; // TODO: read these data from somewhere... vAPI.app = { name: 'µBlock', - version: '0.8.5.3' + version: '0.8.5.4' }; /******************************************************************************/ @@ -366,7 +366,7 @@ vAPI.tabs.registerListeners = function() { vAPI.tabs.getTabId = function(target) { if ( target.linkedPanel ) { - return target.linkedPanel.slice(6); + return target.linkedPanel; } var i, gBrowser = target.ownerDocument.defaultView.gBrowser; @@ -374,13 +374,13 @@ vAPI.tabs.getTabId = function(target) { // This should be more efficient from version 35 if ( gBrowser.getTabForBrowser ) { i = gBrowser.getTabForBrowser(target); - return i ? i.linkedPanel.slice(6) : -1; + return i ? i.linkedPanel : -1; } i = gBrowser.browsers.indexOf(target); if ( i !== -1 ) { - i = gBrowser.tabs[i].linkedPanel.slice(6); + i = gBrowser.tabs[i].linkedPanel; } return i; @@ -399,7 +399,7 @@ vAPI.tabs.get = function(tabId, callback) { for ( var win of windows ) { tab = win.gBrowser.tabContainer.querySelector( - 'tab[linkedpanel="panel-' + tabId + '"]' + 'tab[linkedpanel="' + tabId + '"]' ); if ( tab ) { @@ -541,7 +541,7 @@ vAPI.tabs.remove = function(tabIds) { } tabIds = tabIds.map(function(tabId) { - return 'tab[linkedpanel="panel-' + tabId + '"]'; + return 'tab[linkedpanel="' + tabId + '"]'; }).join(','); for ( var win of this.getWindows() ) { @@ -580,6 +580,7 @@ vAPI.tabs.injectScript = function(tabId, details, callback) { details.file = vAPI.getURL(details.file); } + tab.linkedBrowser.messageManager.sendAsyncMessage( location.host + ':broadcast', JSON.stringify({ @@ -1135,7 +1136,12 @@ vAPI.toolbarButton = { /******************************************************************************/ vAPI.toolbarButton.init = function() { - var {CustomizableUI} = Cu.import('resource:///modules/CustomizableUI.jsm', null); + try { + var {CustomizableUI} = Cu.import('resource:///modules/CustomizableUI.jsm', null); + } catch (ex) { + return; + } + this.defaultArea = CustomizableUI.AREA_NAVBAR; this.styleURI = [ '#' + this.id + ' {', |