Merge pull request #2866 from atom/no-expose-setimmediate

No more exposing setImmediate as local variable
This commit is contained in:
Cheng Zhao 2015-09-22 15:10:44 +08:00
commit 889d7c1e02
7 changed files with 13 additions and 25 deletions

View file

@ -1,8 +1,7 @@
process = global.process fs = require 'fs'
fs = require 'fs' path = require 'path'
path = require 'path' timers = require 'timers'
timers = require 'timers' Module = require 'module'
Module = require 'module'
process.atomBinding = (name) -> process.atomBinding = (name) ->
try try
@ -37,6 +36,8 @@ wrapWithActivateUvLoop = (func) ->
process.activateUvLoop() process.activateUvLoop()
func.apply this, arguments func.apply this, arguments
process.nextTick = wrapWithActivateUvLoop process.nextTick process.nextTick = wrapWithActivateUvLoop process.nextTick
global.setImmediate = wrapWithActivateUvLoop timers.setImmediate
global.clearImmediate = timers.clearImmediate
if process.type is 'browser' if process.type is 'browser'
# setTimeout needs to update the polling timeout of the event loop, when # setTimeout needs to update the polling timeout of the event loop, when
@ -45,10 +46,3 @@ if process.type is 'browser'
# recalculate the timeout in browser process. # recalculate the timeout in browser process.
global.setTimeout = wrapWithActivateUvLoop timers.setTimeout global.setTimeout = wrapWithActivateUvLoop timers.setTimeout
global.setInterval = wrapWithActivateUvLoop timers.setInterval global.setInterval = wrapWithActivateUvLoop timers.setInterval
global.setImmediate = wrapWithActivateUvLoop timers.setImmediate
global.clearImmediate = wrapWithActivateUvLoop timers.clearImmediate
else
# There are no setImmediate under renderer process by default, so we need to
# manually setup them here.
global.setImmediate = setImmediate
global.clearImmediate = clearImmediate

View file

@ -1,4 +1,3 @@
process = global.process
ipc = require 'ipc' ipc = require 'ipc'
v8Util = process.atomBinding 'v8_util' v8Util = process.atomBinding 'v8_util'
CallbacksRegistry = require 'callbacks-registry' CallbacksRegistry = require 'callbacks-registry'

View file

@ -1,8 +1,7 @@
process = global.process events = require 'events'
events = require 'events' path = require 'path'
path = require 'path' url = require 'url'
url = require 'url' Module = require 'module'
Module = require 'module'
# We modified the original process.argv to let node.js load the # We modified the original process.argv to let node.js load the
# atom-renderer.js, we need to restore it here. # atom-renderer.js, we need to restore it here.

View file

@ -1,4 +1,3 @@
process = global.process
ipc = require 'ipc' ipc = require 'ipc'
remote = require 'remote' remote = require 'remote'

View file

@ -304,10 +304,7 @@ describe 'browser-window module', ->
done() done()
w.loadUrl url w.loadUrl url
describe 'beginFrameSubscription method', -> xdescribe 'beginFrameSubscription method', ->
# It is not very reliable on Travis CI.
return if process.env.TRAVIS is 'true'
it 'subscribes frame updates', (done) -> it 'subscribes frame updates', (done) ->
w.loadUrl "file://#{fixtures}/api/blank.html" w.loadUrl "file://#{fixtures}/api/blank.html"
w.webContents.beginFrameSubscription (data) -> w.webContents.beginFrameSubscription (data) ->

View file

@ -86,7 +86,7 @@ describe '<webview> tag', ->
it 'preload script can still use "process" in required modules when nodeintegration is off', (done) -> it 'preload script can still use "process" in required modules when nodeintegration is off', (done) ->
webview.addEventListener 'console-message', (e) -> webview.addEventListener 'console-message', (e) ->
assert.equal e.message, 'object function object' assert.equal e.message, 'object undefined object'
done() done()
webview.setAttribute 'preload', "#{fixtures}/module/preload-node-off.js" webview.setAttribute 'preload', "#{fixtures}/module/preload-node-off.js"
webview.src = "file://#{fixtures}/api/blank.html" webview.src = "file://#{fixtures}/api/blank.html"

2
vendor/node vendored

@ -1 +1 @@
Subproject commit aa9c7a2316ba7762f1d04d091585695be3e6be22 Subproject commit fa54694af4350bf1720ff47e97a07c7c09325ee2