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
|
EventEmitter = require('events').EventEmitter
|
||||||
app = require 'app'
|
app = require 'app'
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc-main'
|
||||||
deprecate = require 'deprecate'
|
deprecate = require 'deprecate'
|
||||||
|
|
||||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
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.
|
# The history operation in renderer is redirected to browser.
|
||||||
ipc.on 'ATOM_SHELL_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
ipc.on 'ATOM_SHELL_NAVIGATION_CONTROLLER', (event, method, args...) ->
|
||||||
|
|
|
@ -2,7 +2,7 @@ EventEmitter = require('events').EventEmitter
|
||||||
Menu = require './menu'
|
Menu = require './menu'
|
||||||
NavigationController = require './navigation-controller'
|
NavigationController = require './navigation-controller'
|
||||||
binding = process.atomBinding 'web_contents'
|
binding = process.atomBinding 'web_contents'
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc-main'
|
||||||
|
|
||||||
nextId = 0
|
nextId = 0
|
||||||
getNextId = -> ++nextId
|
getNextId = -> ++nextId
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc-main'
|
||||||
webContents = require 'web-contents'
|
webContents = require 'web-contents'
|
||||||
webViewManager = null # Doesn't exist in early initialization.
|
webViewManager = null # Doesn't exist in early initialization.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc-main'
|
||||||
v8Util = process.atomBinding 'v8_util'
|
v8Util = process.atomBinding 'v8_util'
|
||||||
BrowserWindow = require 'browser-window'
|
BrowserWindow = require 'browser-window'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc-main'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
objectsRegistry = require './objects-registry.js'
|
objectsRegistry = require './objects-registry.js'
|
||||||
v8Util = process.atomBinding 'v8_util'
|
v8Util = process.atomBinding 'v8_util'
|
||||||
|
|
|
@ -201,12 +201,12 @@ describe 'browser-window module', ->
|
||||||
|
|
||||||
describe '"web-preferences" option', ->
|
describe '"web-preferences" option', ->
|
||||||
afterEach ->
|
afterEach ->
|
||||||
remote.require('ipc').removeAllListeners('answer')
|
remote.require('ipc-main').removeAllListeners('answer')
|
||||||
|
|
||||||
describe '"preload" option', ->
|
describe '"preload" option', ->
|
||||||
it 'loads the script before other scripts in window', (done) ->
|
it 'loads the script before other scripts in window', (done) ->
|
||||||
preload = path.join fixtures, 'module', 'set-global.js'
|
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')
|
assert.equal(test, 'preload')
|
||||||
done()
|
done()
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
@ -219,7 +219,7 @@ describe 'browser-window module', ->
|
||||||
describe '"node-integration" option', ->
|
describe '"node-integration" option', ->
|
||||||
it 'disables node integration when specified to false', (done) ->
|
it 'disables node integration when specified to false', (done) ->
|
||||||
preload = path.join fixtures, 'module', 'send-later.js'
|
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')
|
assert.equal(test, 'undefined')
|
||||||
done()
|
done()
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
|
@ -83,7 +83,7 @@ describe 'ipc module', ->
|
||||||
it 'does not crash when reply is not sent and browser is destroyed', (done) ->
|
it 'does not crash when reply is not sent and browser is destroyed', (done) ->
|
||||||
@timeout 10000
|
@timeout 10000
|
||||||
w = new BrowserWindow(show: false)
|
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
|
event.returnValue = null
|
||||||
w.destroy()
|
w.destroy()
|
||||||
done()
|
done()
|
||||||
|
|
|
@ -60,9 +60,9 @@ describe 'session module', ->
|
||||||
describe 'session.clearStorageData(options)', ->
|
describe 'session.clearStorageData(options)', ->
|
||||||
fixtures = path.resolve __dirname, 'fixtures'
|
fixtures = path.resolve __dirname, 'fixtures'
|
||||||
it 'clears localstorage data', (done) ->
|
it 'clears localstorage data', (done) ->
|
||||||
ipc = remote.require('ipc')
|
ipcMain = remote.require('ipc-main')
|
||||||
ipc.on 'count', (event, count) ->
|
ipcMain.on 'count', (event, count) ->
|
||||||
ipc.removeAllListeners 'count'
|
ipcMain.removeAllListeners 'count'
|
||||||
assert not count
|
assert not count
|
||||||
done()
|
done()
|
||||||
w.loadUrl 'file://' + path.join(fixtures, 'api', 'localstorage.html')
|
w.loadUrl 'file://' + path.join(fixtures, 'api', 'localstorage.html')
|
||||||
|
|
|
@ -407,7 +407,7 @@ describe 'asar package', ->
|
||||||
describe 'asar protocol', ->
|
describe 'asar protocol', ->
|
||||||
url = require 'url'
|
url = require 'url'
|
||||||
remote = require 'remote'
|
remote = require 'remote'
|
||||||
ipc = remote.require 'ipc'
|
ipc = remote.require 'ipc-main'
|
||||||
BrowserWindow = remote.require 'browser-window'
|
BrowserWindow = remote.require 'browser-window'
|
||||||
|
|
||||||
it 'can request a file in package', (done) ->
|
it 'can request a file in package', (done) ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var app = require('app');
|
var app = require('app');
|
||||||
var ipc = require('ipc');
|
var ipc = require('ipc-main');
|
||||||
var dialog = require('dialog');
|
var dialog = require('dialog');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var BrowserWindow = require('browser-window');
|
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
|
// For session's download test, listen 'will-download' event in browser, and
|
||||||
// reply the result to renderer for verifying
|
// reply the result to renderer for verifying
|
||||||
var downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf');
|
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',
|
window.webContents.session.once('will-download',
|
||||||
function(e, item, webContents) {
|
function(e, item, webContents) {
|
||||||
item.setSavePath(downloadFilePath);
|
item.setSavePath(downloadFilePath);
|
||||||
|
|
Loading…
Reference in a new issue