mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add more window globals and shims in task shell
This allows jQuery to be successfully loaded from a web worker since it does not have a document or window object by default. Previously it would log about missing methods and properties. Closes #228
This commit is contained in:
4
spec/fixtures/jquery-task-handler.coffee
vendored
Normal file
4
spec/fixtures/jquery-task-handler.coffee
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports =
|
||||
load: ->
|
||||
$ = require 'jquery'
|
||||
callTaskMethod('loaded', $?)
|
||||
23
spec/stdlib/task-shell-spec.coffee
Normal file
23
spec/stdlib/task-shell-spec.coffee
Normal file
@@ -0,0 +1,23 @@
|
||||
Task = require 'task'
|
||||
|
||||
describe "Task shell", ->
|
||||
describe "populating the window with fake properties", ->
|
||||
describe "when jQuery is loaded in a web worker", ->
|
||||
it "doesn't log to the console", ->
|
||||
spyOn(console, 'log')
|
||||
spyOn(console, 'error')
|
||||
spyOn(console, 'warn')
|
||||
class JQueryTask extends Task
|
||||
constructor: -> super('fixtures/jquery-task-handler.coffee')
|
||||
started: -> @callWorkerMethod('load')
|
||||
loaded: (@jqueryLoaded) ->
|
||||
|
||||
task = new JQueryTask()
|
||||
task.start()
|
||||
waitsFor "web worker to start and jquery to be required", 5000, ->
|
||||
task.jqueryLoaded
|
||||
runs ->
|
||||
expect(task.jqueryLoaded).toBeTruthy()
|
||||
expect(console.log).not.toHaveBeenCalled()
|
||||
expect(console.error).not.toHaveBeenCalled()
|
||||
expect(console.warn).not.toHaveBeenCalled()
|
||||
Reference in New Issue
Block a user