Skip to content

Commit

Permalink
Improve way to detect externally opened tabs: check entire call stack
Browse files Browse the repository at this point in the history
(#42)
  • Loading branch information
Infocatcher committed Apr 25, 2013
1 parent df028d2 commit 1477cc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,13 @@ var windowsObserver = {
//_log(e.type + ": Components.stack:\n" + JSON.stringify(Components.stack, null, "\t"));
if(!prefs.get("allowOpenExternalLinksInPrivateTabs")) {
var err = new Error();
if(err.stack.replace(/:\d+\s*$/, "").endsWith("@" + err.fileName)) { // Only current file in the stack
var curFile = "@" + err.fileName + ":";
var stack = err.stack.trimRight().split("\n");
if( // this.handleEvent() => this.tabOpenHandler()
stack.length == 2 && stack.every(function(line) {
return line.indexOf(curFile) != -1;
})
) {
_log("Looks like tab, opened from external application, ignore");
return;
}
Expand Down

0 comments on commit 1477cc7

Please sign in to comment.