@@ -3,6 +3,7 @@ import run from 'ember-metal/run_loop';
33
44var originalSetTimeout = window . setTimeout ;
55var originalDateValueOf = Date . prototype . valueOf ;
6+ const originalPlatform = run . backburner . _platform ;
67
78function wait ( callback , maxWaitCount ) {
89 maxWaitCount = isNone ( maxWaitCount ) ? 100 : maxWaitCount ;
@@ -33,6 +34,7 @@ function pauseUntil(time) {
3334
3435QUnit . module ( 'run.later' , {
3536 teardown ( ) {
37+ run . backburner . _platform = originalPlatform ;
3638 window . setTimeout = originalSetTimeout ;
3739 Date . prototype . valueOf = originalDateValueOf ;
3840 }
@@ -197,13 +199,14 @@ asyncTest('setTimeout should never run with a negative wait', function() {
197199 // happens when an expired timer callback takes a while to run,
198200 // which is what we simulate here.
199201 var newSetTimeoutUsed ;
200- window . setTimeout = function ( ) {
201- var wait = arguments [ arguments . length - 1 ] ;
202- newSetTimeoutUsed = true ;
203- ok ( ! isNaN ( wait ) && wait >= 0 , 'wait is a non-negative number' ) ;
204- // In IE8, `setTimeout.apply` is `undefined`.
205- var apply = Function . prototype . apply ;
206- return apply . apply ( originalSetTimeout , [ this , arguments ] ) ;
202+ run . backburner . _platform = {
203+ setTimeout ( ) {
204+ var wait = arguments [ arguments . length - 1 ] ;
205+ newSetTimeoutUsed = true ;
206+ ok ( ! isNaN ( wait ) && wait >= 0 , 'wait is a non-negative number' ) ;
207+
208+ return originalPlatform . setTimeout . apply ( originalPlatform , arguments ) ;
209+ }
207210 } ;
208211
209212 var count = 0 ;
@@ -226,7 +229,6 @@ asyncTest('setTimeout should never run with a negative wait', function() {
226229 } ) ;
227230
228231 wait ( function ( ) {
229- window . setTimeout = originalSetTimeout ;
230232 QUnit . start ( ) ;
231233 ok ( newSetTimeoutUsed , 'stub setTimeout was used' ) ;
232234 } ) ;
0 commit comments