1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/app/scripts/runLockdown.js
Mark Stacey 86fba2dac1
Fix contentscript injection failure on Firefox 56 (#10034)
On Firefox 56 and Waterfox Classic, our `runLockdown.js` script throws
an error. This is fine on the HTML pages, as the next script tags still
get run without issue (though they don't benefit from the SES lockdown
sadly). But in the `contentscript`, an exception thrown here appears to
halt the execution of subsequent scripts.

To prevent the `contentscript` from crashing completely, lockdown
errors are now caught and logged. They are also logged to Sentry on the
pages where Sentry is setup.
2020-12-10 14:03:04 -03:30

20 lines
651 B
JavaScript

// Freezes all intrinsics
try {
// eslint-disable-next-line no-undef,import/unambiguous
lockdown({
consoleTaming: 'unsafe',
errorTaming: 'unsafe',
mathTaming: 'unsafe',
dateTaming: 'unsafe',
})
} catch (error) {
// If the `lockdown` call throws an exception, it interferes with the
// contentscript injection on some versions of Firefox. The error is
// caught and logged here so that the contentscript still gets injected.
// This affects Firefox v56 and Waterfox Classic
console.error('Lockdown failed:', error)
if (window.sentry && window.sentry.captureException) {
window.sentry.captureException(error)
}
}