Changes of Linux canary v0.0.86

This commit is contained in:
root 2019-07-24 13:23:41 +02:00
parent e6d20ce28b
commit 5db4a0fd1e
9 changed files with 38 additions and 41 deletions

View file

@ -1,6 +1,9 @@
'use strict';
const { EventEmitter } = require('events');
const { deprecate } = require('electron');
const { Tray } = process.electronBinding('tray');
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype);
// Deprecations
Tray.prototype.setHighlightMode = deprecate.removeFunction(Tray.prototype.setHighlightMode, 'setHighlightMode');
module.exports = Tray;
//# sourceMappingURL=tray.js.map

View file

@ -143,20 +143,23 @@ const getGuestWindow = function (guestContents) {
}
return guestWindow;
};
const isChildWindow = function (sender, target) {
return target.getLastWebPreferences().openerId === sender.id;
};
const isRelatedWindow = function (sender, target) {
return isChildWindow(sender, target) || isChildWindow(target, sender);
};
const isScriptableWindow = function (sender, target) {
return isRelatedWindow(sender, target) && isSameOrigin(sender.getURL(), target.getURL());
};
const isNodeIntegrationEnabled = function (sender) {
return sender.getLastWebPreferences().nodeIntegration === true;
};
// Checks whether |sender| can access the |target|:
// 1. Check whether |sender| is the parent of |target|.
// 2. Check whether |sender| has node integration, if so it is allowed to
// do anything it wants.
// 3. Check whether the origins match.
//
// However it allows a child window without node integration but with same
// origin to do anything it wants, when its opener window has node integration.
// The W3C does not have anything on this, but from my understanding of the
// security model of |window.opener|, this should be fine.
const canAccessWindow = function (sender, target) {
return (target.getLastWebPreferences().openerId === sender.id) ||
(sender.getLastWebPreferences().nodeIntegration === true) ||
isSameOrigin(sender.getURL(), target.getURL());
return isChildWindow(sender, target) ||
isScriptableWindow(sender, target) ||
isNodeIntegrationEnabled(sender);
};
// Routed window.open messages with raw options
ipcMainInternal.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, url, frameName, features) => {

View file

@ -2,7 +2,6 @@
const electron = require('electron');
const { EventEmitter } = require('events');
const fs = require('fs');
const path = require('path');
const util = require('util');
const v8Util = process.electronBinding('v8_util');
const eventBinding = process.electronBinding('event');
@ -16,7 +15,6 @@ const guestViewManager = require('@electron/internal/browser/guest-view-manager'
const bufferUtils = require('@electron/internal/common/buffer-utils');
const errorUtils = require('@electron/internal/common/error-utils');
const clipboardUtils = require('@electron/internal/common/clipboard-utils');
const { isParentDir } = require('@electron/internal/common/path-utils');
const hasProp = {}.hasOwnProperty;
// The internal properties of Function.
const FUNCTION_PROPERTIES = [
@ -446,22 +444,11 @@ ipcMainUtils.handle('ELECTRON_BROWSER_CLIPBOARD', function (event, method, ...ar
return clipboardUtils.serialize(electron.clipboard[method](...clipboardUtils.deserialize(args)));
});
const readFile = util.promisify(fs.readFile);
const realpath = util.promisify(fs.realpath);
let absoluteAppPath;
const getAppPath = async function () {
if (absoluteAppPath === undefined) {
absoluteAppPath = await realpath(electron.app.getAppPath());
}
return absoluteAppPath;
};
const getPreloadScript = async function (preloadPath) {
let preloadSrc = null;
let preloadError = null;
if (preloadPath) {
try {
if (!isParentDir(await getAppPath(), await realpath(preloadPath))) {
throw new Error('Preload scripts outside of app path are not allowed');
}
preloadSrc = (await readFile(preloadPath)).toString();
}
catch (err) {

View file

@ -35,9 +35,21 @@ const deprecate = {
return console.warn(`(electron) ${message}`);
}
},
// remove a function with no replacement
removeFunction: (fn, removedName) => {
if (!fn) {
throw Error(`'${removedName} function' is invalid or does not exist.`);
}
// wrap the deprecated function to warn user
const warn = warnOnce(`${fn.name} function`);
return function () {
warn();
fn.apply(this, arguments);
};
},
// change the name of a function
function: (fn, newName) => {
const warn = warnOnce(fn.name, newName);
renameFunction: (fn, newName) => {
const warn = warnOnce(`${fn.name} function`, `${newName} function`);
return function () {
warn();
fn.apply(this, arguments);

View file

@ -1,8 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
exports.isParentDir = function (parent, dir) {
const relative = path.relative(parent, dir);
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
};
//# sourceMappingURL=path-utils.js.map

View file

@ -2,7 +2,6 @@
// Public-facing API methods.
exports.syncMethods = new Set([
'getURL',
'loadURL',
'getTitle',
'isLoading',
'isLoadingMainFrame',
@ -62,6 +61,7 @@ exports.asyncCallbackMethods = new Set([
'print'
]);
exports.asyncPromiseMethods = new Set([
'loadURL',
'capturePage',
'executeJavaScript',
'printToPDF'

View file

@ -33,7 +33,7 @@ class Port {
});
ipc_renderer_internal_1.ipcRendererInternal.on(`CHROME_PORT_POSTMESSAGE_${portId}`, (_event, message) => {
const sendResponse = function () { console.error('sendResponse is not implemented'); };
this.onMessage.emit(message, this.sender, sendResponse);
this.onMessage.emit(JSON.parse(message), this.sender, sendResponse);
});
}
disconnect() {
@ -43,7 +43,7 @@ class Port {
this._onDisconnect();
}
postMessage(message) {
ipc_renderer_internal_1.ipcRendererInternal.sendToAll(this.tabId, `CHROME_PORT_POSTMESSAGE_${this.portId}`, message);
ipc_renderer_internal_1.ipcRendererInternal.sendToAll(this.tabId, `CHROME_PORT_POSTMESSAGE_${this.portId}`, JSON.stringify(message));
}
_onDisconnect() {
this.disconnected = true;

View file

@ -12,9 +12,9 @@ exports.ipcRendererInternal.sendSync = function (channel, ...args) {
return binding.ipc.sendSync(internal, channel, args)[0];
};
exports.ipcRendererInternal.sendTo = function (webContentsId, channel, ...args) {
return binding.sendTo(internal, false, webContentsId, channel, args);
return binding.ipc.sendTo(internal, false, webContentsId, channel, args);
};
exports.ipcRendererInternal.sendToAll = function (webContentsId, channel, ...args) {
return binding.sendTo(internal, true, webContentsId, channel, args);
return binding.ipc.sendTo(internal, true, webContentsId, channel, args);
};
//# sourceMappingURL=ipc-renderer-internal.js.map

View file

@ -168,7 +168,7 @@ class SrcAttribute extends WebViewAttribute {
const guestInstanceId = this.webViewImpl.guestInstanceId;
const method = 'loadURL';
const args = [this.getValue(), opts];
ipcRendererUtils.invokeSync('ELECTRON_GUEST_VIEW_MANAGER_CALL', guestInstanceId, method, args);
ipcRendererUtils.invoke('ELECTRON_GUEST_VIEW_MANAGER_CALL', guestInstanceId, method, args);
}
}
// Attribute specifies HTTP referrer.