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

fix: skip snow usage for MV3 test build #19827

Merged
merged 5 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions app/scripts/app-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function importAllScripts() {
loadFile('./globalthis.js');
loadFile('./sentry-install.js');

const isWorker = !self.document
if (!isWorker) { // process.env.ENABLE_MV3 ?
loadFile('./snow.js');
}

loadFile('./use-snow.js');

// Always apply LavaMoat in e2e test builds, so that we can capture initialization stats
if (testMode || applyLavaMoat) {
loadFile('./runtime-lavamoat.js');
Expand Down
15 changes: 10 additions & 5 deletions app/scripts/use-snow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ Changing this code must be done cautiously to avoid breaking the app!
// eslint-disable-next-line import/unambiguous
(function () {
const log = console.log.bind(console);
const isWorker = !self.document; // process.env.ENABLE_MV3 ?
const msg =
'Snow detected a new realm creation attempt in MetaMask. Performing scuttling on new realm.';
Object.defineProperty(window.top, 'SCUTTLER', {
Object.defineProperty(self, 'SCUTTLER', {
value: (realm, scuttle) => {
window.top.SNOW((win) => {
log(msg, win);
scuttle(win);
}, realm);
if (isWorker) {
scuttle(realm);
} else {
self.SNOW((win) => {
log(msg, win);
scuttle(win);
}, realm);
}
},
});
})();