Extensions API: tabs do not exist at profile startup in Brave, but do in Chrome

Description of the issue:
There is a discrepancy between how Chrome and Brave respond to the extension listed below. The extension creates an alarm, and stores tab details when the alarm expires. Querying the storage reveals that in Chrome tabs exist at the time the alarm expires, but in Brave they do not.

How can this issue be reproduced?

  1. Create an extension based on the scripts below
  2. Create a new profile in Brave and in Chrome
  3. Install the extension in the Brave and Chrome profiles
  4. close the new profiles but in each browser keep another profile open
  5. Re-open the closed profiles after more than 60 seconds
  6. Check in the console to see what was logged

Expected result:
Both browsers should report the same thing regarding the number of tabs

Brave Version( check About Brave):
Brave: 1.76.81 Chromium: 134.0.6998.166 (Official Build) (64-bit)
Chrome: 134.0.6998.165 (Official Build) (64-bit)

Additional Information:
I’m using Fedora Linux 41.

Screenshot of the consoles showing extension output. Brave is on the left.

manifest.json

{
  "manifest_version": 3,
  "version": "1.0",
  "name": "Check tabs at startup",
  "description": "Do tabs exist at startup?",
  "permissions": [
    "alarms",
    "storage",
    "tabs"
  ],
  "background": {
    "service_worker": "sw.js"
  }
}

sw.js

chrome.runtime.onInstalled.addListener(details =>
{
  chrome.alarms.create(
    "test",
    { delayInMinutes: 1 }
  );
});

chrome.alarms.onAlarm.addListener(alarm =>
{
  logger();
  setTimeout(logger, 1000);

  async function logger()
  {
    chrome.storage.local
      .set({ [Date.now()]: await chrome.tabs.query({ }) });
  }
});
1 Like

To be clear, “the extension” consists of the combination:

manifest.json AND sw.js

And, the extension is expected to report the number of existing Tabs in the:

Array { } ← fields

More information:

If all profiles are closed then the extension in Brave does report tabs existing when it is reopened*. It is only when another profile is kept open during the test that the bug appears. Chrome works as expected in both scenarios.

I’ve updated step 4 in the first post to reflect this.

*I use the profile-selection screen at startup, and the test profile was the first one I opened.

1 Like