spec: Test beforeunload handler in webview
This commit is contained in:
parent
817dfbdc27
commit
36d2512ff8
2 changed files with 28 additions and 0 deletions
13
spec/fixtures/pages/beforeunload-false.html
vendored
Normal file
13
spec/fixtures/pages/beforeunload-false.html
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
var ipc = require('ipc');
|
||||
ipc.sendToHost('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -178,3 +178,18 @@ describe '<webview> tag', ->
|
|||
done()
|
||||
webview.src = "file://#{fixtures}/pages/a.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe '<webview>.reload()', ->
|
||||
it 'should emit beforeunload handler', (done) ->
|
||||
webview.addEventListener 'did-finish-load', (e) ->
|
||||
webview.reload()
|
||||
listener = (e) ->
|
||||
assert.equal e.channel, 'onbeforeunload'
|
||||
webview.removeEventListener 'ipc-message', listener
|
||||
done()
|
||||
webview.addEventListener 'console-message', (e) ->
|
||||
console.log(e)
|
||||
webview.addEventListener 'ipc-message', listener
|
||||
webview.setAttribute 'nodeintegration', 'on'
|
||||
webview.src = "file://#{fixtures}/pages/beforeunload-false.html"
|
||||
document.body.appendChild webview
|
||||
|
|
Loading…
Reference in a new issue