From 9c92f2e692909bfc9cadfcf27a646e2d051f4d51 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 27 Oct 2014 19:26:45 +0800 Subject: [PATCH] spec: "new-window" event of --- spec/fixtures/pages/target-name.html | 13 +++++++++++++ spec/fixtures/pages/window-open.html | 7 +++++++ spec/webview-spec.coffee | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 spec/fixtures/pages/target-name.html create mode 100644 spec/fixtures/pages/window-open.html diff --git a/spec/fixtures/pages/target-name.html b/spec/fixtures/pages/target-name.html new file mode 100644 index 000000000000..0dc760d233f5 --- /dev/null +++ b/spec/fixtures/pages/target-name.html @@ -0,0 +1,13 @@ + + +link + + + diff --git a/spec/fixtures/pages/window-open.html b/spec/fixtures/pages/window-open.html new file mode 100644 index 000000000000..94a7202db7c4 --- /dev/null +++ b/spec/fixtures/pages/window-open.html @@ -0,0 +1,7 @@ + + + + + diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index fa533c5777d8..09c7709c08be 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -46,3 +46,20 @@ describe ' tag', -> webview.setAttribute 'nodeintegration', 'on' webview.src = "file://#{fixtures}/pages/d.html" document.body.appendChild webview + + describe 'new-window event', -> + it 'emits when window.open is called', (done) -> + webview.addEventListener 'new-window', (e) -> + assert.equal e.url, 'http://host' + assert.equal e.frameName, 'host' + done() + webview.src = "file://#{fixtures}/pages/window-open.html" + document.body.appendChild webview + + it 'emits when link with target is called', (done) -> + webview.addEventListener 'new-window', (e) -> + assert.equal e.url, 'http://host/' + assert.equal e.frameName, 'target' + done() + webview.src = "file://#{fixtures}/pages/target-name.html" + document.body.appendChild webview