From f6e996c25a5a9cb293bf38158efb5544f0a9ac3d Mon Sep 17 00:00:00 2001 From: Deathamns Date: Fri, 16 Jan 2015 09:01:40 +0100 Subject: [PATCH 1/2] Firefox: suppress some "unsafe CPOW usage" message --- platform/firefox/vapi-background.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index b37fd1b3d..ae799b06b 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1418,15 +1418,23 @@ vAPI.contextMenu.create = function(details, callback) { this.onCommand = function() { var gContextMenu = this.ownerDocument.defaultView.gContextMenu; var details = { - menuItemId: this.id, - tagName: gContextMenu.target.tagName.toLowerCase() + menuItemId: this.id }; if ( gContextMenu.inFrame ) { + details.tagName = 'iframe'; details.frameUrl = gContextMenu.focusedWindow.location.href; - } else if ( gContextMenu.onImage || gContextMenu.onAudio || gContextMenu.onVideo ) { + } else if ( gContextMenu.onImage ) { + details.tagName = 'img'; + details.srcUrl = gContextMenu.mediaURL; + } else if ( gContextMenu.onAudio ) { + details.tagName = 'audio'; + details.srcUrl = gContextMenu.mediaURL; + } else if ( gContextMenu.onVideo ) { + details.tagName = 'video'; details.srcUrl = gContextMenu.mediaURL; } else if ( gContextMenu.onLink ) { + details.tagName = 'a'; details.linkUrl = gContextMenu.linkURL; } From 48134d94695b833083405927318413dc261f5aab Mon Sep 17 00:00:00 2001 From: Deathamns Date: Fri, 16 Jan 2015 11:42:34 +0100 Subject: [PATCH 2/2] Firefox: minimal effort to support older versions --- platform/firefox/frameModule.js | 15 +++++++++++++-- platform/firefox/install.rdf | 4 ++-- platform/firefox/vapi-background.js | 20 +++++++++++++------- src/css/dashboard.css | 1 + src/css/devtool-log.css | 1 + src/css/devtools.css | 2 ++ src/css/popup.css | 1 + 7 files changed, 33 insertions(+), 11 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index ad24e495f..8288fcfab 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 9cbbd7f58..c1534e143 100644 --- a/platform/firefox/install.rdf +++ b/platform/firefox/install.rdf @@ -17,7 +17,7 @@ {{ec8030f7-c20a-464f-9b0e-13a3a9e97384}} - 29.0 + 24.0 38.0 @@ -26,7 +26,7 @@ {{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}} - 2.26 + 2.21 2.35 diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index ae799b06b..994aa7f0a 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 + ' {', diff --git a/src/css/dashboard.css b/src/css/dashboard.css index 12065ea94..329e41287 100644 --- a/src/css/dashboard.css +++ b/src/css/dashboard.css @@ -65,4 +65,5 @@ iframe { height: 100%; border-top: 50px solid transparent; box-sizing: border-box; + -moz-box-sizing: border-box; } diff --git a/src/css/devtool-log.css b/src/css/devtool-log.css index 1ae60b44e..1d7fb3440 100644 --- a/src/css/devtool-log.css +++ b/src/css/devtool-log.css @@ -1,6 +1,7 @@ body { border: 0; box-sizing: border-box; + -moz-box-sizing: border-box; font: 12px monospace; margin: 0; overflow-x: hidden; diff --git a/src/css/devtools.css b/src/css/devtools.css index f3022e730..4f29fb19f 100644 --- a/src/css/devtools.css +++ b/src/css/devtools.css @@ -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; diff --git a/src/css/popup.css b/src/css/popup.css index 5edd1b5b2..0a3a6016d 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -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;