You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tab id values are natively integer values, but they are currently normalized to strings internally on the platform-independent code.
The reason for this is historical: tab id values were used as keys in Object used as dictionary (Map/Set were not available back then). When an integer is used as a key, it is converted to string internally by javascript, and this means when iterating through the items in the Object-based dictionary, the tab id key value was a string. Instead of converting the string back to integer, back then I chose to normalize all tab id values to string.
This issue is to normalize tab id values to their native integer representation, and convert Object-based dictionaries to Maps where needed so as to avoid the implicit javascript conversion of tab id values to string.
The behind-the-scene scope will be represented with the integer -1.
The no tab found value will be 0.
The text was updated successfully, but these errors were encountered:
Are you absolutely sure Chrome will never assign a tab to have ID 0?
When there is no tab, Chrome will set the tab ID to be the constant chrome.tabs.TAB_ID_NONE which happens to be -1. It is safe enough to assume that all tab IDs are larger than -1 although there is no documentation on that. I think -2 (or null, Infinity, etc) are safer than 0.
In light of of regression #3425.
Tab id values are natively integer values, but they are currently normalized to strings internally on the platform-independent code.
The reason for this is historical: tab id values were used as keys in
Object
used as dictionary (Map/Set were not available back then). When an integer is used as a key, it is converted to string internally by javascript, and this means when iterating through the items in the Object-based dictionary, the tab id key value was a string. Instead of converting the string back to integer, back then I chose to normalize all tab id values to string.This issue is to normalize tab id values to their native integer representation, and convert Object-based dictionaries to Maps where needed so as to avoid the implicit javascript conversion of tab id values to string.
The behind-the-scene scope will be represented with the integer -1.
The no tab found value will be 0.
The text was updated successfully, but these errors were encountered: