function doit() {
alert(3);
// Statement 1
// chrome.tabs.create({url:"http://www.google.com"});
// Statement 2
// chrome.tabs.update({url:"http://en.wikipedia.org"});
alert(4);
}
chrome.browserAction.onClicked.addListener(doit);
When the script runs as is, I get JS alerts of 3 and 4. OK.
When I comment in statement 1 and run the script, I get a JS alert of 3, then Google opens in a new, active tab, then I get a JS alert of 4. As expected.
When I comment out statement 1 and comment in statement 2, I get a JS alert of 3, and that's it.
According to http://code.google.com/chrome/extensions/tabs.html#method-update, I do not need to pass a tabId object, because it "defaults to the selected tab of the current window." The url object is defined as "A URL to navigate the tab to", as I noticed when I ran the chrome.tabs.create in statement 1.
Why does my chrome.tabs.update statement not work?