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

Completely exit local code on comms with remote #1113

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import settingsStore from './lib/settingsStore.js';
import abstractFilesystemAccess from './lib/abstractFilesystemAccess.js';
import translateUI from './lib/translateUI.js';

if (params.abort) {
// If the app was loaded only to pass a message from the remote code, then we exit immediately
throw new Error('Managed error: exiting local extension code.')
}

/**
* The delay (in milliseconds) between two "keepalive" messages sent to the ServiceWorker (so that it is not stopped
* by the browser, and keeps the MessageChannel to communicate with the application)
Expand Down
4 changes: 3 additions & 1 deletion www/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ if (/PWA_launch=/.test(window.location.search)) {
localStorage.setItem(params.keyPrefix + 'PWA_launch', match[1]);
// If we have successfully launched the PWA (even if there was no SW mode available), we prevent future default mode change alerts
if (match[1] === 'success') localStorage.setItem(params.keyPrefix + 'defaultModeChangeAlertDisplayed', true);
console.warn('Launch of PWA has been registered as "' + match[1] + '" by the extension. Exiting local code.');
console.warn('Launch of PWA has been registered as "' + match[1] + '" by the extension.');
// Set a flag to prevent further processing in app.js
params.abort = true;
} else {
// Test if WebP is natively supported, and if not, load a webpMachine instance. This is used in uiUtils.js.
var webpMachine = false;
Expand Down