From 651c6959ab1c61f8304ca260e56faf6b8c03ef69 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 1 Sep 2016 22:28:20 -0600 Subject: [PATCH] Remove ol.global --- src/ol/color.js | 3 +-- src/ol/control/fullscreen.js | 3 +-- src/ol/control/zoomslider.js | 3 +-- src/ol/deviceorientation.js | 2 +- src/ol/dom.js | 8 ++------ src/ol/geolocation.js | 2 -- src/ol/has.js | 17 ++++++++-------- src/ol/index.js | 12 ----------- src/ol/interaction/mousewheelzoom.js | 6 ++---- src/ol/map.js | 21 ++++++++------------ src/ol/mapbrowserevent.js | 3 --- src/ol/net.js | 11 +++++----- src/ol/overlay.js | 5 ++--- src/ol/pointer/touchsource.js | 9 +++------ src/ol/proj/index.js | 4 ++-- src/ol/reproj/index.js | 14 ++++++------- src/ol/reproj/tile.js | 3 +-- src/ol/source/tileutfgrid.js | 4 ++-- test/spec/ol/interaction/draganddrop.test.js | 5 ++--- test/spec/ol/net.test.js | 16 +++++++-------- 20 files changed, 55 insertions(+), 96 deletions(-) diff --git a/src/ol/color.js b/src/ol/color.js index 9381d7e150..5b156d362b 100644 --- a/src/ol/color.js +++ b/src/ol/color.js @@ -1,6 +1,5 @@ goog.provide('ol.color'); -goog.require('ol'); goog.require('ol.asserts'); goog.require('ol.math'); @@ -83,7 +82,7 @@ ol.color.fromNamed = function(color) { var el = document.createElement('div'); el.style.color = color; document.body.appendChild(el); - var rgb = ol.global.getComputedStyle(el).color; + var rgb = getComputedStyle(el).color; document.body.removeChild(el); return rgb; }; diff --git a/src/ol/control/fullscreen.js b/src/ol/control/fullscreen.js index f48eedf4ab..4d5217189e 100644 --- a/src/ol/control/fullscreen.js +++ b/src/ol/control/fullscreen.js @@ -158,10 +158,9 @@ ol.control.FullScreen.prototype.handleFullScreenChange_ = function() { * @api stable */ ol.control.FullScreen.prototype.setMap = function(map) { - var global = ol.global; ol.control.Control.prototype.setMap.call(this, map); if (map) { - this.listenerKeys.push(ol.events.listen(global.document, + this.listenerKeys.push(ol.events.listen(document, ol.control.FullScreen.getChangeType_(), this.handleFullScreenChange_, this) ); diff --git a/src/ol/control/zoomslider.js b/src/ol/control/zoomslider.js index 22fd464bcb..25d99d4442 100644 --- a/src/ol/control/zoomslider.js +++ b/src/ol/control/zoomslider.js @@ -181,14 +181,13 @@ ol.control.ZoomSlider.prototype.setMap = function(map) { * @private */ ol.control.ZoomSlider.prototype.initSlider_ = function() { - var global = ol.global; var container = this.element; var containerSize = { width: container.offsetWidth, height: container.offsetHeight }; var thumb = container.firstElementChild; - var computedStyle = global.getComputedStyle(thumb); + var computedStyle = getComputedStyle(thumb); var thumbWidth = thumb.offsetWidth + parseFloat(computedStyle['marginRight']) + parseFloat(computedStyle['marginLeft']); diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 173381da0b..c106f901bd 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -194,7 +194,7 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { if (ol.has.DEVICE_ORIENTATION) { var tracking = this.getTracking(); if (tracking && !this.listenerKey_) { - this.listenerKey_ = ol.events.listen(ol.global, 'deviceorientation', + this.listenerKey_ = ol.events.listen(window, 'deviceorientation', this.orientationChange_, this); } else if (!tracking && this.listenerKey_ !== null) { ol.events.unlistenByKey(this.listenerKey_); diff --git a/src/ol/dom.js b/src/ol/dom.js index 79d6098cd4..93b08c0fce 100644 --- a/src/ol/dom.js +++ b/src/ol/dom.js @@ -1,7 +1,5 @@ goog.provide('ol.dom'); -goog.require('ol'); - /** * Create an html canvas element and returns its 2d context. @@ -29,9 +27,8 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) { * @return {number} The width. */ ol.dom.outerWidth = function(element) { - var global = ol.global; var width = element.offsetWidth; - var style = element.currentStyle || global.getComputedStyle(element); + var style = element.currentStyle || getComputedStyle(element); width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10); return width; @@ -46,9 +43,8 @@ ol.dom.outerWidth = function(element) { * @return {number} The height. */ ol.dom.outerHeight = function(element) { - var global = ol.global; var height = element.offsetHeight; - var style = element.currentStyle || global.getComputedStyle(element); + var style = element.currentStyle || getComputedStyle(element); height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10); return height; diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 37f6b9f41c..00dd8392e1 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -113,9 +113,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() { * @private */ ol.Geolocation.prototype.handleTrackingChanged_ = function() { - var global = ol.global; if (ol.has.GEOLOCATION) { - var navigator = global.navigator; var tracking = this.getTracking(); if (tracking && this.watchId_ === undefined) { this.watchId_ = navigator.geolocation.watchPosition( diff --git a/src/ol/has.js b/src/ol/has.js index 5c64bd2fb7..21dfb03066 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -3,7 +3,6 @@ goog.provide('ol.has'); goog.require('ol'); goog.require('ol.webgl'); -var olGlobal = ol.global; var ua = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase() : ''; @@ -39,7 +38,7 @@ ol.has.MAC = ua.indexOf('macintosh') !== -1; * @type {number} * @api stable */ -ol.has.DEVICE_PIXEL_RATIO = olGlobal.devicePixelRatio || 1; +ol.has.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; /** @@ -61,7 +60,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && ( * @return {boolean} Canvas supported. */ function() { - if (!('HTMLCanvasElement' in olGlobal)) { + if (!('HTMLCanvasElement' in window)) { return false; } try { @@ -86,7 +85,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && ( * @type {boolean} * @api stable */ -ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in olGlobal; +ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in window; /** @@ -95,7 +94,7 @@ ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in olGlobal; * @type {boolean} * @api stable */ -ol.has.GEOLOCATION = 'geolocation' in olGlobal.navigator; +ol.has.GEOLOCATION = 'geolocation' in navigator; /** @@ -104,7 +103,7 @@ ol.has.GEOLOCATION = 'geolocation' in olGlobal.navigator; * @type {boolean} * @api stable */ -ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in olGlobal; +ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in window; /** @@ -112,7 +111,7 @@ ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in olGlobal; * @const * @type {boolean} */ -ol.has.POINTER = 'PointerEvent' in olGlobal; +ol.has.POINTER = 'PointerEvent' in window; /** @@ -120,7 +119,7 @@ ol.has.POINTER = 'PointerEvent' in olGlobal; * @const * @type {boolean} */ -ol.has.MSPOINTER = !!(olGlobal.navigator.msPointerEnabled); +ol.has.MSPOINTER = !!(navigator.msPointerEnabled); /** @@ -139,7 +138,7 @@ ol.has.WEBGL; var textureSize; var /** @type {Array.} */ extensions = []; - if ('WebGLRenderingContext' in olGlobal) { + if ('WebGLRenderingContext' in window) { try { var canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS')); diff --git a/src/ol/index.js b/src/ol/index.js index 697b11a25f..27a0c659d6 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -288,15 +288,3 @@ ol.getUid = function(obj) { * @private */ ol.uidCounter_ = 0; - - -/** - * @see https://github.com/tc39/proposal-global - */ -if (typeof window !== 'undefined') { - ol.global = window; -} else if (typeof global !== 'undefined') { - ol.global = global; -} else if (typeof self !== 'undefined') { - ol.global = self; -} diff --git a/src/ol/interaction/mousewheelzoom.js b/src/ol/interaction/mousewheelzoom.js index 91a1eb74c2..395d32c33a 100644 --- a/src/ol/interaction/mousewheelzoom.js +++ b/src/ol/interaction/mousewheelzoom.js @@ -87,8 +87,6 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { // https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js //TODO There's more good stuff in there for inspiration to improve this interaction. var delta; - var global = ol.global; - var WheelEvent = global.WheelEvent; if (mapBrowserEvent.type == ol.events.EventType.WHEEL) { delta = wheelEvent.deltaY; if (ol.has.FIREFOX && @@ -114,8 +112,8 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION; var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0); - global.clearTimeout(this.timeoutId_); - this.timeoutId_ = global.setTimeout( + clearTimeout(this.timeoutId_); + this.timeoutId_ = setTimeout( this.doZoom_.bind(this, map), timeLeft); mapBrowserEvent.preventDefault(); diff --git a/src/ol/map.js b/src/ol/map.js index 1ad430c15e..2c80a96c55 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -550,7 +550,6 @@ ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) { * @inheritDoc */ ol.Map.prototype.disposeInternal = function() { - var global = ol.global; this.mapBrowserEventHandler_.dispose(); this.renderer_.dispose(); ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL, @@ -558,12 +557,12 @@ ol.Map.prototype.disposeInternal = function() { ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL, this.handleBrowserEvent, this); if (this.handleResize_ !== undefined) { - global.removeEventListener(ol.events.EventType.RESIZE, + window.removeEventListener(ol.events.EventType.RESIZE, this.handleResize_, false); this.handleResize_ = undefined; } if (this.animationDelayKey_) { - global.cancelAnimationFrame(this.animationDelayKey_); + cancelAnimationFrame(this.animationDelayKey_); this.animationDelayKey_ = undefined; } this.setTarget(null); @@ -1037,7 +1036,6 @@ ol.Map.prototype.handleSizeChanged_ = function() { * @private */ ol.Map.prototype.handleTargetChanged_ = function() { - var global = ol.global; // target may be undefined, null, a string or an Element. // If it's a string we convert it to an Element before proceeding. // If it's not now an Element we remove the viewport from the DOM. @@ -1060,7 +1058,7 @@ ol.Map.prototype.handleTargetChanged_ = function() { if (!targetElement) { ol.dom.removeNode(this.viewport_); if (this.handleResize_ !== undefined) { - global.removeEventListener(ol.events.EventType.RESIZE, + window.removeEventListener(ol.events.EventType.RESIZE, this.handleResize_, false); this.handleResize_ = undefined; } @@ -1078,7 +1076,7 @@ ol.Map.prototype.handleTargetChanged_ = function() { if (!this.handleResize_) { this.handleResize_ = this.updateSize.bind(this); - global.addEventListener(ol.events.EventType.RESIZE, + window.addEventListener(ol.events.EventType.RESIZE, this.handleResize_, false); } } @@ -1159,9 +1157,8 @@ ol.Map.prototype.isRendered = function() { * @api stable */ ol.Map.prototype.renderSync = function() { - var global = ol.global; if (this.animationDelayKey_) { - global.cancelAnimationFrame(this.animationDelayKey_); + cancelAnimationFrame(this.animationDelayKey_); } this.animationDelay_(); }; @@ -1172,9 +1169,8 @@ ol.Map.prototype.renderSync = function() { * @api stable */ ol.Map.prototype.render = function() { - var global = ol.global; if (this.animationDelayKey_ === undefined) { - this.animationDelayKey_ = global.requestAnimationFrame( + this.animationDelayKey_ = requestAnimationFrame( this.animationDelay_); } }; @@ -1314,7 +1310,7 @@ ol.Map.prototype.renderFrame_ = function(time) { this.dispatchEvent( new ol.MapEvent(ol.MapEventType.POSTRENDER, this, frameState)); - ol.global.setTimeout(this.handlePostRender.bind(this), 0); + setTimeout(this.handlePostRender.bind(this), 0); }; @@ -1381,13 +1377,12 @@ ol.Map.prototype.skipFeature = function(feature) { * @api stable */ ol.Map.prototype.updateSize = function() { - var global = ol.global; var targetElement = this.getTargetElement(); if (!targetElement) { this.setSize(undefined); } else { - var computedStyle = global.getComputedStyle(targetElement); + var computedStyle = getComputedStyle(targetElement); this.setSize([ targetElement.offsetWidth - parseFloat(computedStyle['borderLeftWidth']) - diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index 90aa80f00c..30cc787eda 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -214,9 +214,6 @@ ol.inherits(ol.MapBrowserEventHandler, ol.events.EventTarget); * @private */ ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) { - var global = ol.global; - var clearTimeout = global.clearTimeout; - var setTimeout = global.setTimeout; var newEvent = new ol.MapBrowserPointerEvent( ol.MapBrowserEvent.EventType.CLICK, this.map_, pointerEvent); this.dispatchEvent(newEvent); diff --git a/src/ol/net.js b/src/ol/net.js index 0775bf2bd1..0fe398d97a 100644 --- a/src/ol/net.js +++ b/src/ol/net.js @@ -15,24 +15,23 @@ goog.require('ol'); * callback. Default is 'callback'. */ ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) { - var global = ol.global; - var script = global.document.createElement('script'); + var script = document.createElement('script'); var key = 'olc_' + ol.getUid(callback); function cleanup() { - delete global[key]; + delete window[key]; script.parentNode.removeChild(script); } script.async = true; script.src = url + (url.indexOf('?') == -1 ? '?' : '&') + (opt_callbackParam || 'callback') + '=' + key; - var timer = global.setTimeout(function() { + var timer = setTimeout(function() { cleanup(); if (opt_errback) { opt_errback(); } }, 10000); - global[key] = function(data) { - global.clearTimeout(timer); + window[key] = function(data) { + clearTimeout(timer); cleanup(); callback(data); }; diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 947f84afe8..93243560ee 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -398,10 +398,9 @@ ol.Overlay.prototype.panIntoView_ = function() { * @private */ ol.Overlay.prototype.getRect_ = function(element, size) { - var global = ol.global; var box = element.getBoundingClientRect(); - var offsetX = box.left + global.pageXOffset; - var offsetY = box.top + global.pageYOffset; + var offsetX = box.left + window.pageXOffset; + var offsetY = box.top + window.pageYOffset; return [ offsetX, offsetY, diff --git a/src/ol/pointer/touchsource.js b/src/ol/pointer/touchsource.js index e20dd8c072..6653bd3aab 100644 --- a/src/ol/pointer/touchsource.js +++ b/src/ol/pointer/touchsource.js @@ -148,8 +148,7 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) { * @private */ ol.pointer.TouchSource.prototype.resetClickCount_ = function() { - var global = ol.global; - this.resetId_ = global.setTimeout( + this.resetId_ = setTimeout( this.resetClickCountHandler_.bind(this), ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT); }; @@ -168,9 +167,8 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() { * @private */ ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { - var global = ol.global; if (this.resetId_ !== undefined) { - global.clearTimeout(this.resetId_); + clearTimeout(this.resetId_); } }; @@ -442,8 +440,7 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) { var lt = [t.clientX, t.clientY]; lts.push(lt); - var global = ol.global; - global.setTimeout(function() { + setTimeout(function() { // remove touch after timeout ol.array.remove(lts, lt); }, ol.pointer.TouchSource.DEDUP_TIMEOUT); diff --git a/src/ol/proj/index.js b/src/ol/proj/index.js index 7afbeddbdb..f88d7bf714 100644 --- a/src/ol/proj/index.js +++ b/src/ol/proj/index.js @@ -139,7 +139,7 @@ ol.proj.Projection = function(options) { ol.DEBUG && console.assert(code !== undefined, 'Option "code" is required for constructing instance'); if (ol.ENABLE_PROJ4JS) { - var proj4js = ol.proj.proj4_ || ol.global['proj4']; + var proj4js = ol.proj.proj4_ || window['proj4']; if (typeof proj4js == 'function' && projections[code] === undefined) { var def = proj4js.defs(code); if (def !== undefined) { @@ -668,7 +668,7 @@ ol.proj.get = function(projectionLike) { var code = projectionLike; projection = ol.proj.projections_[code]; if (ol.ENABLE_PROJ4JS) { - var proj4js = ol.proj.proj4_ || ol.global['proj4']; + var proj4js = ol.proj.proj4_ || window['proj4']; if (projection === undefined && typeof proj4js == 'function' && proj4js.defs(code) !== undefined) { projection = new ol.proj.Projection({code: code}); diff --git a/src/ol/reproj/index.js b/src/ol/reproj/index.js index 413d0b15af..a804c4eec2 100644 --- a/src/ol/reproj/index.js +++ b/src/ol/reproj/index.js @@ -17,18 +17,18 @@ goog.require('ol.proj'); * @type {boolean} * @private */ -ol.reproj.browserAntialiasesClip_ = (function(global) { +ol.reproj.browserAntialiasesClip_ = (function() { // Adapted from http://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome - var isOpera = global.navigator.userAgent.indexOf('OPR') > -1; - var isIEedge = global.navigator.userAgent.indexOf('Edge') > -1; + var isOpera = navigator.userAgent.indexOf('OPR') > -1; + var isIEedge = navigator.userAgent.indexOf('Edge') > -1; return !( - !global.navigator.userAgent.match('CriOS') && // Not Chrome on iOS - global.chrome !== null && global.chrome !== undefined && // Has chrome in window - global.navigator.vendor === 'Google Inc.' && // Vendor is Google. + !navigator.userAgent.match('CriOS') && // Not Chrome on iOS + 'chrome' in window && // Has chrome in window + navigator.vendor === 'Google Inc.' && // Vendor is Google. isOpera == false && // Not Opera isIEedge == false // Not Edge ); -})(ol.global); +})(); /** diff --git a/src/ol/reproj/tile.js b/src/ol/reproj/tile.js index b62493ed33..0d6585f89f 100644 --- a/src/ol/reproj/tile.js +++ b/src/ol/reproj/tile.js @@ -300,8 +300,7 @@ ol.reproj.Tile.prototype.load = function() { }); if (leftToLoad === 0) { - var global = ol.global; - global.setTimeout(this.reproject_.bind(this), 0); + setTimeout(this.reproject_.bind(this), 0); } } }; diff --git a/src/ol/source/tileutfgrid.js b/src/ol/source/tileutfgrid.js index 0e897d3763..1634578711 100644 --- a/src/ol/source/tileutfgrid.js +++ b/src/ol/source/tileutfgrid.js @@ -139,7 +139,7 @@ ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function( tile.forDataAtCoordinate(coordinate, callback, opt_this, opt_request); } else { if (opt_request === true) { - ol.global.setTimeout(function() { + setTimeout(function() { callback.call(opt_this, null); }, 0); } else { @@ -389,7 +389,7 @@ ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate, this.loadInternal_(); } else { if (opt_request === true) { - ol.global.setTimeout(function() { + setTimeout(function() { callback.call(opt_this, this.getData(coordinate)); }.bind(this), 0); } else { diff --git a/test/spec/ol/interaction/draganddrop.test.js b/test/spec/ol/interaction/draganddrop.test.js index 4178d26c95..0515c119db 100644 --- a/test/spec/ol/interaction/draganddrop.test.js +++ b/test/spec/ol/interaction/draganddrop.test.js @@ -10,7 +10,6 @@ goog.require('ol.interaction.DragAndDrop'); describe('ol.interaction.DragAndDrop', function() { var viewport, map, interaction; - var global = ol.global; beforeEach(function() { viewport = new ol.events.EventTarget(); @@ -71,7 +70,7 @@ describe('ol.interaction.DragAndDrop', function() { }); describe('#handleDrop_', function() { - var origFileReader = global.FileReader; + var OrigFileReader = FileReader; beforeEach(function() { FileReader = function() { @@ -85,7 +84,7 @@ describe('ol.interaction.DragAndDrop', function() { }); afterEach(function() { - global.FileReader = origFileReader; + FileReader = OrigFileReader; }); it('reads dropped files', function(done) { diff --git a/test/spec/ol/net.test.js b/test/spec/ol/net.test.js index f4b171ffe6..f6cebdd4a6 100644 --- a/test/spec/ol/net.test.js +++ b/test/spec/ol/net.test.js @@ -5,13 +5,11 @@ goog.require('ol.net'); describe('ol.net', function() { - var global = ol.global; - describe('jsonp()', function() { - var head = global.document.getElementsByTagName('head')[0]; + var head = document.getElementsByTagName('head')[0]; var origAppendChild = head.appendChild; var origCreateElement = document.createElement; - var origSetTimeout = global.setTimeout; + var origSetTimeout = setTimeout; var key, removeChild; function createCallback(url, done) { @@ -31,7 +29,7 @@ describe('ol.net', function() { if (arg == 'script') { return element; } else { - return origCreateElement.apply(global.document, arguments); + return origCreateElement.apply(document, arguments); } }; head.appendChild = function(el) { @@ -40,13 +38,13 @@ describe('ol.net', function() { removeChild: removeChild }; origSetTimeout(function() { - global[key](element.src); + window[key](element.src); }, 0); } else { origAppendChild.apply(head, arguments); } }; - global.setTimeout = function(fn, time) { + setTimeout = function(fn, time) { origSetTimeout(fn, 100); }; }); @@ -54,7 +52,7 @@ describe('ol.net', function() { afterEach(function() { document.createElement = origCreateElement; head.appendChild = origAppendChild; - global.setTimeout = origSetTimeout; + setTimeout = origSetTimeout; }); it('appends callback param to url, cleans up after call', function(done) { @@ -74,7 +72,7 @@ describe('ol.net', function() { expect.fail(); } function errback() { - expect(global[key]).to.be(undefined); + expect(window[key]).to.be(undefined); expect(removeChild.called).to.be(true); done(); }