Skip to content

Commit

Permalink
Don't call getTabPrivacyContext() for remote tabs
Browse files Browse the repository at this point in the history
(to avoid "unsafe CPOW usage" warnings)
(#208)
  • Loading branch information
Infocatcher committed Mar 1, 2016
1 parent 2882974 commit 9a5657b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3600,10 +3600,8 @@ var privateTab = {
}));
},
toggleTabPrivate: function(tab, isPrivate, _silent) {
var window = tab.ownerDocument.defaultView;
var privacyContext = this.getTabPrivacyContext(tab);
if(!privacyContext) { // Electrolysis
_log("toggleTabPrivate(): getTabPrivacyContext() failed, will use frame script");
if(this.isRemoteTab(tab)) {
_log("toggleTabPrivate(): will use frame script");
var mm = tab.linkedBrowser.messageManager;
var receiveMessage = function(msg) {
mm.removeMessageListener("PrivateTab:PrivateChanged", receiveMessage);
Expand All @@ -3622,6 +3620,9 @@ var privateTab = {
});
return;
}

var window = tab.ownerDocument.defaultView;
var privacyContext = this.getTabPrivacyContext(tab);
if(isPrivate === undefined)
isPrivate = !privacyContext.usePrivateBrowsing;

Expand Down Expand Up @@ -4170,19 +4171,19 @@ var privateTab = {
return null;
},
isPrivateTab: function(tab) {
var privacyContext = this.getTabPrivacyContext(tab);
if(!privacyContext) {
if(this.isRemoteTab(tab)) {
_log(
"isPrivateTab() failed. Electrolysis? Fallback to check private attribute"
"isPrivateTab(): tab is remote, will check private attribute"
+ (_dbgv ? ". Call stack:\n" + new Error().stack : "")
);
return tab.getAttribute(this.privateAttr) == "true";
}
var privacyContext = this.getTabPrivacyContext(tab);
return privacyContext.usePrivateBrowsing;
},
isPrivateTabAsync: function(tab, feedback, context) {
var privacyContext = this.getTabPrivacyContext(tab, true);
if(privacyContext) {
if(!this.isRemoteTab(tab)) {
var privacyContext = this.getTabPrivacyContext(tab, true);
feedback.call(context, privacyContext.usePrivateBrowsing);
return;
}
Expand All @@ -4196,6 +4197,9 @@ var privateTab = {
action: "GetSatet"
});
},
isRemoteTab: function(tab) {
return tab.linkedBrowser && !tab.linkedBrowser.docShell;
},
isPendingTab: function(tab) {
return tab.hasAttribute("pending");
},
Expand Down

0 comments on commit 9a5657b

Please sign in to comment.