[Pkg-mozext-commits] [greasemonkey] 26/62: Show script source: Switch to `.addTab()`.
David Prévot
taffit at moszumanska.debian.org
Sun Sep 13 22:10:22 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 32e21223b1dace98ac863e53aac3d57318e9b82e
Author: Anthony Lieuallen <arantius at gmail.com>
Date: Wed Aug 19 18:01:56 2015 -0400
Show script source: Switch to `.addTab()`.
Something deep in Firefox internals was failing, given the way we
called `.loadOneTab()`. Switch to `.addTab()` and tweak the
notification bar to (apparently?) cope with the different timing
that results.
Along the way: fix the is-temp-script method to actually be handled,
by listening for it via the PPMM, not global MM.
Fixes #2202
---
components/greasemonkey.js | 6 ++----
modules/remoteScript.js | 43 +++++++++++++++++++++----------------------
2 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index 9d39473..080c75a 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -58,8 +58,6 @@ function startup(aService) {
'greasemonkey:script-install', aService.scriptInstall.bind(aService));
globalMessageManager.addMessageListener(
'greasemonkey:scripts-for-url', aService.getScriptsForUrl.bind(aService));
- globalMessageManager.addMessageListener(
- 'greasemonkey:url-is-temp-file', aService.urlIsTempFile.bind(aService));
var scriptValHandler = aService.handleScriptValMsg.bind(aService);
globalMessageManager.addMessageListener(
@@ -71,13 +69,13 @@ function startup(aService) {
globalMessageManager.addMessageListener(
'greasemonkey:scriptVal-set', scriptValHandler);
- // This particular message must be listened for by the "parent" and not
- // by "global". Why?!?!?
var parentMessageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
parentMessageManager.addMessageListener(
'greasemonkey:scripts-for-uuid',
aService.getScriptsForUuid.bind(aService));
+ parentMessageManager.addMessageListener(
+ 'greasemonkey:url-is-temp-file', aService.urlIsTempFile.bind(aService));
// Yes, we have to load the frame script once here in the parent scope.
// Why? Who knows!?
diff --git a/modules/remoteScript.js b/modules/remoteScript.js
index a47f510..305d5a1 100644
--- a/modules/remoteScript.js
+++ b/modules/remoteScript.js
@@ -447,46 +447,45 @@ RemoteScript.prototype.setSilent = function(aVal) {
this._silent = !!aVal;
};
-RemoteScript.prototype.showSource = function(aTabBrowser) {
- // Turn standard browser into tab browser, if necessary.
- if (aTabBrowser.getTabBrowser) aTabBrowser = aTabBrowser.getTabBrowser();
-
+RemoteScript.prototype.showSource = function(aBrowser) {
if (this._progress[0] < 1) {
throw new Error('Script is not loaded!');
}
- var tab = aTabBrowser.loadOneTab(
- ioService.newFileURI(this._scriptFile).spec,
- {'inBackground': false});
+ var tabBrowser = aBrowser.getTabBrowser();
+ var tab = tabBrowser.addTab(ioService.newFileURI(this._scriptFile).spec);
+ tabBrowser.selectedTab = tab;
// Ensure any temporary files are deleted after the tab is closed.
- var cleanup = GM_util.hitch(this, function() {
- tab.removeEventListener("TabClose", cleanup, false);
- this.cleanup();
- });
+ var cleanup = GM_util.hitch(this, 'cleanup');
tab.addEventListener("TabClose", cleanup, false);
- var notificationBox = aTabBrowser.getNotificationBox();
- notificationBox.appendNotification(
- stringBundleBrowser.GetStringFromName('greeting.msg'),
- "install-userscript",
- "chrome://greasemonkey/skin/icon16.png",
- notificationBox.PRIORITY_WARNING_MEDIUM,
- [{
+ var buttons = [{
'label': stringBundleBrowser.GetStringFromName('greeting.btn'),
'accessKey': stringBundleBrowser.GetStringFromName('greeting.btnAccess'),
'popup': null,
'callback': GM_util.hitch(this, function() {
- GM_util.showInstallDialog(this, aTabBrowser);
+ GM_util.showInstallDialog(this, tabBrowser);
// Skip the cleanup handler, as the downloaded files are used in the
// installation process.
tab.removeEventListener("TabClose", cleanup, false);
// Timeout puts this after the notification closes itself for the
// button click, avoiding an error inside that (Firefox) code.
- GM_util.timeout(function() { aTabBrowser.removeTab(tab); }, 0);
+ GM_util.timeout(function() { tabBrowser.removeTab(tab); }, 0);
})
- }]
- );
+ }];
+ function addNotification() {
+ tab.removeEventListener('load', addNotification, true);
+ var notificationBox = tabBrowser.getNotificationBox();
+ notificationBox.appendNotification(
+ stringBundleBrowser.GetStringFromName('greeting.msg'),
+ "install-userscript",
+ "chrome://greasemonkey/skin/icon16.png",
+ notificationBox.PRIORITY_WARNING_MEDIUM,
+ buttons
+ );
+ }
+ tab.addEventListener('load', addNotification, true);
};
RemoteScript.prototype.toString = function() {
--
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