From: Kevin Sawicki Date: Tue, 13 Dec 2016 19:47:54 +0000 (-0800) Subject: Add initial isolated world spec X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2928fe5c439ddf9d0e350dfef71015e9db05034a;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add initial isolated world spec --- diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index ab5d6d2..2dd7fc8 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1835,6 +1835,39 @@ describe('BrowserWindow module', function () { }) }) + describe('isolated option', () => { + it('separates the page context from the Electron/preload context', (done) => { + if (w != null) w.destroy() + + ipcMain.once('isolated-world', (event, data) => { + assert.deepEqual(data, { + preloadContext: { + preloadProperty: 'number', + pageProperty: 'undefined', + typeofRequire: 'function', + typeofProcess: 'object' + }, + pageContext: { + preloadProperty: 'undefined', + pageProperty: 'string', + typeofRequire: 'undefined', + typeofProcess: 'undefined' + } + }) + done() + }) + + w = new BrowserWindow({ + show: false, + webPreferences: { + isolated: true, + preload: path.join(fixtures, 'api', 'isolated-preload.js') + } + }) + w.loadURL('file://' + fixtures + '/api/isolated.html') + }) + }) + describe('offscreen rendering', function () { beforeEach(function () { if (w != null) w.destroy() diff --git a/spec/fixtures/api/isolated-preload.js b/spec/fixtures/api/isolated-preload.js new file mode 100644 index 0000000..8cb80d3 --- /dev/null +++ b/spec/fixtures/api/isolated-preload.js @@ -0,0 +1,15 @@ +const {ipcRenderer} = require('electron') + +window.foo = 3 + +window.addEventListener('message', (event) => { + ipcRenderer.send('isolated-world', { + preloadContext: { + preloadProperty: typeof window.foo, + pageProperty: typeof window.hello, + typeofRequire: typeof require, + typeofProcess: typeof process + }, + pageContext: event.data + }) +}) diff --git a/spec/fixtures/api/isolated.html b/spec/fixtures/api/isolated.html new file mode 100644 index 0000000..bb0aca9 --- /dev/null +++ b/spec/fixtures/api/isolated.html @@ -0,0 +1,19 @@ + + + + + Isolated World + + + + + +