Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit b620f3a

Browse files
axizo-piyotamberk
authored andcommitted
Eliminate possibility of 'window is undefined' during travis test (#3406)
A recurring problem during travis tests is that global variable `window` can get reset while `Network` tests using a mock canvas object are running. This issue has been adressed several times, but it still happens. This PR reduces the possibility of it happening again to a minimum. PR's affected by this issue should be merged with this fix and re-submitted. At time of writing, these are: - #3402 - #3405 - #3399 Chances are it will occur sporadically for other PR's as well. Labelling this `High Priority` because it indrectly affects unrelated PR's.
1 parent 8a8234d commit b620f3a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/network/modules/CanvasRenderer.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,20 @@ class CanvasRenderer {
149149
//
150150
// This is not something that will happen in normal operation, but we still need
151151
// to take it into account.
152-
if (window === undefined) return;
152+
//
153+
var myWindow = window; // Grab a reference to reduce the possibility that 'window' is reset
154+
// while running this method.
155+
if (myWindow === undefined) return;
153156

154157
let timer;
155158

156159
if (this.requiresTimeout === true) {
157160
// wait given number of milliseconds and perform the animation step function
158-
timer = window.setTimeout(callback, delay);
161+
timer = myWindow.setTimeout(callback, delay);
159162
}
160163
else {
161-
if (window.requestAnimationFrame) {
162-
timer = window.requestAnimationFrame(callback);
164+
if (myWindow.requestAnimationFrame) {
165+
timer = myWindow.requestAnimationFrame(callback);
163166
}
164167
}
165168

0 commit comments

Comments
 (0)