Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding the option to use the PWA in SW mode inside the Chrome extension (as prerequisite for Zimit support) #992

Closed
Jaifroid opened this issue Apr 22, 2023 · 4 comments · Fixed by #1000
Assignees
Milestone

Comments

@Jaifroid
Copy link
Member

Jaifroid commented Apr 22, 2023

Due to the continued restriction on inline JS, which is not alleviated by MV3 (Cheomium extension manifest v3) , I am considering using the same mechanism in the Chromium extension as we use in the Firefox extension for ServiceWorker mode, i.e. send the user to the offline-first moz-extension PWA.

Although we can fix the use of inline JS in the openZIM-produced scrapers (see #865), we will never be able to ban use of inline JS in Zimit ZIMs, as they come from "wild" and unpredictable sources.

As a prerequisite for supporting Zimit (upcoming Hackathon), it seems necessary to have more flexibility. This means that the extension, like the Mozilla extension, would effectively be a "shell" that redirects the user to a Progressive Web App, which is much more flexible than an extension.

Although I have #986, which could provide that flexibility, it's a major re-engineering effort, and I'm not sure it'll provide the flexibility even then.

@kelson42 Any advice?

@Jaifroid
Copy link
Member Author

I've pretty much exhausted attempts to use either a nested iframe or a Shadow DOM within the app's iframe under MV3: see #986. None of these techniques are flexible enough, or else they are blocked by MV3 policies.

I now need to test whether the PWA trick works under MV3 in Chromium browsers.

@Jaifroid
Copy link
Member Author

This option is confirmed to be working (offline also) in Chrome-Extension under Manifest v3. It successfully bypasses the restriction on inline JS by navigating to the PWA, and back to the extension if the user switches back to jQuery mode. The extension can launch the PWA fully offline (after the first visit).

There is a working version of this MV3 Chrome Extension in #984.

Should I keep the local SW mode, but warn the user that inline JS is not supported in this mode?

@Jaifroid
Copy link
Member Author

Proposed UI - the local option is hidden if we are not in a local Chromium extension:

image

@Jaifroid
Copy link
Member Author

Jaifroid commented Apr 24, 2023

@kelson42 Are you in agreement with the proposed UI above for Chromium extensions only (with MV3*)? The extra option (ServiceWorkerLocal) will be hidden and non-functional in Firefox, at least until Service Workers are enabled in Firefox's MV3 (they are currently disabled still).

The local option (what currently runs in Chromium extensions) is limited because, as you know, it can't run unsafe-inline JS or unsafe-eval. The remote version (effectively a PWA), which is the current Mozilla extension solution to run SW mode, is offline-first, but it needs one-time Internet access to cache its own code. The remote version would be the default, so most users won't have to think about these options.

The main reason for introducing an extra option in Chromium extensions is to support Zimit / WARC, since we cannot control the use of inline JS in those ZIMs, so we need a more flexible solution than either MV2 or MV3 can offer. I have tried every possibility I can think of in #984 and #986, but nothing else works. The reason for keeping the local option in Chromium Extensions is so that the extension can still provide standard ZIM access in 100% offline situations (e.g. where someone has installed the extension from a USB stick). Admittedly, such situations are rare.

*MV3 = Extension Manifest Version 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant