Skip to content

Commit 9651d66

Browse files
committed
Detection of private browsing mode now works for real
1 parent c4acfd2 commit 9651d66

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/ssl-observatory.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ SSLObservatory.prototype = {
401401
// anonymisation is weak, we avoid submitting during private browsing
402402
// mode.
403403
var pbm = this.inPrivateBrowsingMode(channel);
404-
this.log(NOTE, "Private browsing mode: " + pbm);
404+
this.log(DBUG, "Private browsing mode: " + pbm);
405405
return !pbm;
406406
}
407407
},
@@ -410,16 +410,19 @@ SSLObservatory.prototype = {
410410
// In classic firefox fashion, there are multiple versions of this API
411411
// https://developer.mozilla.org/EN/docs/Supporting_per-window_private_browsing
412412
try {
413+
// Firefox 20+, this state is per-window;
414+
// should raise an exception on FF < 20
413415
CU.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
414-
// Firefox 20+, this state is per-window
415416
if (!(channel instanceof CI.nsIHttpChannel)) {
416-
this.log(WARN, "observatoryActive() without a channel");
417+
this.log(NOTE, "observatoryActive() without a channel");
417418
// This is a windowless request. We cannot tell if private browsing
418419
// applies. Conservatively, if we have ever seen PBM, it might be
419420
// active now
420421
return this.everSeenPrivateBrowsing;
421422
}
422423
var win = this.HTTPSEverywhere.getWindowForChannel(channel);
424+
if (!win) return this.everSeenPrivateBrowsing; // windowless request
425+
423426
if (PrivateBrowsingUtils.isWindowPrivate(win)) {
424427
this.everSeenPrivateBrowsing = true;
425428
return true;
@@ -432,9 +435,8 @@ SSLObservatory.prototype = {
432435
this.everSeenPrivateBrowsing = true;
433436
return true;
434437
}
435-
} catch (e) { /* seamonkey or old firefox */ }
438+
} catch (e) { /* seamonkey or very old firefox */ }
436439
}
437-
438440
return false;
439441
},
440442

0 commit comments

Comments
 (0)