diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 79dbaa435e85..c81e1731d5ae 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -136,6 +136,16 @@ describe 'browser-window module', -> assert.equal after[0], size.width assert.equal after[1], size.height + describe '"preload" options', -> + it 'loads the script before other scripts in window', (done) -> + preload = path.join fixtures, 'module', 'set-global.js' + remote.require('ipc').once 'preload', (event, test) -> + assert.equal(test, 'preload') + done() + w.destroy() + w = new BrowserWindow(show: false, width: 400, height: 400, preload: preload) + w.loadUrl 'file://' + path.join(fixtures, 'api', 'preload.html') + describe 'beforeunload handler', -> it 'returning true would not prevent close', (done) -> w.on 'closed', -> diff --git a/spec/fixtures/api/preload.html b/spec/fixtures/api/preload.html new file mode 100644 index 000000000000..22dee23444fa --- /dev/null +++ b/spec/fixtures/api/preload.html @@ -0,0 +1,9 @@ + + + + + diff --git a/spec/fixtures/module/set-global.js b/spec/fixtures/module/set-global.js new file mode 100644 index 000000000000..f39919ff9d8f --- /dev/null +++ b/spec/fixtures/module/set-global.js @@ -0,0 +1 @@ +window.test = 'preload';