Firefox: minimal effort to support older versions

This commit is contained in:
Deathamns 2015-01-16 11:42:34 +01:00
parent f6e996c25a
commit 48134d9469
7 changed files with 33 additions and 11 deletions

View File

@ -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;

View File

@ -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>

View File

@ -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 + ' {',

View File

@ -65,4 +65,5 @@ iframe {
height: 100%;
border-top: 50px solid transparent;
box-sizing: border-box;
-moz-box-sizing: border-box;
}

View File

@ -1,6 +1,7 @@
body {
border: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
font: 12px monospace;
margin: 0;
overflow-x: hidden;

View File

@ -8,6 +8,7 @@ body {
background-color: #eee;
border: none;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 4em;
padding: 1em;
position: fixed;
@ -41,6 +42,7 @@ select option {
#content {
border: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: calc(100vh - 4em);
margin-top: 4em;
overflow-y: auto;

View File

@ -192,6 +192,7 @@ body.dirty #refresh:hover {
background-color: transparent;
border: none;
box-sizing: border-box;
-moz-box-sizing: border-box;
color: #000;
display: inline-block;
height: 24px;