diff --git a/spec/fixtures/pages/target-name.html b/spec/fixtures/pages/target-name.html new file mode 100644 index 000000000..0dc760d23 --- /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 000000000..94a7202db --- /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 fa533c577..09c7709c0 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