close-window-with-last-tab=never is bypassed by chrome.tabs.remove()

Author: Bin-2Created Sep 25, 2026Updated Sep 25, 2026
Labelsbug

OS/Platform

Windows

Installed

https://ungoogled-software.github.io/ungoogled-chromium-binaries/

Version

Version 153.0.8010.52 (Official Build, ungoogled-chromium) (64-bit)

Have you tested that this is not an upstream issue or an issue with your configuration?

  • I have tried reproducing this issue in Chrome and it could not be reproduced there
  • I have tried reproducing this issue in vanilla Chromium and it could not be reproduced there
  • I have tried reproducing this issue in ungoogled-chromium with a new and empty profile using --user-data-dir command line argument and it could not be reproduced there

Description

When --close-window-with-last-tab=never is enabled, closing the only tab in a window through the extensions API chrome.tabs.remove() closes the entire window.

How to Reproduce?

  1. Set chrome://flags/#close-window-with-last-tab to Never.
  2. Relaunch the browser.
  3. Open a window containing only one tab.
  4. Press Ctrl+W.
  5. Confirm that the window remains open and a new tab is created.
  6. Open or return to a window containing only one tab.
  7. From an extension with the tabs permission, execute:
javascript
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
    chrome.tabs.remove(tab.id);
});

Actual behaviour

When the only tab is removed through chrome.tabs.remove(), the entire browser window closes.

The same tab closed through Ctrl+W behaves as expected: the window remains open and a new tab is created.

Expected behaviour

Removing the last tab through chrome.tabs.remove() should respect --close-window-with-last-tab=never, just like closing the tab through Ctrl+W.

The window should remain open and a new tab should be created.

Relevant log output

bash

Additional context

The current add-flag-to-close-window-with-last-tab.patch handles the behavior in TabStripModel::CloseWebContentsAt() and TabStripModel::ExecuteCloseTabs() by adding a replacement tab when closing the final tab.

chrome.tabs.remove() appears to use a different closing path. Chromium's extensions implementation ultimately removes/closes the requested WebContents, so extension-initiated removal can bypass the logic added to the TabStripModel paths covered by the patch.

This is not specific to a particular extension. I initially noticed it with the Close Tab extension:

https://chromewebstore.google.com/detail/close-tab/lnchemdcmhoccciihokpdkkekmnejfhj

but the minimal chrome.tabs.remove() example above reproduces the same behavior.

Downstream report:

https://github.com/imputnet/helium/issues/2580

Source: ungoogled-software/ungoogled-chromium