browser.tabs API not working as expected

Here's my manifest.json:

Code Block json
{
  "manifest_version": 2,
  "default_locale": "en",
  "name": "MSG_extension_name",
  "description": "MSG_extension_description",
  "version": "1.0",
  "icons": {
    "48": "images/icon-48.png",
    "96": "images/icon-96.png",
    "128": "images/icon-128.png",
    "256": "images/icon-256.png",
    "512": "images/icon-512.png"
  },
  "background": {
    "scripts": [ "background.js" ]
  },
  "content_scripts": [{
    "js": [ "content.js" ],
    "matches": [ "*://example.com/*" ]
  }],
  "browser_action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "images/toolbar-icon-16.png",
      "19": "images/toolbar-icon-19.png",
      "32": "images/toolbar-icon-32.png",
      "38": "images/toolbar-icon-38.png"
    }
  },
  "permissions": ["<all_urls>", "tabs"]
}


On my background.js, I have this:

Code Block javascript
browser.tabs.onCreated.addListener(tab => {
  console.log("onCreated", tab)
})
browser.tabs.onCreated.addListener((tabId, changeInfo, tab) => {
  console.log("onUpdated", tabId, changeInfo, tab)
})


When I open a new tab I see this in the background log:

Code Block language
"onCreated": {
"id": 7,
"index": 1,
"active": true,
"width": 938,
"audible": false,
"url": "",
"mutedInfo": {
"muted": false
},
"windowId": 2,
"title": "",
"pendingUrl": "",
"incognito": true,
"pinned": false,
"height": 1027,
"highlighted": true,
"status": "complete"
}


Code Block language
"onUpdated": {
"id": 7,
"index": 1,
"active": true,
"width": 938,
"audible": false,
"url": "",
"mutedInfo": {
"muted": false
},
"windowId": 2,
"title": "",
"pendingUrl": "",
"incognito": true,
"pinned": false,
"height": 1027,
"highlighted": true,
"status": "complete"
}


Problem 1
Why are the title, url and pendingUrl empty if I have the permission set for all urls and the user accepted it?

Problem 2
Safari internal pages url, eg.: "about:blank" are not included in browser.tabs.query, eg.:

browser.tabs.query({}, el => { console.log(el)})


Replies

You have a typo in your background script, the second listener should be browser.tabs.onUpdated instead of browser.tabs.onCreated a second time.

The tabs events will only deliver info for sites the user has granted permission for already. Explicit API calls like browser.tabs.query() will prompt the user via a badged on your extension's toolbar item and block for up-to 2 minutes to give the user time to answer. However, passive events like this don't trigger any permission prompts.

Unlike other browsers, putting <all_urls> in your manifest does not grant you access to all pages on install. The usr needs to grant explicit access per-site via the toolbar item permission popover, or you can do an explicit request for specific domains using browser.permissions.request(). Until the user has granted permission for a site, it is expected that tab info will have no title, url, etc. This is a privacy feature detailed in Meet Safari Web Extensions.

Can you file a bug via Feedback Assistant for the about:blank issue you mentioned?