From 64ce44d3418494afddbc8a471e2bad6d1ce2b7b2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 27 Oct 2014 22:07:57 +0800 Subject: [PATCH] spec: "new-window" event of BrowserWindow --- spec/api-browser-window-spec.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index fa3b69df55e5..79dbaa435e85 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -156,3 +156,20 @@ describe 'browser-window module', -> w.on 'onbeforeunload', -> done() w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html') + + describe 'new-window event', -> + it 'emits when window.open is called', (done) -> + w.webContents.once 'new-window', (e, url, frameName) -> + e.preventDefault() + assert.equal url, 'http://host' + assert.equal frameName, 'host' + done() + w.loadUrl "file://#{fixtures}/pages/window-open.html" + + it 'emits when link with target is called', (done) -> + w.webContents.once 'new-window', (e, url, frameName) -> + e.preventDefault() + assert.equal url, 'http://host/' + assert.equal frameName, 'target' + done() + w.loadUrl "file://#{fixtures}/pages/target-name.html"