Safari Extension browser.tabs.query returns invalid results

When you have a blank Safari new tab open, the browser.tabs.query API inaccurately includes those tabs in results that include a url or title in the query options.

To reproduce, open several tabs, and a blank new tab. Open the background page devtools, and execute the following command:

browser.tabs.query({url: 'https://github.com/'}, console.log)

In addition to any potentially valid results (if you have github.com open, for example), there will also be an entry for the blank tab, which has an empty, non-matching URL.

Tab { 
  active: true, 
  audible: false, 
  height: 1095, 
  highlighted: true, 
  id: 6, 
  incognito: false, 
  index: 3, 
  isArticle: false, 
  isInReaderMode: false, 
  mutedInfo: {muted: false}, 
  pendingUrl: "", 
  pinned: false, 
  status: "complete", 
  title: "", url: "", 
  width: 1792, 
  windowId: 1 
}

I hope that this bug can be addressed, as it causes some unexpected behavior.

Update: I filed an issue with Feedback Assistant back when I initially discovered this issue. They reached out and this appears to be fixed on the latest developer beta for Sequoia macOS 15.

Safari Extension browser.tabs.query returns invalid results
 
 
Q