From eaacf0a6ef3ec9dcf24290bcd5483546551b5dcf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 17 Dec 2014 15:03:34 -0800 Subject: [PATCH] spec: "will-navigate" event --- spec/api-browser-window-spec.coffee | 8 ++++++++ spec/fixtures/pages/will-navigate.html | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 spec/fixtures/pages/will-navigate.html diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 5bf3adcbe116..fa4432b8df35 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -208,3 +208,11 @@ describe 'browser-window module', -> w.once 'minimize', -> done() w.show() w.minimize() + + describe 'will-navigate event', -> + it 'emits when user starts a navigation', (done) -> + w.webContents.on 'will-navigate', (event, url) -> + event.preventDefault() + assert.equal url, 'https://www.github.com/' + done() + w.loadUrl "file://#{fixtures}/pages/will-navigate.html" diff --git a/spec/fixtures/pages/will-navigate.html b/spec/fixtures/pages/will-navigate.html new file mode 100644 index 000000000000..bd2ebdc1cb43 --- /dev/null +++ b/spec/fixtures/pages/will-navigate.html @@ -0,0 +1,7 @@ + + + + +