Add spec for alert/confirm toString errors

This commit is contained in:
Kevin Sawicki 2017-04-21 12:19:37 -07:00
parent c146f8a308
commit a00d36fb07

View file

@ -880,4 +880,28 @@ describe('chromium feature', function () {
})
})
})
describe('window.alert(message, title)', function () {
it('throws an exception when the arguments cannot be converted to strings', function () {
assert.throws(function () {
window.alert({toString: null})
}, /Cannot convert object to primitive value/)
assert.throws(function () {
window.alert('message', {toString: 3})
}, /Cannot convert object to primitive value/)
})
})
describe('window.confirm(message, title)', function () {
it('throws an exception when the arguments cannot be converted to strings', function () {
assert.throws(function () {
window.confirm({toString: null}, 'title')
}, /Cannot convert object to primitive value/)
assert.throws(function () {
window.confirm('message', {toString: 3})
}, /Cannot convert object to primitive value/)
})
})
})