Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is chrome tabId unique across windows

I need to know if the chrome tabId is unique across all the open windows. Incognito and normal. Is it guaranteed that non of the open tabs in all the windows will have the same tabId ?

I searched the documentation but could not find any reliable answer.

like image 485
Amila Avatar asked Jul 26 '12 01:07

Amila


People also ask

How do I find my Chrome windows ID?

chrome. windows. getCurrent(function (win) { callback(win.id) }); to get window Id.

Can you email a tab link in Chrome?

Email all open tabs in current window. Keyboard Shortcut: Alt + M. Use the button on browser toolbar, or the keyboard shortcut command: alt + m. Option to set default multiple recipients, cc & bcc addresses.


1 Answers

Yes, the tab ID is unique within a browser session. It's also mentioned in the documentation of chrome.tabs:

Tab
( object )
    id ( integer )
       The ID of the tab. Tab IDs are unique within a browser session.

If you still don't believe it, create an extension which has the tabs permission, and the right to run in an incognito window. Then run the following code in the background page:

// Create incognito window
chrome.windows.create({incognito: true, url:'about:blank'}, showTabId);
// Create normal window
chrome.windows.create({incognito: false, url:'about:blank'}, showTabId);

function showTabId(_window) {
    console.log(_window.tabs[0].id);        // Or alert, whatever.
    chrome.tabs.remove(_window.tabs[0].id); // Closes tab & window, user-friendly
}

The logged numbers are increasing (if you consider two numbers as a too small sample, run the chrome.windows.create method in a loop, until you believe it).

like image 154
Rob W Avatar answered Sep 18 '22 08:09

Rob W