diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 50c6a62eb0c..bdd32af7a61 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -101,8 +101,8 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function(event, guest ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() { var args, guestId, method, ref1; - guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; - return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0; + event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; + return event.returnValue = (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0; }); ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function(event, guestId, message, targetOrigin, sourceOrigin) { diff --git a/lib/renderer/override.js b/lib/renderer/override.js index 2b0e48b3dd3..6717db931dc 100644 --- a/lib/renderer/override.js +++ b/lib/renderer/override.js @@ -57,6 +57,15 @@ var BrowserWindowProxy = (function() { return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'blur'); }; + Object.defineProperty(BrowserWindowProxy.prototype, 'location', { + get: function() { + return ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'getURL'); + }, + set: function(url) { + return ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'loadURL', url); + } + }); + BrowserWindowProxy.prototype.postMessage = function(message, targetOrigin) { if (targetOrigin == null) { targetOrigin = '*'; diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 67b2d263204..71cef125618 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -193,6 +193,32 @@ describe('chromium feature', function() { window.addEventListener('message', listener); b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', "show=no,width=" + size.width + ",height=" + size.height); }); + + it('defines a window.location getter', function(done) { + var b, targetURL; + targetURL = "file://" + fixtures + "/pages/base-page.html"; + b = window.open(targetURL); + BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() { + assert.equal(b.location, targetURL); + b.close(); + done(); + }); + }); + + it('defines a window.location setter', function(done) { + // Load a page that definitely won't redirect + var b; + b = window.open("about:blank"); + BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() { + // When it loads, redirect + b.location = "file://" + fixtures + "/pages/base-page.html"; + BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() { + // After our second redirect, cleanup and callback + b.close(); + done(); + }); + }); + }); }); describe('window.opener', function() {