[Pkg-mozext-commits] [nosquint] 02/04: Ignore errors from PrivateBrowsingUtils.isWindowPrivate()
David Prévot
taffit at moszumanska.debian.org
Tue Apr 28 01:41:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 2.1.9
in repository nosquint.
commit 7263e159832b0010aa56c2aa024274c5d0631c30
Author: Jason Tackaberry <tack at urandom.ca>
Date: Sat Apr 20 13:49:14 2013 -0400
Ignore errors from PrivateBrowsingUtils.isWindowPrivate()
Fixes #73.
---
src/content/browser.js | 2 +-
src/content/lib.js | 27 +++++++++++++++++++++------
src/content/prefs.js | 2 +-
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/src/content/browser.js b/src/content/browser.js
index e148539..d05b40e 100644
--- a/src/content/browser.js
+++ b/src/content/browser.js
@@ -14,7 +14,7 @@ NoSquint.browser = NoSquint.ns(function() { with (NoSquint) {
this.init = function() {
this.gBrowser = gBrowser;
- this.isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
+ this.isPrivate = isWindowPrivate();
this.prefs = NSQ.prefs;
this.updateZoomMenu();
diff --git a/src/content/lib.js b/src/content/lib.js
index f2be511..9e18323 100644
--- a/src/content/lib.js
+++ b/src/content/lib.js
@@ -47,6 +47,21 @@
return doc.getElementById(id);
};
+ this.isWindowPrivate = function(win) {
+ if (win === undefined)
+ win = window;
+ try {
+ return PrivateBrowsingUtils.isWindowPrivate(win);
+ } catch (e) {
+ // As per issue #73, for some unknown reason,
+ // PBU.isWindowPrivate() can throw NS_NOINTERFACE. I have never
+ // been able to reproduce this on Linux, so perhaps this is
+ // platform specific. In any case, just blindly catch exceptions
+ // thrown here and assume the window isn't private if it throws.
+ return false;
+ }
+ };
+
// Loads a string bundle and returns a key -> value map.
this.getStringBundle = function(name) {
var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
@@ -110,7 +125,7 @@
// XXX: don't forget to disable this for releases.
this.debug = function(msg) {
- //dump("[nosquint] " + msg + "\n");
+ // dump("[nosquint] " + msg + "\n");
};
/* This function is called a lot, so we take some care to optimize for the
@@ -119,7 +134,7 @@
this.isChrome = function(browser) {
var document = browser.docShell.document;
- //this.debug('isChrome(): URL=' + document.URL + ', spec=' + browser.currentURI.spec + ', contentType=' + document.contentType);
+ // this.debug('isChrome(): URL=' + document.URL + ', spec=' + browser.currentURI.spec + ', contentType=' + document.contentType);
if (document.URL == undefined)
return true;
@@ -160,12 +175,12 @@
return doc.body ? doc.body.firstChild : null;
};
- this.foreachNSQ = (function() {
+ this.foreachNSQ = (function(self) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
return function(callback) {
// For private windows, apply callback only to self.
- if (PrivateBrowsingUtils.isWindowPrivate(window)) {
+ if (self.isWindowPrivate(window)) {
callback(this.NSQ);
return window;
}
@@ -175,13 +190,13 @@
var enumerator = wm.getEnumerator("navigator:browser");
var win;
while ((win = enumerator.getNext())) {
- if (win.NoSquint && !PrivateBrowsingUtils.isWindowPrivate(win) &&
+ if (win.NoSquint && !self.isWindowPrivate(win) &&
callback(win.NoSquint) === false)
break;
}
return win;
};
- })();
+ })(this);
this.popup = function(type, title, text, value) {
diff --git a/src/content/prefs.js b/src/content/prefs.js
index 16a8fa4..902001c 100644
--- a/src/content/prefs.js
+++ b/src/content/prefs.js
@@ -12,7 +12,7 @@
*/
NoSquint.prefs = NoSquint.ns(function() { with(NoSquint) {
- this.isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
+ this.isPrivate = isWindowPrivate();
if (!this.isPrivate) {
// For non-private windows, namespace is a singleton, so return any
// previously instantiated prefs object.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nosquint.git
More information about the Pkg-mozext-commits
mailing list