Merge pull request #9252 from electron/convert-to-string-in-render-process
Convert alert/confirm arguments to strings in render process
This commit is contained in:
commit
2e223288d2
2 changed files with 26 additions and 2 deletions
|
@ -121,11 +121,11 @@ module.exports = (ipcRenderer, guestInstanceId, openerId, hiddenPage) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.alert = function (message, title) {
|
window.alert = function (message, title) {
|
||||||
ipcRenderer.sendSync('ELECTRON_BROWSER_WINDOW_ALERT', message, title)
|
ipcRenderer.sendSync('ELECTRON_BROWSER_WINDOW_ALERT', `${message}`, `${title}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.confirm = function (message, title) {
|
window.confirm = function (message, title) {
|
||||||
return ipcRenderer.sendSync('ELECTRON_BROWSER_WINDOW_CONFIRM', message, title)
|
return ipcRenderer.sendSync('ELECTRON_BROWSER_WINDOW_CONFIRM', `${message}`, `${title}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// But we do not support prompt().
|
// But we do not support prompt().
|
||||||
|
|
|
@ -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/)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue