From 36d2512ff88cbb11ee02c4500eaafc072377307f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 1 May 2015 13:48:23 +0800 Subject: [PATCH] spec: Test beforeunload handler in webview --- spec/fixtures/pages/beforeunload-false.html | 13 +++++++++++++ spec/webview-spec.coffee | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 spec/fixtures/pages/beforeunload-false.html diff --git a/spec/fixtures/pages/beforeunload-false.html b/spec/fixtures/pages/beforeunload-false.html new file mode 100644 index 000000000000..7ae4edf4ce29 --- /dev/null +++ b/spec/fixtures/pages/beforeunload-false.html @@ -0,0 +1,13 @@ + + + + + diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index 51058ad695e9..92a77351ee68 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -178,3 +178,18 @@ describe ' tag', -> done() webview.src = "file://#{fixtures}/pages/a.html" document.body.appendChild webview + + describe '.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