[Pkg-mozext-commits] [greasemonkey] 07/21: Restore delayed script execution.
David Prévot
taffit at moszumanska.debian.org
Sun Sep 13 21:27:15 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 106fc3614fa7bcc77c939e448c9321065ff56a7a
Author: Anthony Lieuallen <arantius at gmail.com>
Date: Mon Jul 13 16:51:50 2015 -0400
Restore delayed script execution.
---
content/framescript.js | 13 +++++++------
modules/util/windowId.js | 8 ++++++--
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/content/framescript.js b/content/framescript.js
index 136a170..a65e8ce 100644
--- a/content/framescript.js
+++ b/content/framescript.js
@@ -91,15 +91,18 @@ function createScriptFromObject(aObject) {
function injectDelayedScript(aMessage) {
- // TODO: Make this work again.
var windowId = aMessage.data.windowId;
var windowMediator = Components
.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator);
var win = windowMediator.getOuterWindowWithId(windowId);
- console.log('injectDelayedScript; windowId='+windowId+'; win='+win+'\n');
-// injectScripts([script], win);
+ if (!win) {
+ dump('Couldn\'t find window with (outer?) ID ' + windowId + '!\n');
+ } else {
+ var script = createScriptFromObject(aMessage.data.script);
+ injectScripts([script], win);
+ }
};
@@ -142,13 +145,11 @@ function runScripts(aRunWhen, aContentWin) {
var url = urlForWin(aContentWin);
if (!GM_util.isGreasemonkeyable(url)) return;
- var windowId = GM_util.windowId(aContentWin);
-
var response = sendSyncMessage(
'greasemonkey:scripts-for-url', {
'url': url,
'when': aRunWhen,
- 'windowId': windowId
+ 'windowId': GM_util.windowId(aContentWin, 'outer'),
});
if (!response || !response[0]) return;
diff --git a/modules/util/windowId.js b/modules/util/windowId.js
index 49950b7..383d457 100644
--- a/modules/util/windowId.js
+++ b/modules/util/windowId.js
@@ -2,7 +2,7 @@ Components.utils.import('chrome://greasemonkey-modules/content/util.js');
var EXPORTED_SYMBOLS = ['windowId'];
-function windowId(win) {
+function windowId(win, which) {
try {
// Do not operate on chrome windows.
win.QueryInterface(Components.interfaces.nsIDOMChromeWindow);
@@ -25,7 +25,11 @@ function windowId(win) {
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var windowId;
try {
- windowId = domWindowUtils.currentInnerWindowID;
+ if ('outer' == which) {
+ windowId = domWindowUtils.outerWindowID;
+ } else if (!which || 'inner' == which) {
+ windowId = domWindowUtils.currentInnerWindowID;
+ }
} catch (e) { }
if ('undefined' == typeof windowId) {
// Firefox <4.0 does not provide this, use the document instead.
--
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