[Pkg-mozext-commits] [greasemonkey] 09/21: Identify both which script and which registered command to run.
David Prévot
taffit at moszumanska.debian.org
Sun Sep 13 21:27:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository greasemonkey.
commit 8ad2bb3920550171bb6d24b59805b67c0d170b98
Author: Anthony Lieuallen <arantius at gmail.com>
Date: Wed Jul 15 15:30:53 2015 -0400
Identify both which script and which registered command to run.
---
content/menucommander.js | 2 +-
modules/menucommand.js | 11 +++++++----
modules/sandbox.js | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/content/menucommander.js b/content/menucommander.js
index 20d8c4b..a3f7008 100644
--- a/content/menucommander.js
+++ b/content/menucommander.js
@@ -20,7 +20,7 @@ GM_MenuCommander.initialize = function() {
GM_MenuCommander.commandClicked = function(aCommand) {
gBrowser.selectedBrowser.messageManager.sendAsyncMessage(
'greasemonkey:menu-command-run',
- {'cookie': aCommand.cookie});
+ {'cookie': aCommand.cookie, 'scriptUuid': aCommand.scriptUuid});
};
diff --git a/modules/menucommand.js b/modules/menucommand.js
index c18d3b0..0a3675f 100644
--- a/modules/menucommand.js
+++ b/modules/menucommand.js
@@ -32,7 +32,8 @@ function MenuCommandRespond(aCookie, aData) {
// from the parent, pass it into the sandbox.
function MenuCommandRun(aContent, aMessage) {
var e = new aContent.CustomEvent(
- 'greasemonkey-menu-command-run', {'detail': aMessage.data.cookie});
+ 'greasemonkey-menu-command-run',
+ {'detail': JSON.stringify(aMessage.data)});
aContent.dispatchEvent(e);
}
@@ -40,7 +41,7 @@ function MenuCommandRun(aContent, aMessage) {
// This function is injected into the sandbox, in a private scope wrapper, BY
// SOURCE. Data and sensitive references are wrapped up inside its closure.
function MenuCommandSandbox(
- aScriptId, aScriptName, aCommandResponder, aFrameScope,
+ aScriptUuid, aScriptName, aCommandResponder, aFrameScope,
aInvalidAccesskeyErrorStr) {
// 1) Internally to this function's private scope, maintain a set of
// registered menu commands.
@@ -52,7 +53,9 @@ function MenuCommandSandbox(
}, true);
// 3) Respond to requests to run those registered commands.
addEventListener('greasemonkey-menu-command-run', function(e) {
- var command = commands[e.detail];
+ var detail = JSON.parse(e.detail);
+ if (aScriptUuid != detail.scriptUuid) return;
+ var command = commands[detail.cookie];
if (!command) {
throw new Error('Could not run requested menu command!');
} else {
@@ -77,8 +80,8 @@ function MenuCommandSandbox(
var command = {
cookie: ++commandCookie,
name: commandName,
- scriptId: aScriptId,
scriptName: aScriptName,
+ scriptUuid: aScriptUuid,
accessKey: accessKey,
commandFunc: commandFunc,
};
diff --git a/modules/sandbox.js b/modules/sandbox.js
index 863b8d7..4676035 100644
--- a/modules/sandbox.js
+++ b/modules/sandbox.js
@@ -73,7 +73,7 @@ function createSandbox(aScript, aContentWin, aUrl, aFrameScope) {
if (GM_util.inArray(aScript.grants, 'GM_registerMenuCommand')) {
Components.utils.evalInSandbox(MenuCommandSandbox.toSource(), sandbox);
sandbox.MenuCommandSandbox(
- aScript.id, aScript.name, MenuCommandRespond, aFrameScope,
+ aScript.uuid, aScript.name, MenuCommandRespond, aFrameScope,
gInvalidAccesskeyErrorStr);
Components.utils.evalInSandbox('delete MenuCommandSandbox;', sandbox);
}
--
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