A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/test/unit-global/frozenPromise.js

53 lines
1.4 KiB

// Should occur before anything else
import './globalPatch'
import 'ses/dist/lockdown.cjs'
import '../../app/scripts/runLockdown'
import assert from 'assert' /* eslint-disable-line import/first,import/order */
describe('Promise global is immutable', function () {
it('throws when reassinging promise (syntax 1)', function () {
try {
// eslint-disable-next-line no-global-assign,no-native-reassign
Promise = {}
assert.fail('did not throw error')
} catch (err) {
assert.ok(err, 'did throw error')
}
})
it('throws when reassinging promise (syntax 2)', function () {
try {
global.Promise = {}
assert.fail('did not throw error')
} catch (err) {
assert.ok(err, 'did throw error')
}
})
it('throws when mutating existing Promise property', function () {
try {
Promise.all = () => undefined
assert.fail('did not throw error')
} catch (err) {
assert.ok(err, 'did throw error')
}
})
it('throws when adding new Promise property', function () {
try {
Promise.foo = 'bar'
assert.fail('did not throw error')
} catch (err) {
assert.ok(err, 'did throw error')
}
})
it('throws when deleting Promise from global', function () {
try {
delete global.Promise
assert.fail('did not throw error')
} catch (err) {
assert.ok(err, 'did throw error')
}
})
})