workers and local_storage reasons fail for creating offscreen document

77 views
Skip to first unread message

David Roland

unread,
May 1, 2023, 11:58:06 AM5/1/23
to Chromium Extensions
When I call chrome.offscreen.createDocument with reason WORKERS or LOCAL_STORAGE, the call throws a Type Error, and says that the property `reasons` must be one of AUDIO_PLAYBACK, BLOBS, ... This allowed list includes the reasons given in chrome api document, but not WORKERS or LOCAL_STORAGE, though these are the last two items in api doc.

Both WORKERS and LOCAL_STORAGE reasons are also included in the code here:
https://chromium.googlesource.com/chromium/src/+/main/extensions/common/api/offscreen.idl

My browser is Chrome 112.0.5615.138 on Windows.

Does anyone know if WORKERS and  LOCAL_STORAGE are valid reasons? Maybe not yet added to current chrome version? I need the offscreen document to interface with IndexedDB so was planning to use the LOCAL_STORAGE reason.

Patrick Kettner

unread,
May 1, 2023, 12:16:16 PM5/1/23
to David Roland, Chromium Extensions
Looking at the version you mentioned in omaha proxy, your chrome version is based on commit 9c6408ef696e83a9936b82bbead3d41c93c82ee4. That landed back on Feb 23. Checking the blame for the lines adding those features, they were added on march 7th. So v113 should have the change.

--
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 on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/9f162afd-614a-4cdf-a1b1-c4ba64caf1dan%40chromium.org.

Jackie Han

unread,
May 2, 2023, 12:40:39 AM5/2/23
to Patrick Kettner, David Roland, Chromium Extensions
Yes, this is a feature landed in Chrome 113 https://chromiumdash.appspot.com/commit/a8fe947f9d5737f4e36fe32ab8fa851ea6da8865

You can add "minimum_chrome_version": "113" in your manifest.json to prevent users from installing it.

You can also do feature detect for reasons:
"DOM_SCRAPING" in chrome.offscreen.Reason // true
"LOCAL_STORAGE" in chrome.offscreen.Reason // false in Chrome 112


wOxxOm

unread,
May 2, 2023, 12:48:13 AM5/2/23
to Chromium Extensions, Jackie Han, David Roland, Chromium Extensions, Patrick Kettner
Another solution is to specify a fallback reason for an old browser via a named constant and || operator:

 reasons: [chrome.offscreen.Reason.LOCAL_STORAGE || chrome.offscreen.Reason.BLOBS],
Reply all
Reply to author
Forward
0 new messages