Use ipcMain in Electron's code
This commit is contained in:
parent
844cea8f21
commit
751af25f37
11 changed files with 16 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
app = require 'app'
|
||||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
deprecate = require 'deprecate'
|
||||
|
||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
|
||||
# The history operation in renderer is redirected to browser.
|
||||
ipc.on 'ATOM_SHELL_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||
|
|
|
@ -2,7 +2,7 @@ EventEmitter = require('events').EventEmitter
|
|||
Menu = require './menu'
|
||||
NavigationController = require './navigation-controller'
|
||||
binding = process.atomBinding 'web_contents'
|
||||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
|
||||
nextId = 0
|
||||
getNextId = -> ++nextId
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
webContents = require 'web-contents'
|
||||
webViewManager = null # Doesn't exist in early initialization.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
BrowserWindow = require 'browser-window'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ipc = require 'ipc'
|
||||
ipc = require 'ipc-main'
|
||||
path = require 'path'
|
||||
objectsRegistry = require './objects-registry.js'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
|
|
@ -201,12 +201,12 @@ describe 'browser-window module', ->
|
|||
|
||||
describe '"web-preferences" option', ->
|
||||
afterEach ->
|
||||
remote.require('ipc').removeAllListeners('answer')
|
||||
remote.require('ipc-main').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').once 'answer', (event, test) ->
|
||||
remote.require('ipc-main').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').once 'answer', (event, test) ->
|
||||
remote.require('ipc-main').once 'answer', (event, test) ->
|
||||
assert.equal(test, 'undefined')
|
||||
done()
|
||||
w.destroy()
|
||||
|
|
|
@ -83,7 +83,7 @@ describe 'ipc module', ->
|
|||
it 'does not crash when reply is not sent and browser is destroyed', (done) ->
|
||||
@timeout 10000
|
||||
w = new BrowserWindow(show: false)
|
||||
remote.require('ipc').once 'send-sync-message', (event) ->
|
||||
remote.require('ipc-main').once 'send-sync-message', (event) ->
|
||||
event.returnValue = null
|
||||
w.destroy()
|
||||
done()
|
||||
|
|
|
@ -60,9 +60,9 @@ describe 'session module', ->
|
|||
describe 'session.clearStorageData(options)', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
it 'clears localstorage data', (done) ->
|
||||
ipc = remote.require('ipc')
|
||||
ipc.on 'count', (event, count) ->
|
||||
ipc.removeAllListeners 'count'
|
||||
ipcMain = remote.require('ipc-main')
|
||||
ipcMain.on 'count', (event, count) ->
|
||||
ipcMain.removeAllListeners 'count'
|
||||
assert not count
|
||||
done()
|
||||
w.loadUrl 'file://' + path.join(fixtures, 'api', 'localstorage.html')
|
||||
|
|
|
@ -407,7 +407,7 @@ describe 'asar package', ->
|
|||
describe 'asar protocol', ->
|
||||
url = require 'url'
|
||||
remote = require 'remote'
|
||||
ipc = remote.require 'ipc'
|
||||
ipc = remote.require 'ipc-main'
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
it 'can request a file in package', (done) ->
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var app = require('app');
|
||||
var ipc = require('ipc');
|
||||
var ipc = require('ipc-main');
|
||||
var dialog = require('dialog');
|
||||
var path = require('path');
|
||||
var BrowserWindow = require('browser-window');
|
||||
|
@ -78,7 +78,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');
|
||||
require('ipc').on('set-download-option', function(event, need_cancel) {
|
||||
ipc.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