Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

What reasons should I give my offscreen document?

91 views
Skip to first unread message

Daniel Martin

unread,
Apr 1, 2025, 5:46:13 PMApr 1
to Chromium Extensions
I have an extension that I recently upgraded to manifest v3, and part of that involved moving some calls that I had done on a background page to an offscreen page.

Specifically, my extension ships with a load of javascript files generated from the "unidata" text files published by the Unicode Consortium, only two or three of which a typical user will need at any moment. Therefore, in old "manifest v2" version of my code I loaded those files only as needed by adding a <script> tag dynamically to the background page.

In my "manifest v3" version, I now do that to the offscreen page (and then use onConnect and events on a port to query stuff loaded from those files) instead.

Also, my old code at one point invoked window.open(..., '_blank') from the background page - that obviously won't work anymore, so it's now I do that on the offscreen page too. (yes, I could _also_ request the "tabs" permission, but that really seems like overkill just to use window.open)

Neither of these reasons seems to fit any of the listed reasons for why one might need to use offscreen.

I'm currently loading my offscreen document with:

    creating = chrome.offscreen.createDocument({
      url: path,
      reasons: ['IFRAME_SCRIPTING'],
      justification: 'Dynamically load only needed unicode blocks into memory',
    });

But that doesn't really seem accurate: I'm using an offscreen document for the ability to load javascript on-demand, only as needed, by creating new <script> tags. Lazy javascript loading isn't mentioned in the chrome.offscreen documentation as a use case, nor is basic access to window.* APIs.

My extension: https://chromewebstore.google.com/detail/unicode-inspector/ckmdmkehfjmcdfnepokgihljkmgekjed
Source repo: https://github.com/fizbin/unicode_inspector

Mythical 5th

unread,
Apr 1, 2025, 6:43:57 PMApr 1
to Chromium Extensions, Daniel Martin
I have an extension where the service worker needs to prompt for confirmation. I used "DOM_SCRAPING" as the reason and it was accepted.

The only rejection I've had is where I requested the tabs permission to create a new tab. It's not actually necessary!

Patrick Kettner

unread,
Apr 2, 2025, 6:30:17 AMApr 2
to Mythical 5th, Chromium Extensions, Daniel Martin
> yes, I could _also_ request the "tabs" permission, but that really seems like overkill just to use window.open

From the docs, "Most features don't require any permissions to use. For example: creating a new tab"

patrick

You don't need to request the tabs permission to create a new tab/window.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/a980209e-78e1-493a-b77b-10d257e00a73n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages