2020-11-24 04:26:43 +01:00
|
|
|
// 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 */
|
2019-10-24 15:54:32 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Promise global is immutable', function () {
|
|
|
|
it('throws when reassinging promise (syntax 1)', function () {
|
2019-10-24 15:54:32 +02:00
|
|
|
try {
|
2020-08-13 01:51:54 +02:00
|
|
|
// eslint-disable-next-line no-global-assign,no-native-reassign
|
2019-10-24 15:54:32 +02:00
|
|
|
Promise = {}
|
|
|
|
assert.fail('did not throw error')
|
|
|
|
} catch (err) {
|
|
|
|
assert.ok(err, 'did throw error')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('throws when reassinging promise (syntax 2)', function () {
|
2019-10-24 15:54:32 +02:00
|
|
|
try {
|
|
|
|
global.Promise = {}
|
|
|
|
assert.fail('did not throw error')
|
|
|
|
} catch (err) {
|
|
|
|
assert.ok(err, 'did throw error')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('throws when mutating existing Promise property', function () {
|
2019-10-24 15:54:32 +02:00
|
|
|
try {
|
2020-08-14 13:47:02 +02:00
|
|
|
Promise.all = () => undefined
|
2019-10-24 15:54:32 +02:00
|
|
|
assert.fail('did not throw error')
|
|
|
|
} catch (err) {
|
|
|
|
assert.ok(err, 'did throw error')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('throws when adding new Promise property', function () {
|
2019-10-24 15:54:32 +02:00
|
|
|
try {
|
|
|
|
Promise.foo = 'bar'
|
|
|
|
assert.fail('did not throw error')
|
|
|
|
} catch (err) {
|
|
|
|
assert.ok(err, 'did throw error')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('throws when deleting Promise from global', function () {
|
2019-10-24 15:54:32 +02:00
|
|
|
try {
|
|
|
|
delete global.Promise
|
|
|
|
assert.fail('did not throw error')
|
|
|
|
} catch (err) {
|
|
|
|
assert.ok(err, 'did throw error')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|