Merge branch 'master' into native-window-open

This commit is contained in:
Ryohei Ikegami 2017-03-23 23:53:13 +09:00
commit 6f9dbd4e04
50 changed files with 517 additions and 102 deletions

View file

@ -144,7 +144,7 @@ Menu.prototype._init = function () {
}
Menu.prototype.popup = function (window, x, y, positioningItem) {
let asyncPopup = false
let asyncPopup
// menu.popup(x, y, positioningItem)
if (window != null && (typeof window !== 'object' || window.constructor !== BrowserWindow)) {
@ -174,6 +174,9 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
// Default to not highlighting any item.
if (typeof positioningItem !== 'number') positioningItem = -1
// Default to synchronous for backwards compatibility.
if (typeof asyncPopup !== 'boolean') asyncPopup = false
this.popupAt(window, x, y, positioningItem, asyncPopup)
}

View file

@ -179,7 +179,15 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) {
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
return target[property]
const value = target[property]
// Bind toString to target if it is a function to avoid
// Function.prototype.toString is not generic errors
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)
}
return value
},
ownKeys: (target) => {
loadRemoteProperties()

View file

@ -6,7 +6,7 @@ const Module = require('module')
const resolvePromise = Promise.resolve.bind(Promise)
// We modified the original process.argv to let node.js load the
// atom-renderer.js, we need to restore it here.
// init.js, we need to restore it here.
process.argv.splice(1, 1)
// Clear search paths.

37
lib/worker/init.js Normal file
View file

@ -0,0 +1,37 @@
'use strict'
const path = require('path')
const Module = require('module')
// We modified the original process.argv to let node.js load the
// init.js, we need to restore it here.
process.argv.splice(1, 1)
// Clear search paths.
require('../common/reset-search-paths')
// Import common settings.
require('../common/init')
// Expose public APIs.
Module.globalPaths.push(path.join(__dirname, 'api', 'exports'))
// Export node bindings to global.
global.require = require
global.module = module
// Set the __filename to the path of html file if it is file: protocol.
if (self.location.protocol === 'file:') {
let pathname = process.platform === 'win32' && self.location.pathname[0] === '/' ? self.location.pathname.substr(1) : self.location.pathname
global.__filename = path.normalize(decodeURIComponent(pathname))
global.__dirname = path.dirname(global.__filename)
// Set module's filename so relative require can work as expected.
module.filename = global.__filename
// Also search for module under the html file.
module.paths = module.paths.concat(Module._nodeModulePaths(global.__dirname))
} else {
global.__filename = __filename
global.__dirname = __dirname
}