aboutsummaryrefslogtreecommitdiffstats
path: root/platform/firefox
diff options
context:
space:
mode:
authorDeathamns <deathamns@gmail.com>2015-01-12 20:39:23 +0100
committerDeathamns <deathamns@gmail.com>2015-01-13 07:30:07 +0100
commitb4ea5454128db0b008156c53a6e973a4f59ebdb4 (patch)
tree91d21ca85c9a3b649e64f3316ed00f5bae923d37 /platform/firefox
parent3522f0414d924afdf4319ed4e5c6e0f6cd7cabc1 (diff)
downloaduBlock-b4ea5454128db0b008156c53a6e973a4f59ebdb4.zip
uBlock-b4ea5454128db0b008156c53a6e973a4f59ebdb4.tar.gz
uBlock-b4ea5454128db0b008156c53a6e973a4f59ebdb4.tar.bz2
Implement vAPI.insertHTML
The purpose of this API is basically to satisfy AMO reviewers in the future, since the use of innerHTML with variables (i.e., not plain text) will be rejected without any questions. Since this is not a problem for browsers other than Firefox, they will use simple innerHTML assignment, however safe-parsing could be implemented for them too.
Diffstat (limited to 'platform/firefox')
-rw-r--r--platform/firefox/vapi-background.js7
-rw-r--r--platform/firefox/vapi-common.js22
-rw-r--r--platform/firefox/vapi-popup.js1
3 files changed, 27 insertions, 3 deletions
diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js
index 5c3fb84..d64c3fd 100644
--- a/platform/firefox/vapi-background.js
+++ b/platform/firefox/vapi-background.js
@@ -42,7 +42,7 @@ vAPI.firefox = true;
// TODO: read these data from somewhere...
vAPI.app = {
name: 'µBlock',
- version: '0.8.5.0'
+ version: '0.8.5.3'
};
/******************************************************************************/
@@ -59,7 +59,7 @@ vAPI.app.restart = function() {
// List of things that needs to be destroyed when disabling the extension
// Only functions should be added to it
-cleanupTasks = [];
+var cleanupTasks = [];
/******************************************************************************/
@@ -1212,8 +1212,9 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
var resizePopup = function() {
var body = iframe.contentDocument.body;
panel.parentNode.style.maxWidth = 'none';
- panel.style.width = iframe.style.width = body.clientWidth + 'px';
+ // Set the hegiht first, then the width for proper resising
panel.style.height = iframe.style.height = body.clientHeight + 'px';
+ panel.style.width = iframe.style.width = body.clientWidth + 'px';
updateTimer = null;
};
var onPopupReady = function() {
diff --git a/platform/firefox/vapi-common.js b/platform/firefox/vapi-common.js
index 14dbbe3..5fc3754 100644
--- a/platform/firefox/vapi-common.js
+++ b/platform/firefox/vapi-common.js
@@ -70,6 +70,28 @@ vAPI.download = function(details) {
/******************************************************************************/
+vAPI.insertHTML = (function() {
+ const {classes: Cc, interfaces: Ci} = Components;
+ const parser = Cc['@mozilla.org/parserutils;1'].getService(Ci.nsIParserUtils);
+ const io = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
+
+ return function(node, html) {
+ while ( node.firstChild ) {
+ node.removeChild(node.firstChild);
+ }
+
+ node.appendChild(parser.parseFragment(
+ html,
+ parser.SanitizerAllowStyle,
+ false,
+ io.newURI(document.baseURI, null, null),
+ document.documentElement
+ ));
+ };
+})();
+
+/******************************************************************************/
+
vAPI.getURL = function(path) {
return 'chrome://' + location.host + '/content/' + path.replace(/^\/+/, '');
};
diff --git a/platform/firefox/vapi-popup.js b/platform/firefox/vapi-popup.js
new file mode 100644
index 0000000..73250bb
--- /dev/null
+++ b/platform/firefox/vapi-popup.js
@@ -0,0 +1 @@
+/* Firefox: no platform-specific code */ \ No newline at end of file