Added support for window.location on window.open windows
This commit is contained in:
Родитель
b10f196d16
Коммит
7569d180c9
|
@ -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) {
|
||||
|
|
|
@ -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 = '*';
|
||||
|
|
|
@ -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() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче