Skip to content

Fix "The 'activeTab' permission is not in effect" in a Chrome extension

7 min readModerok team

Why Chrome says the activeTab permission is not in effect, the manifest and handler that fix it, and which pages only activeTab can capture.

If chrome.tabs.captureVisibleTab() rejects with The 'activeTab' permission is not in effect because this extension has not been in invoked., you are capturing a privileged page (a chrome:// page, another extension's page, a data: URL, or the Chrome Web Store) with broad host permissions and no live activeTab grant on that tab. Host permissions do not reach those pages. Declare activeTab too, and capture inside a handler for a gesture that grants it:

{
  "manifest_version": 3,
  "permissions": ["activeTab"],
  "host_permissions": ["<all_urls>"],
  "action": { "default_title": "Capture this tab" },
  "background": { "service_worker": "background.js" }
}
chrome.action.onClicked.addListener(async (tab) => {
  const dataUrl = await chrome.tabs.captureVisibleTab(tab.windowId, {
    format: "png",
  });
  // dataUrl is a data: URL you can store, upload, or draw.
});

Reload at chrome://extensions, click the toolbar button on the tab you want, and the capture succeeds. Keep <all_urls> only if you already had it: activeTab alone is enough, and cheaper. The rest of this post is what the message means, because its text points at the wrong half of the problem.

What "the activeTab permission is not in effect" means

Declaring "activeTab" grants nothing. It makes the browser willing to grant a temporary, per-tab permission later. Chrome's activeTab page describes a permission that "gives an extension temporary access to the currently active tab when the user invokes the extension."

The string is defined in manifest_constants.h and assigned once in permissions_data.cc, in the last branch of CanCaptureVisiblePage(). Two early exits come first (a URL the browser will not capture, a policy-blocked host). After those, the capture branch opens with a check that precedes anything about privileged pages:

if (!has_active_tab && !has_all_urls) {
  if (error)
    *error = manifest_errors::kAllURLOrActiveTabNeeded;
  return false;
}

has_active_tab is the live per-tab grant, not the manifest key: it comes from GetTabSpecificPermissions(tab_id). So:

  • Either the '<all_urls>' or 'activeTab' permission is required. No live grant and no <all_urls>. This is what an activeTab-only extension gets when it has not been invoked, despite the text saying nothing about invocation.
  • The 'activeTab' permission is not in effect because this extension has not been in invoked. You cleared the first check with <all_urls>, you still have no live grant, and the page is one of the four origins the code comment lists: chrome:-scheme pages, other extensions' pages, data: URLs, and the Chrome Web Store. Chrome's docs name the first three; the Web Store comes from the Chromium comment. On those four, only a live grant works.
  • Cannot access contents of the page. Extension manifest must request permission to access the respective host. You have a grant or <all_urls>, but page access is denied for another reason. The in-code comment gives one example: a file:// URL where the extension lacks file access. It is handed up from the page-access check, which picks the url-bearing variant when the extension declares "tabs": Cannot access contents of url "*". ...

So if you get the "not in effect" string, you are not missing host permissions. You have broad ones aimed at a page where they are irrelevant.

One line on that page looks like it rules the fix out: "Access is not granted to restricted pages, such as chrome:// pages." That governs script access. The capture path asks only whether a tab grant exists, and active_tab_permission_granter.cc inserts one on invocation whatever the scheme.

The four gestures that grant it

Chrome's activeTab page lists four under "Invoking activeTab":

Executing an action Executing a context menu item Executing a keyboard shortcut from the commands API Accepting a suggestion from the omnibox API

MDN's activeTab permission page lists the same four with their events: menus.onClicked, commands.onCommand, and omnibox.onInputEntered. MDN adds a case Chrome's list omits: a menus item shown when the user context-clicks a tab in the tab strip grants activeTab "for the tab clicked, even if it isn't the active tab," which its compatibility table dates to Firefox 63 and Chrome 150. An alarm, tabs.onActivated, or a message from a content script never produces a grant, however recently the user touched the extension.

  • A declared popup moves your code. Chrome's action reference says of action.onClicked that "This event will not fire if the action has a popup," so an extension with a popup runs the capture from the popup's own script. Both docs name invoking the action as the gesture; neither spells out the popup.
  • The side panel is not on the list. The chromium-extensions thread on this reports panel captures failing where the same code in a popup works, and a Chrome developer replies that the team "decided against adding activeTab permissions, because the Side Panel can stay open across tabs and suddenly losing permissions while the panel is still open could be confusing." If your UI lives in a panel, trigger the capture from a command or context menu item.

Why the grant disappears mid-flow

Chrome's page: "Access to the tab lasts while the user is on that page, and is revoked when the user navigates away or closes the tab." Its example has a grant on https://example.com surviving a move to https://example.com/foo but not one to https://chromium.org.

So one cause of an intermittent failure is timing. await a fetch or a round trip to your backend between the click and the capture, and a cross-origin navigation during that wait kills the grant. Capture first, then do the slow work.

Why host permissions are not the way out

The obvious alternative is to drop the gesture and lean on host permissions. For ordinary pages that works: the tabs reference says the method needs "either the <all_urls> permission or the activeTab permission." For the privileged ones it does not, because those "sensitive sites can only be captured with the activeTab permission." <all_urls> also costs an install warning, while activeTab "displays no warning message during installation"; see host_permissions vs permissions. One more line: "File URLs may be captured only if the extension has been granted file access," a user-set toggle, not a manifest key.

What still breaks after the permission is right

  • Two calls per second, unless the call carries a gesture. The tabs reference documents MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND with value 2, noting that "captureVisibleTab is expensive and should not be called too often." Exceed it and the quota service answers This request exceeds the MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND quota. Chromium skips the quota when the call carries a user gesture (ShouldSkipQuotaLimiting() in tabs_api.cc returns user_gesture() || disable_throttling_for_test_), so a click-driven capture is exempt and a timer-driven loop is not.

  • Failed to capture tab: view is invisible. Chromium formats that family as Failed to capture tab: *, with the reasons image readback failed, encoding failed, view is invisible, and internal error. The third means the capture client found no RenderWidgetHostView for the tab; an empty bitmap reports image readback failed instead.

  • Only the active tab of a window. The method captures "the visible area of the currently active tab in the specified window," so windowId picks a window, not a tab.

  • Enterprise policy. Capture can be refused with Taking screenshots has been disabled or Administrator policy disables screen capture when confidential content is visible.

  • No DOM to decode the result. The returned data: URL cannot be loaded with new Image() in a service worker. fetch() it, then use createImageBitmap() and OffscreenCanvas, as in changing a toolbar icon from an MV3 service worker.

  • The default format is JPEG. The extensionTypes reference defines ImageDetails: "The format of the resulting image. Default is "jpeg"", and quality is "ignored for PNG images." Text screenshots want format: "png".

Firefox differences

Firefox reached the activeTab route later. MDN's captureVisibleTab page notes: "In Firefox 125 and earlier, this method was only available with the <all_urls> permission." The activeTab page gives the same floor: "Capture the tab's contents with tabs.captureVisibleTab() (from Firefox 126)." Older releases still need <all_urls> on that branch.

Revocation differs as well. Below its compatibility tables MDN says Chrome's "access persists while the tab stays on the same origin, including across reloads," while in Firefox "any navigation resulting in a new document ends the access." The tab-strip gesture above is also a long-standing Firefox capability and a very new Chrome one.

Instrument the failure, because users will not report it

Every branch above surfaces as a rejected promise, or an unchecked runtime.lastError in your service worker console. Neither reaches you from an installed copy:

try {
  const dataUrl = await chrome.tabs.captureVisibleTab(tab.windowId, { format: "png" });
  await uploadScreenshot(dataUrl);
  Moderok.track("tab_captured");
} catch (error) {
  Moderok.captureError(error, { action: "capture_tab" });
}

Moderok records uncaught exceptions and unhandled rejections automatically, and Moderok.captureError() covers a handled case like this one, so the message text and how often it fires reach the error log instead of vanishing into a caught promise. Setup is in the error tracking docs. When the same string keeps arriving, you know users are clicking your screenshot button on pages the browser will not let them capture.