Skip to content
Browse files

No longer closes other windows by mistake. Resolves issue #11

Apparently, windows CAN and WILL share the same tab.ID, which is why
you would experience your browser windows closing at random, on you.
Now, before we close our delicious popup window, we check and see if
the uRL starts with delicious.com. Seems to work so far.
  • Loading branch information...
1 parent 90a4b0f commit 45c4717d3e2db339e6d693197d408ff09a2fa506 @billkeller committed Dec 9, 2011
Showing with 12 additions and 3 deletions.
  1. +12 −3 background.html
View
15 background.html
@@ -8,8 +8,8 @@
chrome.windows.getCurrent(function(w) {
chrome.tabs.getSelected(w.id,
function (response){
- // alert(ourWindow);
- // alert(response.id);
+ // alert('ourWindow: ' + ourWindow);
+ // alert('response id: '+ response.id);
if(response.id == ourWindow) {
// You're here because this is the ID of the popup window our extension created
// alert('Found this puppy');
@@ -21,6 +21,7 @@
}
var data = tab.url
+ var tldURL = 'http://delicious.com'
var saveURL = 'http://delicious.com/save?'
var registerURL = 'http://delicious.com/register'
var loginURL = 'http://delicious.com/login'
@@ -33,7 +34,15 @@
// we edit the layout of the login page a bit in style.css
}
} else {
- chrome.tabs.remove(tabId);
+ // Double check that it's actually our popup, if not, exit
+ // What I'm founding now, is that windows CAN and DO share the same tab.id
+ //
+ if(data.startsWith(tldURL)) {
+ chrome.tabs.remove(tabId);
+ } else {
+ // We're here by mistake
+ // alert('Whoops, don\'t close ME!');
+ }
}
}

1 comment on commit 45c4717

@cfarah
cfarah commented on 45c4717 Dec 19, 2011

Bill, I've been using the latest version and there have been no problems so far. Thanks for the fix!
-Cameron

Please sign in to comment.
Something went wrong with that request. Please try again.