I\'m using a listener in the background page to know when a tab is loaded:
chrome.tabs.onUpdated.addListener(function
I wanted a easier way to do this after opening a tab
function createTab (url) {
return new Promise(resolve => {
chrome.tabs.create({url}, async tab => {
chrome.tabs.onUpdated.addListener(function listener (tabId, info) {
if (info.status === 'complete' && tabId === tab.id) {
chrome.tabs.onUpdated.removeListener(listener);
resolve(tab);
}
});
});
});
}
so it would be
let tab = await createTab('http://google.com');