Use require('electron') in Electron's code
This commit is contained in:
parent
f9d7e7ce55
commit
1d1f911b09
71 changed files with 265 additions and 250 deletions
|
@ -1,5 +1,5 @@
|
|||
deprecate = require 'deprecate'
|
||||
EventEmitter = require('events').EventEmitter
|
||||
electron = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
bindings = process.atomBinding 'app'
|
||||
sessionBindings = process.atomBinding 'session'
|
||||
|
@ -9,10 +9,10 @@ app = bindings.app
|
|||
app.__proto__ = EventEmitter.prototype
|
||||
|
||||
app.setApplicationMenu = (menu) ->
|
||||
require('menu').setApplicationMenu menu
|
||||
electron.menu.setApplicationMenu menu
|
||||
|
||||
app.getApplicationMenu = ->
|
||||
require('menu').getApplicationMenu()
|
||||
electron.menu.getApplicationMenu()
|
||||
|
||||
app.commandLine =
|
||||
appendSwitch: bindings.appendSwitch,
|
||||
|
@ -39,6 +39,7 @@ app.getAppPath = ->
|
|||
app.resolveProxy = (url, callback) -> @defaultSession.resolveProxy url, callback
|
||||
|
||||
# Deprecated.
|
||||
{deprecate} = electron
|
||||
app.getHomeDir = deprecate 'app.getHomeDir', 'app.getPath', ->
|
||||
@getPath 'home'
|
||||
app.getDataPath = deprecate 'app.getDataPath', 'app.getPath', ->
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
app = require 'app'
|
||||
ipc = require 'ipc-main'
|
||||
deprecate = require 'deprecate'
|
||||
{app, ipcMain, deprecate} = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
||||
BrowserWindow::__proto__ = EventEmitter.prototype
|
||||
|
@ -15,7 +13,7 @@ BrowserWindow::_init = ->
|
|||
# Make new windows requested by links behave like "window.open"
|
||||
@webContents.on '-new-window', (event, url, frameName) ->
|
||||
options = show: true, width: 800, height: 600
|
||||
ipc.emit 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options
|
||||
ipcMain.emit 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options
|
||||
|
||||
# window.resizeTo(...)
|
||||
# window.moveTo(...)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{app, BrowserWindow} = require 'electron'
|
||||
|
||||
binding = process.atomBinding 'dialog'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
app = require 'app'
|
||||
BrowserWindow = require 'browser-window'
|
||||
|
||||
fileDialogProperties =
|
||||
openFile: 1 << 0
|
||||
|
|
|
@ -45,3 +45,8 @@ Object.defineProperties module.exports,
|
|||
tray:
|
||||
enumerable: true
|
||||
get: -> require '../tray'
|
||||
# The internal modules, invisible unless you know their names.
|
||||
NavigationController:
|
||||
get: -> require '../navigation-controller'
|
||||
webContents:
|
||||
get: -> require '../web-contents'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
bindings = process.atomBinding 'global_shortcut'
|
||||
|
||||
globalShortcut = bindings.globalShortcut
|
||||
{globalShortcut} = process.atomBinding 'global_shortcut'
|
||||
|
||||
module.exports = globalShortcut
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
deprecate = require 'deprecate'
|
||||
{deprecate, ipcMain} = require 'electron'
|
||||
|
||||
# This module is deprecated, we mirror everything from ipcMain.
|
||||
deprecate.warn 'ipc module', 'ipcMain module'
|
||||
|
||||
module.exports = require 'ipc-main'
|
||||
module.exports = ipcMain
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
BrowserWindow = require 'browser-window'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
nextCommandId = 0
|
||||
|
@ -18,7 +17,7 @@ class MenuItem
|
|||
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
|
||||
|
||||
constructor: (options) ->
|
||||
Menu = require 'menu'
|
||||
{Menu} = require 'electron'
|
||||
|
||||
{click, @selector, @type, @role, @label, @sublabel, @accelerator, @icon, @enabled, @visible, @checked, @submenu} = options
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
BrowserWindow = require 'browser-window'
|
||||
EventEmitter = require('events').EventEmitter
|
||||
MenuItem = require 'menu-item'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
{BrowserWindow, MenuItem} = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
bindings = process.atomBinding 'menu'
|
||||
|
||||
# Automatically generated radio menu item's group id.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
ipc = require 'ipc-main'
|
||||
{ipcMain} = require 'electron'
|
||||
|
||||
# The history operation in renderer is redirected to browser.
|
||||
ipc.on 'ATOM_SHELL_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||
ipcMain.on 'ATOM_SHELL_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||
event.sender[method] args...
|
||||
|
||||
ipc.on 'ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||
ipcMain.on 'ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||
event.returnValue = event.sender[method] args...
|
||||
|
||||
# JavaScript implementation of Chromium's NavigationController.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
powerMonitor = process.atomBinding('power_monitor').powerMonitor
|
||||
EventEmitter = require('events').EventEmitter
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
{powerMonitor} = process.atomBinding 'power_monitor'
|
||||
|
||||
powerMonitor.__proto__ = EventEmitter.prototype
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
bindings = process.atomBinding 'power_save_blocker'
|
||||
{powerSaveBlocker} = process.atomBinding 'power_save_blocker'
|
||||
|
||||
module.exports = bindings.powerSaveBlocker
|
||||
module.exports = powerSaveBlocker
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
app = require 'app'
|
||||
{app} = require 'electron'
|
||||
|
||||
throw new Error('Can not initialize protocol module before app is ready') unless app.isReady()
|
||||
|
||||
protocol = process.atomBinding('protocol').protocol
|
||||
{protocol} = process.atomBinding 'protocol'
|
||||
|
||||
# Warn about removed APIs.
|
||||
logAndThrow = (callback, message) ->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
{EventEmitter} = require 'events'
|
||||
{screen} = process.atomBinding 'screen'
|
||||
|
||||
screen = process.atomBinding('screen').screen
|
||||
screen.__proto__ = EventEmitter.prototype
|
||||
|
||||
module.exports = screen
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
bindings = process.atomBinding 'tray'
|
||||
{EventEmitter} = require 'events'
|
||||
{Tray} = process.atomBinding 'tray'
|
||||
|
||||
Tray = bindings.Tray
|
||||
Tray::__proto__ = EventEmitter.prototype
|
||||
|
||||
Tray::setContextMenu = (menu) ->
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
Menu = require './menu'
|
||||
NavigationController = require './navigation-controller'
|
||||
{EventEmitter} = require 'events'
|
||||
{ipcMain, NavigationController, Menu} = require 'electron'
|
||||
|
||||
binding = process.atomBinding 'web_contents'
|
||||
ipc = require 'ipc-main'
|
||||
|
||||
nextId = 0
|
||||
getNextId = -> ++nextId
|
||||
|
@ -60,11 +59,11 @@ wrapWebContents = (webContents) ->
|
|||
# Dispatch IPC messages to the ipc module.
|
||||
webContents.on 'ipc-message', (event, packed) ->
|
||||
[channel, args...] = packed
|
||||
ipc.emit channel, event, args...
|
||||
ipcMain.emit channel, event, args...
|
||||
webContents.on 'ipc-message-sync', (event, packed) ->
|
||||
[channel, args...] = packed
|
||||
Object.defineProperty event, 'returnValue', set: (value) -> event.sendReply JSON.stringify(value)
|
||||
ipc.emit channel, event, args...
|
||||
ipcMain.emit channel, event, args...
|
||||
|
||||
# Handle context menu action request from pepper plugin.
|
||||
webContents.on 'pepper-context-menu', (event, params) ->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var app = require('app');
|
||||
var BrowserWindow = require('browser-window');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
var mainWindow = null;
|
||||
|
||||
|
|
|
@ -57,13 +57,17 @@
|
|||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var execPath = require('remote').process.execPath;
|
||||
const electron = require('electron');
|
||||
const remote = electron.remote;
|
||||
const shell = electron.shell;
|
||||
|
||||
var execPath = remote.process.execPath;
|
||||
var command = execPath + ' path-to-your-app';
|
||||
|
||||
document.onclick = function(e) {
|
||||
e.preventDefault();
|
||||
if (e.target.tagName == 'A')
|
||||
require('shell').openExternal(e.target.href);
|
||||
shell.openExternal(e.target.href);
|
||||
return false;
|
||||
};
|
||||
document.ondragover = document.ondrop = function(e) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
var app = require('app');
|
||||
var dialog = require('dialog');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const dialog = electron.dialog;
|
||||
const shell = electron.shell;
|
||||
const Menu = electron.Menu;
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var Menu = require('menu');
|
||||
var BrowserWindow = require('browser-window');
|
||||
|
||||
// Quit when all windows are closed and no other one is listening to this.
|
||||
app.on('window-all-closed', function() {
|
||||
|
@ -142,19 +144,19 @@ app.once('ready', function() {
|
|||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: function() { require('shell').openExternal('http://electron.atom.io') }
|
||||
click: function() { shell.openExternal('http://electron.atom.io') }
|
||||
},
|
||||
{
|
||||
label: 'Documentation',
|
||||
click: function() { require('shell').openExternal('https://github.com/atom/electron/tree/master/docs#readme') }
|
||||
click: function() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme') }
|
||||
},
|
||||
{
|
||||
label: 'Community Discussions',
|
||||
click: function() { require('shell').openExternal('https://discuss.atom.io/c/electron') }
|
||||
click: function() { shell.openExternal('https://discuss.atom.io/c/electron') }
|
||||
},
|
||||
{
|
||||
label: 'Search Issues',
|
||||
click: function() { require('shell').openExternal('https://github.com/atom/electron/issues') }
|
||||
click: function() { shell.openExternal('https://github.com/atom/electron/issues') }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -269,5 +271,5 @@ if (option.file && !option.webdriver) {
|
|||
console.log(helpMessage);
|
||||
process.exit(0);
|
||||
} else {
|
||||
require('./default_app.js');
|
||||
require('./default_app');
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
app = require 'app'
|
||||
electron = require 'electron'
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
url = require 'url'
|
||||
|
@ -40,6 +40,7 @@ loadedExtensions = null
|
|||
loadedExtensionsPath = null
|
||||
|
||||
# Persistent loaded extensions.
|
||||
{app} = electron
|
||||
app.on 'will-quit', ->
|
||||
try
|
||||
loadedExtensions = Object.keys(extensionInfoMap).map (key) -> extensionInfoMap[key].srcDirectory
|
||||
|
@ -51,8 +52,7 @@ app.on 'will-quit', ->
|
|||
|
||||
# We can not use protocol or BrowserWindow until app is ready.
|
||||
app.once 'ready', ->
|
||||
protocol = require 'protocol'
|
||||
BrowserWindow = require 'browser-window'
|
||||
{protocol, BrowserWindow} = electron
|
||||
|
||||
# Load persistented extensions.
|
||||
loadedExtensionsPath = path.join app.getPath('userData'), 'DevTools Extensions'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
ipc = require 'ipc-main'
|
||||
webContents = require 'web-contents'
|
||||
{ipcMain, webContents} = require 'electron'
|
||||
|
||||
webViewManager = null # Doesn't exist in early initialization.
|
||||
|
||||
supportedWebViewEvents = [
|
||||
|
@ -140,19 +140,19 @@ destroyGuest = (embedder, id) ->
|
|||
delete reverseEmbedderElementsMap[id]
|
||||
delete embedderElementsMap[key]
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', (event, params, requestId) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', (event, params, requestId) ->
|
||||
event.sender.send "ATOM_SHELL_RESPONSE_#{requestId}", createGuest(event.sender, params)
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', (event, elementInstanceId, guestInstanceId, params) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', (event, elementInstanceId, guestInstanceId, params) ->
|
||||
attachGuest event.sender, elementInstanceId, guestInstanceId, params
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', (event, id) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', (event, id) ->
|
||||
destroyGuest event.sender, id
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', (event, id, params) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', (event, id, params) ->
|
||||
guestInstances[id]?.guest.setSize params
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', (event, id, allowtransparency) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', (event, id, allowtransparency) ->
|
||||
guestInstances[id]?.guest.setAllowTransparency allowtransparency
|
||||
|
||||
# Returns WebContents from its guest id.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
ipc = require 'ipc-main'
|
||||
{ipcMain, BrowserWindow} = require 'electron'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
BrowserWindow = require 'browser-window'
|
||||
|
||||
frameToGuest = {}
|
||||
|
||||
|
@ -58,7 +57,7 @@ createGuest = (embedder, url, frameName, options) ->
|
|||
guest.id
|
||||
|
||||
# Routed window.open messages.
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) ->
|
||||
[url, frameName, options] = args
|
||||
options = mergeBrowserWindowOptions event.sender, options
|
||||
event.sender.emit 'new-window', event, url, frameName, 'new-window', options
|
||||
|
@ -67,26 +66,26 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) ->
|
|||
else
|
||||
event.returnValue = createGuest event.sender, url, frameName, options
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', (event, guestId) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', (event, guestId) ->
|
||||
BrowserWindow.fromId(guestId)?.destroy()
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', (event, guestId, method, args...) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', (event, guestId, method, args...) ->
|
||||
BrowserWindow.fromId(guestId)?[method] args...
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, message, targetOrigin) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, message, targetOrigin) ->
|
||||
guestContents = BrowserWindow.fromId(guestId)?.webContents
|
||||
if guestContents?.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*'
|
||||
guestContents.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', guestId, message, targetOrigin
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, guestId, message, targetOrigin, sourceOrigin) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, guestId, message, targetOrigin, sourceOrigin) ->
|
||||
embedder = v8Util.getHiddenValue event.sender, 'embedder'
|
||||
if embedder?.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*'
|
||||
embedder.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', guestId, message, sourceOrigin
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', (event, guestId, method, args...) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', (event, guestId, method, args...) ->
|
||||
BrowserWindow.fromId(guestId)?.webContents?[method] args...
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID', (event) ->
|
||||
ipcMain.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID', (event) ->
|
||||
embedder = v8Util.getHiddenValue event.sender, 'embedder'
|
||||
if embedder?
|
||||
guest = BrowserWindow.fromWebContents event.sender
|
||||
|
|
|
@ -46,12 +46,13 @@ process.on 'uncaughtException', (error) ->
|
|||
return
|
||||
|
||||
# Show error in GUI.
|
||||
{dialog} = require 'electron'
|
||||
stack = error.stack ? "#{error.name}: #{error.message}"
|
||||
message = "Uncaught Exception:\n#{stack}"
|
||||
require('dialog').showErrorBox 'A JavaScript error occurred in the main process', message
|
||||
dialog.showErrorBox 'A JavaScript error occurred in the main process', message
|
||||
|
||||
# Emit 'exit' event on quit.
|
||||
app = require 'app'
|
||||
{app} = require 'electron'
|
||||
app.on 'quit', ->
|
||||
process.emit 'exit'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
{EventEmitter} = require 'events'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
class ObjectsRegistry extends EventEmitter
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
ipc = require 'ipc-main'
|
||||
{ipcMain} = require 'electron'
|
||||
path = require 'path'
|
||||
objectsRegistry = require './objects-registry.js'
|
||||
objectsRegistry = require './objects-registry'
|
||||
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap
|
||||
{IDWeakMap} = process.atomBinding 'id_weak_map'
|
||||
|
||||
# Convert a real value into meta data.
|
||||
valueToMeta = (sender, value, optimizeSimpleObject=false) ->
|
||||
|
@ -115,28 +116,28 @@ callFunction = (event, func, caller, args) ->
|
|||
process.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (id) ->
|
||||
objectsRegistry.clear id
|
||||
|
||||
ipc.on 'ATOM_BROWSER_REQUIRE', (event, module) ->
|
||||
ipcMain.on 'ATOM_BROWSER_REQUIRE', (event, module) ->
|
||||
try
|
||||
event.returnValue = valueToMeta event.sender, process.mainModule.require(module)
|
||||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_GLOBAL', (event, name) ->
|
||||
ipcMain.on 'ATOM_BROWSER_GLOBAL', (event, name) ->
|
||||
try
|
||||
event.returnValue = valueToMeta event.sender, global[name]
|
||||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event) ->
|
||||
ipcMain.on 'ATOM_BROWSER_CURRENT_WINDOW', (event) ->
|
||||
try
|
||||
event.returnValue = valueToMeta event.sender, event.sender.getOwnerBrowserWindow()
|
||||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_CURRENT_WEB_CONTENTS', (event) ->
|
||||
ipcMain.on 'ATOM_BROWSER_CURRENT_WEB_CONTENTS', (event) ->
|
||||
event.returnValue = valueToMeta event.sender, event.sender
|
||||
|
||||
ipc.on 'ATOM_BROWSER_CONSTRUCTOR', (event, id, args) ->
|
||||
ipcMain.on 'ATOM_BROWSER_CONSTRUCTOR', (event, id, args) ->
|
||||
try
|
||||
args = unwrapArgs event.sender, args
|
||||
constructor = objectsRegistry.get id
|
||||
|
@ -147,7 +148,7 @@ ipc.on 'ATOM_BROWSER_CONSTRUCTOR', (event, id, args) ->
|
|||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_FUNCTION_CALL', (event, id, args) ->
|
||||
ipcMain.on 'ATOM_BROWSER_FUNCTION_CALL', (event, id, args) ->
|
||||
try
|
||||
args = unwrapArgs event.sender, args
|
||||
func = objectsRegistry.get id
|
||||
|
@ -155,7 +156,7 @@ ipc.on 'ATOM_BROWSER_FUNCTION_CALL', (event, id, args) ->
|
|||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_MEMBER_CONSTRUCTOR', (event, id, method, args) ->
|
||||
ipcMain.on 'ATOM_BROWSER_MEMBER_CONSTRUCTOR', (event, id, method, args) ->
|
||||
try
|
||||
args = unwrapArgs event.sender, args
|
||||
constructor = objectsRegistry.get(id)[method]
|
||||
|
@ -165,7 +166,7 @@ ipc.on 'ATOM_BROWSER_MEMBER_CONSTRUCTOR', (event, id, method, args) ->
|
|||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_MEMBER_CALL', (event, id, method, args) ->
|
||||
ipcMain.on 'ATOM_BROWSER_MEMBER_CALL', (event, id, method, args) ->
|
||||
try
|
||||
args = unwrapArgs event.sender, args
|
||||
obj = objectsRegistry.get id
|
||||
|
@ -173,7 +174,7 @@ ipc.on 'ATOM_BROWSER_MEMBER_CALL', (event, id, method, args) ->
|
|||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_MEMBER_SET', (event, id, name, value) ->
|
||||
ipcMain.on 'ATOM_BROWSER_MEMBER_SET', (event, id, name, value) ->
|
||||
try
|
||||
obj = objectsRegistry.get id
|
||||
obj[name] = value
|
||||
|
@ -181,17 +182,17 @@ ipc.on 'ATOM_BROWSER_MEMBER_SET', (event, id, name, value) ->
|
|||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_MEMBER_GET', (event, id, name) ->
|
||||
ipcMain.on 'ATOM_BROWSER_MEMBER_GET', (event, id, name) ->
|
||||
try
|
||||
obj = objectsRegistry.get id
|
||||
event.returnValue = valueToMeta event.sender, obj[name]
|
||||
catch e
|
||||
event.returnValue = exceptionToMeta e
|
||||
|
||||
ipc.on 'ATOM_BROWSER_DEREFERENCE', (event, id) ->
|
||||
ipcMain.on 'ATOM_BROWSER_DEREFERENCE', (event, id) ->
|
||||
objectsRegistry.remove event.sender.getId(), id
|
||||
|
||||
ipc.on 'ATOM_BROWSER_GUEST_WEB_CONTENTS', (event, guestInstanceId) ->
|
||||
ipcMain.on 'ATOM_BROWSER_GUEST_WEB_CONTENTS', (event, guestInstanceId) ->
|
||||
try
|
||||
guestViewManager = require './guest-view-manager'
|
||||
event.returnValue = valueToMeta event.sender, guestViewManager.getGuest(guestInstanceId)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
if process.platform is 'linux' and process.type is 'renderer'
|
||||
{remote} = require 'electron'
|
||||
# On Linux we could not access clipboard in renderer process.
|
||||
module.exports = require('remote').require 'clipboard'
|
||||
module.exports = remote.require 'clipboard'
|
||||
else
|
||||
module.exports = process.atomBinding 'clipboard'
|
||||
|
|
|
@ -8,11 +8,12 @@ class CrashReporter
|
|||
start: (options={}) ->
|
||||
{@productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra} = options
|
||||
|
||||
app =
|
||||
electron = require 'electron'
|
||||
{app} =
|
||||
if process.type is 'browser'
|
||||
require 'app'
|
||||
electron
|
||||
else
|
||||
require('remote').require 'app'
|
||||
electron.remote.require 'electron'
|
||||
|
||||
@productName ?= app.getName()
|
||||
companyName ?= 'GitHub, Inc'
|
||||
|
|
|
@ -13,3 +13,8 @@ Object.defineProperties exports,
|
|||
shell:
|
||||
enumerable: true
|
||||
get: -> require '../shell'
|
||||
# The internal modules, invisible unless you know their names.
|
||||
CallbacksRegistry:
|
||||
get: -> require '../callbacks-registry'
|
||||
deprecate:
|
||||
get: -> require '../deprecate'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
deprecate = require 'deprecate'
|
||||
ipcRenderer = require 'ipc-renderer'
|
||||
{ipcRenderer, deprecate} = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
# This module is deprecated, we mirror everything from ipcRenderer.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
ipc = require 'ipc-renderer'
|
||||
{ipcRenderer, CallbacksRegistry} = require 'electron'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
CallbacksRegistry = require 'callbacks-registry'
|
||||
|
||||
callbacksRegistry = new CallbacksRegistry
|
||||
|
||||
|
@ -58,7 +57,7 @@ metaToValue = (meta) ->
|
|||
constructor: ->
|
||||
if @constructor == RemoteFunction
|
||||
# Constructor call.
|
||||
obj = ipc.sendSync 'ATOM_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments)
|
||||
obj = ipcRenderer.sendSync 'ATOM_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments)
|
||||
|
||||
# Returning object in constructor will replace constructed object
|
||||
# with the returned object.
|
||||
|
@ -66,7 +65,7 @@ metaToValue = (meta) ->
|
|||
return metaToValue obj
|
||||
else
|
||||
# Function call.
|
||||
ret = ipc.sendSync 'ATOM_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments)
|
||||
ret = ipcRenderer.sendSync 'ATOM_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments)
|
||||
return metaToValue ret
|
||||
else
|
||||
ret = v8Util.createObjectWithName meta.name
|
||||
|
@ -80,11 +79,11 @@ metaToValue = (meta) ->
|
|||
constructor: ->
|
||||
if @constructor is RemoteMemberFunction
|
||||
# Constructor call.
|
||||
obj = ipc.sendSync 'ATOM_BROWSER_MEMBER_CONSTRUCTOR', meta.id, member.name, wrapArgs(arguments)
|
||||
obj = ipcRenderer.sendSync 'ATOM_BROWSER_MEMBER_CONSTRUCTOR', meta.id, member.name, wrapArgs(arguments)
|
||||
return metaToValue obj
|
||||
else
|
||||
# Call member function.
|
||||
ret = ipc.sendSync 'ATOM_BROWSER_MEMBER_CALL', meta.id, member.name, wrapArgs(arguments)
|
||||
ret = ipcRenderer.sendSync 'ATOM_BROWSER_MEMBER_CALL', meta.id, member.name, wrapArgs(arguments)
|
||||
return metaToValue ret
|
||||
else
|
||||
Object.defineProperty ret, member.name,
|
||||
|
@ -92,18 +91,18 @@ metaToValue = (meta) ->
|
|||
configurable: false,
|
||||
set: (value) ->
|
||||
# Set member data.
|
||||
ipc.sendSync 'ATOM_BROWSER_MEMBER_SET', meta.id, member.name, value
|
||||
ipcRenderer.sendSync 'ATOM_BROWSER_MEMBER_SET', meta.id, member.name, value
|
||||
value
|
||||
|
||||
get: ->
|
||||
# Get member data.
|
||||
ret = ipc.sendSync 'ATOM_BROWSER_MEMBER_GET', meta.id, member.name
|
||||
ret = ipcRenderer.sendSync 'ATOM_BROWSER_MEMBER_GET', meta.id, member.name
|
||||
metaToValue ret
|
||||
|
||||
# Track delegate object's life time, and tell the browser to clean up
|
||||
# when the object is GCed.
|
||||
v8Util.setDestructor ret, ->
|
||||
ipc.send 'ATOM_BROWSER_DEREFERENCE', meta.id
|
||||
ipcRenderer.send 'ATOM_BROWSER_DEREFERENCE', meta.id
|
||||
|
||||
# Remember object's id.
|
||||
v8Util.setHiddenValue ret, 'atomId', meta.id
|
||||
|
@ -119,11 +118,11 @@ metaToPlainObject = (meta) ->
|
|||
obj
|
||||
|
||||
# Browser calls a callback in renderer.
|
||||
ipc.on 'ATOM_RENDERER_CALLBACK', (event, id, args) ->
|
||||
ipcRenderer.on 'ATOM_RENDERER_CALLBACK', (event, id, args) ->
|
||||
callbacksRegistry.apply id, metaToValue(args)
|
||||
|
||||
# A callback in browser is released.
|
||||
ipc.on 'ATOM_RENDERER_RELEASE_CALLBACK', (event, id) ->
|
||||
ipcRenderer.on 'ATOM_RENDERER_RELEASE_CALLBACK', (event, id) ->
|
||||
callbacksRegistry.remove id
|
||||
|
||||
# Get remote module.
|
||||
|
@ -133,26 +132,26 @@ moduleCache = {}
|
|||
exports.require = (module) ->
|
||||
return moduleCache[module] if moduleCache[module]?
|
||||
|
||||
meta = ipc.sendSync 'ATOM_BROWSER_REQUIRE', module
|
||||
meta = ipcRenderer.sendSync 'ATOM_BROWSER_REQUIRE', module
|
||||
moduleCache[module] = metaToValue meta
|
||||
|
||||
# Get current BrowserWindow object.
|
||||
windowCache = null
|
||||
exports.getCurrentWindow = ->
|
||||
return windowCache if windowCache?
|
||||
meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WINDOW'
|
||||
meta = ipcRenderer.sendSync 'ATOM_BROWSER_CURRENT_WINDOW'
|
||||
windowCache = metaToValue meta
|
||||
|
||||
# Get current WebContents object.
|
||||
webContentsCache = null
|
||||
exports.getCurrentWebContents = ->
|
||||
return webContentsCache if webContentsCache?
|
||||
meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WEB_CONTENTS'
|
||||
meta = ipcRenderer.sendSync 'ATOM_BROWSER_CURRENT_WEB_CONTENTS'
|
||||
webContentsCache = metaToValue meta
|
||||
|
||||
# Get a global object in browser.
|
||||
exports.getGlobal = (name) ->
|
||||
meta = ipc.sendSync 'ATOM_BROWSER_GLOBAL', name
|
||||
meta = ipcRenderer.sendSync 'ATOM_BROWSER_GLOBAL', name
|
||||
metaToValue meta
|
||||
|
||||
# Get the process object in browser.
|
||||
|
@ -169,5 +168,5 @@ exports.createFunctionWithReturnValue = (returnValue) ->
|
|||
|
||||
# Get the guest WebContents from guestInstanceId.
|
||||
exports.getGuestWebContents = (guestInstanceId) ->
|
||||
meta = ipc.sendSync 'ATOM_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId
|
||||
meta = ipcRenderer.sendSync 'ATOM_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId
|
||||
metaToValue meta
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = require('remote').require('screen')
|
||||
module.exports = require('electron').remote.require('electron').screen
|
||||
|
|
|
@ -32,8 +32,8 @@ convertToMenuTemplate = (items) ->
|
|||
template
|
||||
|
||||
createMenu = (x, y, items, document) ->
|
||||
remote = require 'remote'
|
||||
Menu = remote.require 'menu'
|
||||
{remote} = require 'electron'
|
||||
{Menu} = remote.require 'electron'
|
||||
|
||||
menu = Menu.buildFromTemplate convertToMenuTemplate(items)
|
||||
# The menu is expected to show asynchronously.
|
||||
|
@ -42,8 +42,8 @@ createMenu = (x, y, items, document) ->
|
|||
DevToolsAPI.contextMenuCleared()
|
||||
|
||||
showFileChooserDialog = (callback) ->
|
||||
remote = require 'remote'
|
||||
dialog = remote.require 'dialog'
|
||||
{remote} = require 'electron'
|
||||
{dialog} = remote.require 'electron'
|
||||
files = dialog.showOpenDialog {}
|
||||
callback pathToHtml5FileObject files[0] if files?
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
ipc = require 'ipc-renderer'
|
||||
remote = require 'remote'
|
||||
{ipcRenderer, remote} = require 'electron'
|
||||
|
||||
# Helper function to resolve relative url.
|
||||
a = window.top.document.createElement 'a'
|
||||
|
@ -11,24 +10,24 @@ resolveUrl = (url) ->
|
|||
class BrowserWindowProxy
|
||||
constructor: (@guestId) ->
|
||||
@closed = false
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (event, guestId) =>
|
||||
ipcRenderer.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (event, guestId) =>
|
||||
if guestId is @guestId
|
||||
@closed = true
|
||||
|
||||
close: ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', @guestId
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', @guestId
|
||||
|
||||
focus: ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'focus'
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'focus'
|
||||
|
||||
blur: ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'blur'
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'blur'
|
||||
|
||||
postMessage: (message, targetOrigin='*') ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', @guestId, message, targetOrigin
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', @guestId, message, targetOrigin
|
||||
|
||||
eval: (args...) ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', @guestId, 'executeJavaScript', args...
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', @guestId, 'executeJavaScript', args...
|
||||
|
||||
unless process.guestInstanceId?
|
||||
# Override default window.close.
|
||||
|
@ -60,7 +59,7 @@ window.open = (url, frameName='', features='') ->
|
|||
|
||||
(options[name] = parseInt(options[name], 10) if options[name]?) for name in ints
|
||||
|
||||
guestId = ipc.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options
|
||||
guestId = ipcRenderer.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options
|
||||
if guestId
|
||||
new BrowserWindowProxy(guestId)
|
||||
else
|
||||
|
@ -87,13 +86,13 @@ window.prompt = ->
|
|||
throw new Error('prompt() is and will not be supported.')
|
||||
|
||||
# Implement window.postMessage if current window is a guest window.
|
||||
guestId = ipc.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID'
|
||||
guestId = ipcRenderer.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID'
|
||||
if guestId?
|
||||
window.opener =
|
||||
postMessage: (message, targetOrigin='*') ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', guestId, message, targetOrigin, location.origin
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', guestId, message, targetOrigin, location.origin
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', (event, guestId, message, sourceOrigin) ->
|
||||
ipcRenderer.on 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', (event, guestId, message, sourceOrigin) ->
|
||||
# Manually dispatch event instead of using postMessage because we also need to
|
||||
# set event.source.
|
||||
event = document.createEvent 'Event'
|
||||
|
@ -105,10 +104,10 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', (event, guestId, message, sourceOr
|
|||
|
||||
# Forward history operations to browser.
|
||||
sendHistoryOperation = (args...) ->
|
||||
ipc.send 'ATOM_SHELL_NAVIGATION_CONTROLLER', args...
|
||||
ipcRenderer.send 'ATOM_SHELL_NAVIGATION_CONTROLLER', args...
|
||||
|
||||
getHistoryOperation = (args...) ->
|
||||
ipc.sendSync 'ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', args...
|
||||
ipcRenderer.sendSync 'ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', args...
|
||||
|
||||
window.history.back = -> sendHistoryOperation 'goBack'
|
||||
window.history.forward = -> sendHistoryOperation 'goForward'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
ipc = require 'ipc-renderer'
|
||||
webFrame = require 'web-frame'
|
||||
{ipcRenderer, webFrame} = require 'electron'
|
||||
|
||||
requestId = 0
|
||||
|
||||
|
@ -37,40 +36,40 @@ dispatchEvent = (webView, event, args...) ->
|
|||
|
||||
module.exports =
|
||||
registerEvents: (webView, viewInstanceId) ->
|
||||
ipc.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}", (event, domEvent, args...) ->
|
||||
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}", (event, domEvent, args...) ->
|
||||
dispatchEvent webView, domEvent, args...
|
||||
|
||||
ipc.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}", (event, channel, args...) ->
|
||||
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}", (event, channel, args...) ->
|
||||
domEvent = new Event('ipc-message')
|
||||
domEvent.channel = channel
|
||||
domEvent.args = [args...]
|
||||
webView.dispatchEvent domEvent
|
||||
|
||||
ipc.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}", (event, args...) ->
|
||||
ipcRenderer.on "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}", (event, args...) ->
|
||||
domEvent = new Event('size-changed')
|
||||
for f, i in ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']
|
||||
domEvent[f] = args[i]
|
||||
webView.onSizeChanged domEvent
|
||||
|
||||
deregisterEvents: (viewInstanceId) ->
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}"
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}"
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}"
|
||||
ipcRenderer.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}"
|
||||
ipcRenderer.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}"
|
||||
ipcRenderer.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}"
|
||||
|
||||
createGuest: (params, callback) ->
|
||||
requestId++
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId
|
||||
ipc.once "ATOM_SHELL_RESPONSE_#{requestId}", callback
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId
|
||||
ipcRenderer.once "ATOM_SHELL_RESPONSE_#{requestId}", callback
|
||||
|
||||
attachGuest: (elementInstanceId, guestInstanceId, params) ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params
|
||||
webFrame.attachGuest elementInstanceId
|
||||
|
||||
destroyGuest: (guestInstanceId) ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId
|
||||
|
||||
setSize: (guestInstanceId, params) ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params
|
||||
|
||||
setAllowTransparency: (guestInstanceId, allowtransparency) ->
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', guestInstanceId, allowtransparency
|
||||
ipcRenderer.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', guestInstanceId, allowtransparency
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
WebViewImpl = require './web-view'
|
||||
guestViewInternal = require './guest-view-internal'
|
||||
webViewConstants = require './web-view-constants'
|
||||
remote = require 'remote'
|
||||
|
||||
{remote} = require 'electron'
|
||||
|
||||
# Helper function to resolve url set in attribute.
|
||||
a = document.createElement 'a'
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{webFrame, remote} = require 'electron'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
guestViewInternal = require './guest-view-internal'
|
||||
webViewConstants = require './web-view-constants'
|
||||
webFrame = require 'web-frame'
|
||||
remote = require 'remote'
|
||||
|
||||
# ID generator.
|
||||
nextId = 0
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
assert = require 'assert'
|
||||
remote = require 'remote'
|
||||
app = remote.require 'app'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
{remote} = require 'electron'
|
||||
{app, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
describe 'app module', ->
|
||||
describe 'app.getVersion()', ->
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
assert = require 'assert'
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
remote = require 'remote'
|
||||
http = require 'http'
|
||||
url = require 'url'
|
||||
os = require 'os'
|
||||
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
{remote, screen} = require 'electron'
|
||||
{ipcMain, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
isCI = remote.process.argv[2] == '--ci'
|
||||
|
||||
|
@ -191,7 +191,7 @@ describe 'browser-window module', ->
|
|||
assert.equal after[1], -10
|
||||
|
||||
it 'can set the window larger than screen', ->
|
||||
size = require('screen').getPrimaryDisplay().size
|
||||
size = screen.getPrimaryDisplay().size
|
||||
size.width += 100
|
||||
size.height += 100
|
||||
w.setSize size.width, size.height
|
||||
|
@ -201,12 +201,12 @@ describe 'browser-window module', ->
|
|||
|
||||
describe '"web-preferences" option', ->
|
||||
afterEach ->
|
||||
remote.require('ipc-main').removeAllListeners('answer')
|
||||
ipcMain.removeAllListeners('answer')
|
||||
|
||||
describe '"preload" option', ->
|
||||
it 'loads the script before other scripts in window', (done) ->
|
||||
preload = path.join fixtures, 'module', 'set-global.js'
|
||||
remote.require('ipc-main').once 'answer', (event, test) ->
|
||||
ipcMain.once 'answer', (event, test) ->
|
||||
assert.equal(test, 'preload')
|
||||
done()
|
||||
w.destroy()
|
||||
|
@ -219,7 +219,7 @@ describe 'browser-window module', ->
|
|||
describe '"node-integration" option', ->
|
||||
it 'disables node integration when specified to false', (done) ->
|
||||
preload = path.join fixtures, 'module', 'send-later.js'
|
||||
remote.require('ipc-main').once 'answer', (event, test) ->
|
||||
ipcMain.once 'answer', (event, test) ->
|
||||
assert.equal(test, 'undefined')
|
||||
done()
|
||||
w.destroy()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
assert = require 'assert'
|
||||
clipboard = require 'clipboard'
|
||||
nativeImage = require 'native-image'
|
||||
path = require 'path'
|
||||
|
||||
{clipboard, nativeImage} = require 'electron'
|
||||
|
||||
describe 'clipboard module', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@ assert = require 'assert'
|
|||
path = require 'path'
|
||||
http = require 'http'
|
||||
url = require 'url'
|
||||
remote = require 'remote'
|
||||
multiparty = require 'multiparty'
|
||||
|
||||
crashReporter = remote.require 'crash-reporter'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
{remote} = require 'electron'
|
||||
{app, crashReporter, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
describe 'crash-reporter module', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
|
@ -41,7 +40,7 @@ describe 'crash-reporter module', ->
|
|||
assert.equal fields['extra2'], 'extra2'
|
||||
assert.equal fields['_productName'], 'Zombies'
|
||||
assert.equal fields['_companyName'], 'Umbrella Corporation'
|
||||
assert.equal fields['_version'], require('remote').require('app').getVersion()
|
||||
assert.equal fields['_version'], app.getVersion()
|
||||
|
||||
res.end('abc-123-def')
|
||||
done()
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
assert = require 'assert'
|
||||
ipc = require 'ipc-renderer'
|
||||
path = require 'path'
|
||||
remote = require 'remote'
|
||||
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
{ipcRenderer, remote} = require 'electron'
|
||||
{ipcMain, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
comparePaths = (path1, path2) ->
|
||||
if process.platform is 'win32'
|
||||
|
@ -17,8 +16,8 @@ describe 'ipc module', ->
|
|||
|
||||
describe 'remote.require', ->
|
||||
it 'should returns same object for the same module', ->
|
||||
dialog1 = remote.require 'dialog'
|
||||
dialog2 = remote.require 'dialog'
|
||||
dialog1 = remote.require 'electron'
|
||||
dialog2 = remote.require 'electron'
|
||||
assert.equal dialog1, dialog2
|
||||
|
||||
it 'should work when object contains id property', ->
|
||||
|
@ -70,20 +69,20 @@ describe 'ipc module', ->
|
|||
describe 'ipc.sender.send', ->
|
||||
it 'should work when sending an object containing id property', (done) ->
|
||||
obj = id: 1, name: 'ly'
|
||||
ipc.once 'message', (event, message) ->
|
||||
ipcRenderer.once 'message', (event, message) ->
|
||||
assert.deepEqual message, obj
|
||||
done()
|
||||
ipc.send 'message', obj
|
||||
ipcRenderer.send 'message', obj
|
||||
|
||||
describe 'ipc.sendSync', ->
|
||||
it 'can be replied by setting event.returnValue', ->
|
||||
msg = ipc.sendSync 'echo', 'test'
|
||||
msg = ipcRenderer.sendSync 'echo', 'test'
|
||||
assert.equal msg, 'test'
|
||||
|
||||
it 'does not crash when reply is not sent and browser is destroyed', (done) ->
|
||||
@timeout 10000
|
||||
w = new BrowserWindow(show: false)
|
||||
remote.require('ipc-main').once 'send-sync-message', (event) ->
|
||||
ipcMain.once 'send-sync-message', (event) ->
|
||||
event.returnValue = null
|
||||
w.destroy()
|
||||
done()
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
assert = require 'assert'
|
||||
remote = require 'remote'
|
||||
|
||||
Menu = remote.require 'menu'
|
||||
MenuItem = remote.require 'menu-item'
|
||||
{remote} = require 'electron'
|
||||
{Menu, MenuItem} = remote.require 'electron'
|
||||
|
||||
describe 'menu module', ->
|
||||
describe 'Menu.buildFromTemplate', ->
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
assert = require 'assert'
|
||||
http = require 'http'
|
||||
path = require 'path'
|
||||
remote = require 'remote'
|
||||
protocol = remote.require 'protocol'
|
||||
|
||||
{remote} = require 'electron'
|
||||
{protocol} = remote.require 'electron'
|
||||
|
||||
describe 'protocol module', ->
|
||||
protocolName = 'sp'
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
assert = require 'assert'
|
||||
screen = require 'screen'
|
||||
|
||||
{screen} = require 'electron'
|
||||
|
||||
describe 'screen module', ->
|
||||
describe 'screen.getCursorScreenPoint()', ->
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
assert = require 'assert'
|
||||
remote = require 'remote'
|
||||
http = require 'http'
|
||||
path = require 'path'
|
||||
fs = require 'fs'
|
||||
app = remote.require 'app'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
{ipcRenderer, remote} = require 'electron'
|
||||
{app, ipcMain, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
describe 'session module', ->
|
||||
@timeout 10000
|
||||
|
@ -60,7 +60,6 @@ describe 'session module', ->
|
|||
describe 'session.clearStorageData(options)', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
it 'clears localstorage data', (done) ->
|
||||
ipcMain = remote.require('ipc-main')
|
||||
ipcMain.on 'count', (event, count) ->
|
||||
ipcMain.removeAllListeners 'count'
|
||||
assert not count
|
||||
|
@ -78,7 +77,6 @@ describe 'session module', ->
|
|||
# A 5 MB mock pdf.
|
||||
mockPDF = new Buffer 1024 * 1024 * 5
|
||||
contentDisposition = 'inline; filename="mock.pdf"'
|
||||
ipc = require 'ipc-renderer'
|
||||
downloadFilePath = path.join fixtures, 'mock.pdf'
|
||||
downloadServer = http.createServer (req, res) ->
|
||||
res.writeHead 200, {
|
||||
|
@ -92,9 +90,9 @@ describe 'session module', ->
|
|||
it 'can download successfully', (done) ->
|
||||
downloadServer.listen 0, '127.0.0.1', ->
|
||||
{port} = downloadServer.address()
|
||||
ipc.sendSync 'set-download-option', false
|
||||
ipcRenderer.sendSync 'set-download-option', false
|
||||
w.loadUrl "#{url}:#{port}"
|
||||
ipc.once 'download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) ->
|
||||
ipcRenderer.once 'download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) ->
|
||||
assert.equal state, 'completed'
|
||||
assert.equal filename, 'mock.pdf'
|
||||
assert.equal url, "http://127.0.0.1:#{port}/"
|
||||
|
@ -109,9 +107,9 @@ describe 'session module', ->
|
|||
it 'can cancel download', (done) ->
|
||||
downloadServer.listen 0, '127.0.0.1', ->
|
||||
{port} = downloadServer.address()
|
||||
ipc.sendSync 'set-download-option', true
|
||||
ipcRenderer.sendSync 'set-download-option', true
|
||||
w.loadUrl "#{url}:#{port}/"
|
||||
ipc.once 'download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) ->
|
||||
ipcRenderer.once 'download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) ->
|
||||
assert.equal state, 'cancelled'
|
||||
assert.equal filename, 'mock.pdf'
|
||||
assert.equal mimeType, 'application/pdf'
|
||||
|
|
|
@ -3,6 +3,9 @@ child_process = require 'child_process'
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
{nativeImage, remote} = require 'electron'
|
||||
{ipcMain, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
describe 'asar package', ->
|
||||
fixtures = path.join __dirname, 'fixtures'
|
||||
|
||||
|
@ -406,9 +409,6 @@ describe 'asar package', ->
|
|||
|
||||
describe 'asar protocol', ->
|
||||
url = require 'url'
|
||||
remote = require 'remote'
|
||||
ipc = remote.require 'ipc-main'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
it 'can request a file in package', (done) ->
|
||||
p = path.resolve fixtures, 'asar', 'a.asar', 'file1'
|
||||
|
@ -445,12 +445,12 @@ describe 'asar package', ->
|
|||
it 'sets __dirname correctly', (done) ->
|
||||
after ->
|
||||
w.destroy()
|
||||
ipc.removeAllListeners 'dirname'
|
||||
ipcMain.removeAllListeners 'dirname'
|
||||
|
||||
w = new BrowserWindow(show: false, width: 400, height: 400)
|
||||
p = path.resolve fixtures, 'asar', 'web.asar', 'index.html'
|
||||
u = url.format protocol: 'file', slashed: true, pathname: p
|
||||
ipc.once 'dirname', (event, dirname) ->
|
||||
ipcMain.once 'dirname', (event, dirname) ->
|
||||
assert.equal dirname, path.dirname(p)
|
||||
done()
|
||||
w.loadUrl u
|
||||
|
@ -458,13 +458,13 @@ describe 'asar package', ->
|
|||
it 'loads script tag in html', (done) ->
|
||||
after ->
|
||||
w.destroy()
|
||||
ipc.removeAllListeners 'ping'
|
||||
ipcMain.removeAllListeners 'ping'
|
||||
|
||||
w = new BrowserWindow(show: false, width: 400, height: 400)
|
||||
p = path.resolve fixtures, 'asar', 'script.asar', 'index.html'
|
||||
u = url.format protocol: 'file', slashed: true, pathname: p
|
||||
w.loadUrl u
|
||||
ipc.once 'ping', (event, message) ->
|
||||
ipcMain.once 'ping', (event, message) ->
|
||||
assert.equal message, 'pong'
|
||||
done()
|
||||
|
||||
|
@ -496,10 +496,10 @@ describe 'asar package', ->
|
|||
describe 'native-image', ->
|
||||
it 'reads image from asar archive', ->
|
||||
p = path.join fixtures, 'asar', 'logo.asar', 'logo.png'
|
||||
logo = require('native-image').createFromPath p
|
||||
logo = nativeImage.createFromPath p
|
||||
assert.deepEqual logo.getSize(), {width: 55, height: 55}
|
||||
|
||||
it 'reads image from asar archive with unpacked files', ->
|
||||
p = path.join fixtures, 'asar', 'unpack.asar', 'atom.png'
|
||||
logo = require('native-image').createFromPath p
|
||||
logo = nativeImage.createFromPath p
|
||||
assert.deepEqual logo.getSize(), {width: 1024, height: 1024}
|
||||
|
|
|
@ -3,8 +3,9 @@ http = require 'http'
|
|||
https = require 'https'
|
||||
path = require 'path'
|
||||
ws = require 'ws'
|
||||
remote = require 'remote'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
{remote} = require 'electron'
|
||||
{BrowserWindow} = remote.require 'electron'
|
||||
|
||||
describe 'chromium feature', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
|
|
2
spec/fixtures/api/beforeunload-false.html
vendored
2
spec/fixtures/api/beforeunload-false.html
vendored
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('remote').getCurrentWindow().emit('onbeforeunload');
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('remote').getCurrentWindow().emit('onbeforeunload');
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('remote').getCurrentWindow().emit('onbeforeunload');
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('remote').getCurrentWindow().emit('onbeforeunload');
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return 'string';
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('remote').getCurrentWindow().emit('onbeforeunload');
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return true;
|
||||
}
|
||||
|
|
2
spec/fixtures/api/crash.html
vendored
2
spec/fixtures/api/crash.html
vendored
|
@ -2,7 +2,7 @@
|
|||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var port = require('url').parse(window.location.href, true).query.port;
|
||||
var crashReporter = require('crash-reporter');
|
||||
var crashReporter = require('electron').crashReporter;
|
||||
crashReporter.start({
|
||||
productName: 'Zombies',
|
||||
companyName: 'Umbrella Corporation',
|
||||
|
|
6
spec/fixtures/api/localstorage.html
vendored
6
spec/fixtures/api/localstorage.html
vendored
|
@ -2,9 +2,9 @@
|
|||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.localStorage.setItem('test', 'test');
|
||||
var ipc = require('ipc-renderer');
|
||||
ipc.on('getcount', function() {
|
||||
ipc.send('count', window.localStorage.length);
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
ipcRenderer.on('getcount', function() {
|
||||
ipcRenderer.send('count', window.localStorage.length);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
|
2
spec/fixtures/api/preload.html
vendored
2
spec/fixtures/api/preload.html
vendored
|
@ -3,7 +3,7 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
if (!window.test)
|
||||
window.test = 'window'
|
||||
require('ipc-renderer').send('answer', window.test);
|
||||
require('electron').ipcRenderer.send('answer', window.test);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
4
spec/fixtures/api/send-sync-message.html
vendored
4
spec/fixtures/api/send-sync-message.html
vendored
|
@ -1,8 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ipc = require('ipc-renderer');
|
||||
ipc.sendSync('send-sync-message', 'message');
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
ipcRenderer.sendSync('send-sync-message', 'message');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
BIN
spec/fixtures/asar/script.asar
vendored
BIN
spec/fixtures/asar/script.asar
vendored
Binary file not shown.
BIN
spec/fixtures/asar/web.asar
vendored
BIN
spec/fixtures/asar/web.asar
vendored
Binary file not shown.
6
spec/fixtures/module/preload-ipc.js
vendored
6
spec/fixtures/module/preload-ipc.js
vendored
|
@ -1,4 +1,4 @@
|
|||
var ipc = require('ipc-renderer');
|
||||
ipc.on('ping', function(event, message) {
|
||||
ipc.sendToHost('pong', message);
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
ipcRenderer.on('ping', function(event, message) {
|
||||
ipcRenderer.sendToHost('pong', message);
|
||||
});
|
||||
|
|
4
spec/fixtures/module/send-later.js
vendored
4
spec/fixtures/module/send-later.js
vendored
|
@ -1,4 +1,4 @@
|
|||
var ipc = require('ipc-renderer');
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
window.onload = function() {
|
||||
ipc.send('answer', typeof window.process);
|
||||
ipcRenderer.send('answer', typeof window.process);
|
||||
}
|
||||
|
|
6
spec/fixtures/pages/basic-auth.html
vendored
6
spec/fixtures/pages/basic-auth.html
vendored
|
@ -2,7 +2,7 @@
|
|||
<body>
|
||||
<script src="../../static/jquery-2.0.3.min.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ipc = require('ipc-renderer');
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
var port = location.search.substr("?port=".length);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
|
@ -11,10 +11,10 @@
|
|||
"Authorization": "Basic " + btoa("test:test")
|
||||
},
|
||||
success: function(result) {
|
||||
ipc.sendToHost(result);
|
||||
ipcRenderer.sendToHost(result);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
ipc.sendToHost(error);
|
||||
ipcRenderer.sendToHost(error);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
4
spec/fixtures/pages/beforeunload-false.html
vendored
4
spec/fixtures/pages/beforeunload-false.html
vendored
|
@ -3,8 +3,8 @@
|
|||
<script type="text/javascript" charset="utf-8">
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
var ipc = require('ipc-renderer');
|
||||
ipc.sendToHost('onbeforeunload');
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
ipcRenderer.sendToHost('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
|
|
2
spec/fixtures/pages/document-hidden.html
vendored
2
spec/fixtures/pages/document-hidden.html
vendored
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require('ipc-renderer').send('hidden', document.hidden);
|
||||
require('electron').ipcRenderer.send('hidden', document.hidden);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
2
spec/fixtures/pages/history.html
vendored
2
spec/fixtures/pages/history.html
vendored
|
@ -2,7 +2,7 @@
|
|||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.history.pushState(window.history.state, "test page", "foo.html")
|
||||
require('ipc-renderer').sendToHost('history', window.history.length);
|
||||
require('electron').ipcRenderer.sendToHost('history', window.history.length);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
2
spec/fixtures/pages/ipc-message.html
vendored
2
spec/fixtures/pages/ipc-message.html
vendored
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require('ipc-renderer').sendToHost('channel', 'arg1', 'arg2');
|
||||
require('electron').ipcRenderer.sendToHost('channel', 'arg1', 'arg2');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
2
spec/fixtures/pages/onkeyup.html
vendored
2
spec/fixtures/pages/onkeyup.html
vendored
|
@ -2,7 +2,7 @@
|
|||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
document.onkeyup = function(e) {
|
||||
require('ipc-renderer').sendToHost('keyup', e.keyCode, e.shiftKey, e.ctrlKey);
|
||||
require('electron').ipcRenderer.sendToHost('keyup', e.keyCode, e.shiftKey, e.ctrlKey);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
2
spec/fixtures/pages/onmouseup.html
vendored
2
spec/fixtures/pages/onmouseup.html
vendored
|
@ -2,7 +2,7 @@
|
|||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
document.onmouseup = function(e) {
|
||||
require('ipc-renderer').sendToHost('mouseup', e.x, e.y, e.shiftKey, e.ctrlKey);
|
||||
require('electron').ipcRenderer.sendToHost('mouseup', e.x, e.y, e.shiftKey, e.ctrlKey);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
2
spec/fixtures/pages/window-open-size.html
vendored
2
spec/fixtures/pages/window-open-size.html
vendored
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var size = require('remote').getCurrentWindow().getSize();
|
||||
var size = require('electron').remote.getCurrentWindow().getSize();
|
||||
window.opener.postMessage('size: ' + size.width + ' ' + size.height, '*')
|
||||
</script>
|
||||
</body>
|
||||
|
|
2
spec/fixtures/pages/window-opener.html
vendored
2
spec/fixtures/pages/window-opener.html
vendored
|
@ -4,7 +4,7 @@
|
|||
if (window.opener !== null)
|
||||
window.opener.postMessage(typeof window.opener, '*');
|
||||
else
|
||||
require('ipc-renderer').send('opener', window.opener);
|
||||
require('electron').ipcRenderer.send('opener', window.opener);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,7 +3,8 @@ child_process = require 'child_process'
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
os = require 'os'
|
||||
remote = require 'remote'
|
||||
|
||||
{remote} = require 'electron'
|
||||
|
||||
describe 'node feature', ->
|
||||
fixtures = path.join __dirname, 'fixtures'
|
||||
|
|
|
@ -14,22 +14,25 @@
|
|||
process.throwDeprecation = true;
|
||||
|
||||
// Check if we are running in CI.
|
||||
var argv = require('remote').process.argv;
|
||||
var electron = require ('electron');
|
||||
var remote = electron.remote;
|
||||
var ipcRenderer = electron.ipcRenderer;
|
||||
|
||||
var argv = remote.process.argv;
|
||||
var isCi = argv[2] == '--ci';
|
||||
|
||||
if (!isCi) {
|
||||
var win = require('remote').getCurrentWindow();
|
||||
var win = remote.getCurrentWindow();
|
||||
win.show();
|
||||
win.focus();
|
||||
}
|
||||
|
||||
// Show DevTools.
|
||||
document.oncontextmenu = function(e) {
|
||||
require('remote').getCurrentWindow().inspectElement(e.clientX, e.clientY);
|
||||
remote.getCurrentWindow().inspectElement(e.clientX, e.clientY);
|
||||
}
|
||||
|
||||
require('coffee-script/register'); // Supports .coffee tests.
|
||||
var ipc = require('ipc-renderer');
|
||||
|
||||
// Rediret all output to browser.
|
||||
if (isCi) {
|
||||
|
@ -37,11 +40,11 @@
|
|||
return {
|
||||
log: function() {
|
||||
args = Array.prototype.slice.call(arguments);
|
||||
ipc.send('console.log', args);
|
||||
ipcRenderer.send('console.log', args);
|
||||
},
|
||||
error: function() {
|
||||
args = Array.prototype.slice.call(arguments);
|
||||
ipc.send('console.error', args);
|
||||
ipcRenderer.send('console.error', args);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
@ -70,7 +73,7 @@
|
|||
var runner = mocha.run(function() {
|
||||
Mocha.utils.highlightTags('code');
|
||||
if (isCi)
|
||||
ipc.send('process.exit', runner.failures);
|
||||
ipcRenderer.send('process.exit', runner.failures);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
var app = require('app');
|
||||
var ipc = require('ipc-main');
|
||||
var dialog = require('dialog');
|
||||
var path = require('path');
|
||||
var BrowserWindow = require('browser-window');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const ipcMain = electron.ipcMain;
|
||||
const dialog = electron.dialog;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
var window = null;
|
||||
process.port = 0; // will be used by crash-reporter spec.
|
||||
|
@ -16,27 +18,27 @@ app.commandLine.appendSwitch('disable-renderer-backgrounding');
|
|||
// sure we can reproduce it in renderer process.
|
||||
process.stdout;
|
||||
|
||||
ipc.on('message', function(event, arg) {
|
||||
ipcMain.on('message', function(event, arg) {
|
||||
event.sender.send('message', arg);
|
||||
});
|
||||
|
||||
ipc.on('console.log', function(event, args) {
|
||||
ipcMain.on('console.log', function(event, args) {
|
||||
console.error.apply(console, args);
|
||||
});
|
||||
|
||||
ipc.on('console.error', function(event, args) {
|
||||
ipcMain.on('console.error', function(event, args) {
|
||||
console.error.apply(console, args);
|
||||
});
|
||||
|
||||
ipc.on('process.exit', function(event, code) {
|
||||
ipcMain.on('process.exit', function(event, code) {
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
ipc.on('eval', function(event, script) {
|
||||
ipcMain.on('eval', function(event, script) {
|
||||
event.returnValue = eval(script);
|
||||
});
|
||||
|
||||
ipc.on('echo', function(event, msg) {
|
||||
ipcMain.on('echo', function(event, msg) {
|
||||
event.returnValue = msg;
|
||||
});
|
||||
|
||||
|
@ -54,7 +56,7 @@ app.on('window-all-closed', function() {
|
|||
|
||||
app.on('ready', function() {
|
||||
// Test if using protocol module would crash.
|
||||
require('protocol').registerStringProtocol('test-if-crashes', function() {});
|
||||
electron.protocol.registerStringProtocol('test-if-crashes', function() {});
|
||||
|
||||
window = new BrowserWindow({
|
||||
title: 'Electron Tests',
|
||||
|
@ -79,7 +81,7 @@ app.on('ready', function() {
|
|||
// For session's download test, listen 'will-download' event in browser, and
|
||||
// reply the result to renderer for verifying
|
||||
var downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf');
|
||||
ipc.on('set-download-option', function(event, need_cancel) {
|
||||
ipcMain.on('set-download-option', function(event, need_cancel) {
|
||||
window.webContents.session.once('will-download',
|
||||
function(e, item, webContents) {
|
||||
item.setSavePath(downloadFilePath);
|
||||
|
|
Loading…
Reference in a new issue