[Pkg-mozext-commits] [greasemonkey] 18/45: When @noframes is set, only inject into top-level windows.

David Prévot taffit at moszumanska.debian.org
Mon Nov 3 20:59:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 9537dc964389c877f95efa9a50f5a51f85fa1d63
Author: Anthony Lieuallen <arantius at gmail.com>
Date:   Thu Oct 2 11:24:08 2014 -0400

    When @noframes is set, only inject into top-level windows.
    
    Fixes #1859
---
 components/greasemonkey.js | 11 ++++++++++-
 modules/parseScript.js     |  5 +++++
 modules/script.js          | 11 +++++++++--
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index cb0625a..2376393 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -217,9 +217,18 @@ service.prototype.injectScripts = function(
     // Ignore, it's good if we can't QI to a chrome window.
   }
 
-  var chromeWin = getChromeWinForContentWin(wrappedContentWin);
+  var winIsTop = true;
+  try {
+    wrappedContentWin.QueryInterface(Ci.nsIDOMWindowInternal);
+    if (wrappedContentWin.frameElement) winIsTop = false;
+  } catch (e) {
+    // Ignore non-DOM-windows.
+    dump('Could not QI  wrappedContentWin to nsIDOMWindowInternal at\n'
+        + url + ' ?!\n');
+  }
 
   for (var i = 0, script = null; script = scripts[i]; i++) {
+    if (script.noframes && !winIsTop) continue;
     var sandbox = createSandbox(script, wrappedContentWin, url);
     runScriptInSandbox(script, sandbox);
   }
diff --git a/modules/parseScript.js b/modules/parseScript.js
index e6ac7e6..f199d1d 100644
--- a/modules/parseScript.js
+++ b/modules/parseScript.js
@@ -57,6 +57,11 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
     }
 
     switch (data.keyword) {
+    case 'noframes':
+      dump('parser set no frames\n');
+      script._noframes = true;
+      break;
+
     case 'description':
     case 'name':
       var locale = data.locale.replace(/^:/, '');
diff --git a/modules/script.js b/modules/script.js
index 3766cfe..90ae4ac 100644
--- a/modules/script.js
+++ b/modules/script.js
@@ -52,6 +52,7 @@ function Script(configNode) {
   this._modifiedTime = null;
   this._name = 'user-script';
   this._namespace = '';
+  this._noframes = false;
   this._rawMeta = '';
   this._requires = [];
   this._resources = [];
@@ -169,7 +170,7 @@ function Script_getLocalizedDescription() {
     };
   }
 
-  return this._localized
+  return this._localized;
 });
 
 Script.prototype.__defineGetter__('downloadURL',
@@ -186,6 +187,9 @@ function Script_getVersion() { return this._version; });
 Script.prototype.__defineGetter__('icon',
 function Script_getIcon() { return this._icon; });
 
+Script.prototype.__defineGetter__('noframes',
+function Script_getNoframes() { return this._noframes; });
+
 Script.prototype.__defineGetter__('enabled',
 function Script_getEnabled() { return this._enabled; });
 
@@ -387,7 +391,8 @@ Script.prototype._loadFromConfigNode = function(node) {
   this._name = node.getAttribute("name");
   this._namespace = node.getAttribute("namespace");
   this._description = node.getAttribute("description");
-  this._enabled = node.getAttribute("enabled") == true.toString();
+  this._enabled = node.getAttribute("enabled") == 'true';
+  this._noframes = node.getAttribute("noframes") == 'true';
   this._runAt = node.getAttribute("runAt") || "document-end"; // legacy default
   this._updateMetaStatus = node.getAttribute("updateMetaStatus") || "unknown";
   this.icon.fileURL = node.getAttribute("icon");
@@ -467,6 +472,7 @@ Script.prototype.toConfigNode = function(doc) {
   scriptNode.setAttribute("dependhash", this._dependhash);
   scriptNode.setAttribute("description", this._description);
   scriptNode.setAttribute("enabled", this._enabled);
+  scriptNode.setAttribute("noframes", this._noframes);
   scriptNode.setAttribute("filename", this._filename);
   scriptNode.setAttribute("installTime", this._installTime);
   scriptNode.setAttribute("modified", this._modifiedTime);
@@ -617,6 +623,7 @@ Script.prototype.updateFromNewScript = function(newScript, safeWin) {
   this._description = newScript._description;
   this._localized = newScript._localized;
   this._locales = newScript._locales;
+  this._noframes = newScript._noframes;
   this._runAt = newScript._runAt;
   this._version = newScript._version;
   this.downloadURL = newScript.downloadURL;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list