Bug 1338069 - Don't use 'window' object when using getComputedStyle in tests. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Thu, 06 Apr 2017 12:43:47 +0900
changeset 556604 e457c1c65125b1fc4751a981be52bf07341308b2
parent 556469 867df9483d5af4c8c12e19fab9b0de18bee30db7
child 622930 0991e51c39267b1a9128a0cd24ba0a9fcc5fd3e5
push id52593
push usermantaroh@gmail.com
push dateThu, 06 Apr 2017 03:46:47 +0000
reviewersbirtles
bugs1338069
milestone55.0a1
Bug 1338069 - Don't use 'window' object when using getComputedStyle in tests. r?birtles MozReview-Commit-ID: KWUNCIaF183
dom/animation/test/css-animations/file_animation-finished.html
dom/animation/test/css-animations/file_animation-pausing.html
dom/animation/test/css-animations/file_animation-playstate.html
dom/animation/test/css-animations/file_animation-ready.html
dom/animation/test/css-animations/file_element-get-animations.html
dom/animation/test/css-transitions/file_animation-pausing.html
dom/animation/test/css-transitions/file_animation-ready.html
dom/animation/test/css-transitions/file_csstransition-transitionproperty.html
dom/animation/test/css-transitions/file_effect-target.html
dom/animation/test/css-transitions/file_element-get-animations.html
dom/animation/test/css-transitions/file_keyframeeffect-getkeyframes.html
dom/animation/test/css-transitions/file_setting-effect.html
dom/animation/test/document-timeline/file_document-timeline.html
dom/animation/test/mozilla/file_deferred_start.html
dom/animation/test/testcommon.js
--- a/dom/animation/test/css-animations/file_animation-finished.html
+++ b/dom/animation/test/css-animations/file_animation-finished.html
@@ -28,17 +28,17 @@ promise_test(function(t) {
                   'finished promise is rejected with AbortError');
     assert_not_equals(animation.finished, previousFinishedPromise,
                       'Finished promise should change after the original is ' +
                       'rejected');
   });
 
   // Now cancel the animation and flush styles
   div.style.animation = '';
-  window.getComputedStyle(div).animation;
+  getComputedStyle(div).animation;
 
   return retPromise;
 }, 'finished promise is rejected when an animation is cancelled by resetting ' +
    'the animation property');
 
 promise_test(function(t) {
   var div = addDiv(t);
   // As before, but this time instead of removing all animations, simply update
@@ -58,17 +58,17 @@ promise_test(function(t) {
                   'finished promise is rejected with AbortError');
     assert_not_equals(animation.finished, previousFinishedPromise,
                       'Finished promise should change after the original is ' +
                       'rejected');
   });
 
   // Now update the animation and flush styles
   div.style.animation = 'def 100s';
-  window.getComputedStyle(div).animation;
+  getComputedStyle(div).animation;
 
   return retPromise;
 }, 'finished promise is rejected when an animation is cancelled by changing ' +
    'the animation property');
 
 promise_test(function(t) {
   var div = addDiv(t);
   div.style.animation = ANIM_PROP_VAL;
--- a/dom/animation/test/css-animations/file_animation-pausing.html
+++ b/dom/animation/test/css-animations/file_animation-pausing.html
@@ -12,32 +12,32 @@
 'use strict';
 
 function getMarginLeft(cs) {
   return parseFloat(cs.marginLeft);
 }
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   assert_equals(getMarginLeft(cs), 0,
                 'Initial value of margin-left is zero');
   animation.play();
 
   return animation.ready.then(waitForFrame).then(function() {
     assert_true(getMarginLeft(cs) > 0,
                 'Playing value of margin-left is greater than zero');
   });
 }, 'play() overrides animation-play-state');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   assert_equals(getMarginLeft(cs), 0,
                 'Initial value of margin-left is zero');
 
   animation.pause();
   div.style.animationPlayState = 'running';
 
@@ -46,17 +46,17 @@ promise_test(function(t) {
                   'animation-play-state is running');
     assert_equals(getMarginLeft(cs), 0,
                   'Paused value of margin-left is zero');
   });
 }, 'pause() overrides animation-play-state');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   assert_equals(getMarginLeft(cs), 0,
                 'Initial value of margin-left is zero');
   animation.play();
   var previousAnimVal;
 
   return animation.ready.then(function() {
@@ -77,17 +77,17 @@ promise_test(function(t) {
     assert_equals(getMarginLeft(cs), previousAnimVal,
                   'Animated value of margin-left does not change when'
                   + ' paused by style');
   });
 }, 'play() is overridden by later setting "animation-play-state: paused"');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s';
   var animation = div.getAnimations()[0];
   assert_equals(getMarginLeft(cs), 0,
                 'Initial value of margin-left is zero');
 
   // Set the specified style first. If implementations fail to
   // apply the style changes first, they will ignore the redundant
   // call to play() and fail to correctly override the pause style.
@@ -100,17 +100,17 @@ promise_test(function(t) {
                   'animation-play-state is paused');
     assert_true(getMarginLeft(cs) > previousAnimVal,
                 'Playing value of margin-left is increasing');
   });
 }, 'play() flushes pending changes to animation-play-state first');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   assert_equals(getMarginLeft(cs), 0,
                 'Initial value of margin-left is zero');
 
   // Unlike the previous test for play(), since calling pause() is sticky,
   // we'll apply it even if the underlying style also says we're paused.
   //
--- a/dom/animation/test/css-animations/file_animation-playstate.html
+++ b/dom/animation/test/css-animations/file_animation-playstate.html
@@ -5,54 +5,54 @@
 @keyframes anim { }
 </style>
 <body>
 <script>
 'use strict';
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s';
   var animation = div.getAnimations()[0];
   assert_equals(animation.playState, 'pending');
 
   return animation.ready.then(function() {
     assert_equals(animation.playState, 'running');
   });
 }, 'Animation returns correct playState when running');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   assert_equals(animation.playState, 'pending');
 
   return animation.ready.then(function() {
     assert_equals(animation.playState, 'paused');
   });
 }, 'Animation returns correct playState when paused');
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s';
   var animation = div.getAnimations()[0];
   animation.pause();
   assert_equals(animation.playState, 'pending');
 
   return animation.ready.then(function() {
     assert_equals(animation.playState, 'paused');
   });
 }, 'Animation.playState updates when paused by script');
 
 test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
   var animation = div.getAnimations()[0];
   div.style.animationPlayState = 'running';
 
   // This test also checks that calling playState flushes style
   assert_equals(animation.playState, 'pending',
                 'Animation.playState reports pending after updating'
                 + ' animation-play-state (got: ' + animation.playState + ')');
--- a/dom/animation/test/css-animations/file_animation-ready.html
+++ b/dom/animation/test/css-animations/file_animation-ready.html
@@ -38,17 +38,17 @@ promise_test(function(t) {
     assert_unreached('ready promise is fulfilled');
   }).catch(function(err) {
     assert_equals(err.name, 'AbortError',
                   'ready promise is rejected with AbortError');
   });
 
   // Now cancel the animation and flush styles
   div.style.animation = '';
-  window.getComputedStyle(div).animation;
+  getComputedStyle(div).animation;
 
   return retPromise;
 }, 'ready promise is rejected when an animation is cancelled by resetting'
    + ' the animation property');
 
 promise_test(function(t) {
   var div = addDiv(t);
 
@@ -67,17 +67,17 @@ promise_test(function(t) {
     assert_unreached('ready promise was fulfilled');
   }).catch(function(err) {
     assert_equals(err.name, 'AbortError',
                   'ready promise is rejected with AbortError');
   });
 
   // Now update the animation and flush styles
   div.style.animation = 'def 100s';
-  window.getComputedStyle(div).animation;
+  getComputedStyle(div).animation;
 
   return retPromise;
 }, 'ready promise is rejected when an animation is cancelled by updating'
    + ' the animation property');
 
 promise_test(function(t) {
   var div = addDiv(t, { style: 'animation: abc 100s' });
   var animation = div.getAnimations()[0];
--- a/dom/animation/test/css-animations/file_element-get-animations.html
+++ b/dom/animation/test/css-animations/file_element-get-animations.html
@@ -78,17 +78,17 @@ test(function(t) {
 }, 'getAnimations for multi-property animations');
 
 promise_test(function(t) {
   var div = addDiv(t);
 
   // Add an animation
   div.style.backgroundColor = 'red';
   div.style.animation = 'anim1 100s';
-  window.getComputedStyle(div).backgroundColor;
+  getComputedStyle(div).backgroundColor;
 
   // Wait until a frame after the animation starts, then add a transition
   var animations = div.getAnimations();
   return animations[0].ready.then(waitForFrame).then(function() {
     div.style.transition = 'all 100s';
     div.style.backgroundColor = 'green';
 
     animations = div.getAnimations();
--- a/dom/animation/test/css-transitions/file_animation-pausing.html
+++ b/dom/animation/test/css-transitions/file_animation-pausing.html
@@ -6,17 +6,17 @@
 'use strict';
 
 function getMarginLeft(cs) {
   return parseFloat(cs.marginLeft);
 }
 
 async_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
 
   div.style.marginLeft = '0px';
   cs.marginLeft; // Flush style to set up transition start point
   div.style.transition = 'margin-left 100s';
   div.style.marginLeft = '10000px';
   cs.marginLeft;
 
   var animation = div.getAnimations()[0];
--- a/dom/animation/test/css-transitions/file_animation-ready.html
+++ b/dom/animation/test/css-transitions/file_animation-ready.html
@@ -3,20 +3,20 @@
 <script src="../testcommon.js"></script>
 <body>
 <script>
 'use strict';
 
 async_test(function(t) {
   var div = addDiv(t);
   div.style.transform = 'translate(0px)';
-  window.getComputedStyle(div).transform;
+  getComputedStyle(div).transform;
   div.style.transition = 'transform 100s';
   div.style.transform = 'translate(10px)';
-  window.getComputedStyle(div).transform;
+  getComputedStyle(div).transform;
 
   var animation = div.getAnimations()[0];
   var originalReadyPromise = animation.ready;
 
   animation.ready.then(t.step_func(function() {
     assert_equals(animation.ready, originalReadyPromise,
                   'Ready promise is the same object when playing completes');
     animation.pause();
@@ -27,20 +27,20 @@ async_test(function(t) {
 }, 'A new ready promise is created each time play() is called'
    + ' the animation property');
 
 async_test(function(t) {
   var div = addDiv(t);
 
   // Set up pending transition
   div.style.transform = 'translate(0px)';
-  window.getComputedStyle(div).transform;
+  getComputedStyle(div).transform;
   div.style.transition = 'transform 100s';
   div.style.transform = 'translate(10px)';
-  window.getComputedStyle(div).transform;
+  getComputedStyle(div).transform;
 
   var animation = div.getAnimations()[0];
   assert_equals(animation.playState, 'pending', 'Animation is initially pending');
 
   // Set up listeners on ready promise
   animation.ready.then(t.step_func(function() {
     assert_unreached('ready promise was fulfilled');
   })).catch(t.step_func(function(err) {
@@ -49,30 +49,30 @@ async_test(function(t) {
     assert_equals(animation.playState, 'idle',
                   'Animation is idle after transition was cancelled');
   })).then(t.step_func(function() {
     t.done();
   }));
 
   // Now remove transform from transition-property and flush styles
   div.style.transitionProperty = 'none';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
 
 }, 'ready promise is rejected when a transition is cancelled by updating'
    + ' transition-property');
 
 async_test(function(t) {
   var div = addDiv(t);
 
   // Set up pending transition
   div.style.marginLeft = '0px';
-  window.getComputedStyle(div).marginLeft;
+  getComputedStyle(div).marginLeft;
   div.style.transition = 'margin-left 100s';
   div.style.marginLeft = '100px';
-  window.getComputedStyle(div).marginLeft;
+  getComputedStyle(div).marginLeft;
 
   var animation = div.getAnimations()[0];
   assert_equals(animation.playState, 'pending', 'Animation is initially pending');
 
   // Set up listeners on ready promise
   animation.ready.then(t.step_func(function() {
     assert_unreached('ready promise was fulfilled');
   })).catch(t.step_func(function(err) {
@@ -81,16 +81,16 @@ async_test(function(t) {
     assert_equals(animation.playState, 'idle',
                   'Animation is idle after transition was cancelled');
   })).then(t.step_func(function() {
     t.done();
   }));
 
   // Now update the transition to animate to something not-interpolable
   div.style.marginLeft = 'auto';
-  window.getComputedStyle(div).marginLeft;
+  getComputedStyle(div).marginLeft;
 
 }, 'ready promise is rejected when a transition is cancelled by changing'
    + ' the transition property to something not interpolable');
 
 done();
 </script>
 </body>
--- a/dom/animation/test/css-transitions/file_csstransition-transitionproperty.html
+++ b/dom/animation/test/css-transitions/file_csstransition-transitionproperty.html
@@ -5,17 +5,17 @@
 <script>
 'use strict';
 
 test(function(t) {
   var div = addDiv(t);
 
   // Add a transition
   div.style.left = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'all 100s';
   div.style.left = '100px';
 
   assert_equals(div.getAnimations()[0].transitionProperty, 'left',
                 'The transitionProperty for the corresponds to the specific ' +
                 'property being transitioned');
 }, 'CSSTransition.transitionProperty');
 
--- a/dom/animation/test/css-transitions/file_effect-target.html
+++ b/dom/animation/test/css-transitions/file_effect-target.html
@@ -4,17 +4,17 @@
 <body>
 <script>
 'use strict';
 
 test(function(t) {
   var div = addDiv(t);
 
   div.style.left = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'left 100s';
   div.style.left = '100px';
 
   var animation = div.getAnimations()[0];
   assert_equals(animation.effect.target, div,
     'Animation.target is the animatable div');
 }, 'Returned CSS transitions have the correct Animation.target');
 
--- a/dom/animation/test/css-transitions/file_element-get-animations.html
+++ b/dom/animation/test/css-transitions/file_element-get-animations.html
@@ -8,17 +8,17 @@
 async_test(function(t) {
   var div = addDiv(t);
 
   // FIXME: This test does too many things. It should be split up.
 
   // Add a couple of transitions
   div.style.left = '0px';
   div.style.top = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
 
   div.style.transition = 'all 100s';
   div.style.left = '100px';
   div.style.top = '100px';
 
   var animations = div.getAnimations();
   assert_equals(animations.length, 2,
     'getAnimations() returns one Animation per transitioning property');
@@ -61,43 +61,43 @@ async_test(function(t) {
   div.addEventListener('transitionend', t.step_func(function() {
     assert_equals(div.getAnimations().length, 0,
       'getAnimations does not return finished CSS Transitions');
     t.done();
   }));
 
   // Add a very short transition
   div.style.left = '0px';
-  window.getComputedStyle(div).left;
+  getComputedStyle(div).left;
 
   div.style.transition = 'all 0.01s';
   div.style.left = '100px';
-  window.getComputedStyle(div).left;
+  getComputedStyle(div).left;
 }, 'getAnimations for CSS Transitions that have finished');
 
 test(function(t) {
   var div = addDiv(t);
 
   // Try to transition non-animatable property animation-duration
   div.style.animationDuration = '10s';
-  window.getComputedStyle(div).animationDuration;
+  getComputedStyle(div).animationDuration;
 
   div.style.transition = 'all 100s';
   div.style.animationDuration = '100s';
 
   assert_equals(div.getAnimations().length, 0,
     'getAnimations returns an empty sequence for a transition'
     + ' of a non-animatable property');
 }, 'getAnimations for transition on non-animatable property');
 
 test(function(t) {
   var div = addDiv(t);
 
   div.style.setProperty('-vendor-unsupported', '0px', '');
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'all 100s';
   div.style.setProperty('-vendor-unsupported', '100px', '');
 
   assert_equals(div.getAnimations().length, 0,
     'getAnimations returns an empty sequence for a transition'
     + ' of an unsupported property');
 }, 'getAnimations for transition on unsupported property');
 
--- a/dom/animation/test/css-transitions/file_keyframeeffect-getkeyframes.html
+++ b/dom/animation/test/css-transitions/file_keyframeeffect-getkeyframes.html
@@ -22,17 +22,17 @@ function assert_frames_equal(a, b, name)
     assert_equals(a[p], b[p], "value for '" + p + "' on " + name);
   }
 }
 
 test(function(t) {
   var div = addDiv(t);
 
   div.style.left = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'left 100s';
   div.style.left = '100px';
 
   var frames = getKeyframes(div);
 
   assert_equals(frames.length, 2, "number of frames");
 
   var expected = [
@@ -45,17 +45,17 @@ test(function(t) {
   }
 }, 'KeyframeEffectReadOnly.getKeyframes() returns expected frames for a simple'
    + ' transition');
 
 test(function(t) {
   var div = addDiv(t);
 
   div.style.left = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'left 100s steps(2,end)';
   div.style.left = '100px';
 
   var frames = getKeyframes(div);
 
   assert_equals(frames.length, 2, "number of frames");
 
   var expected = [
@@ -67,17 +67,17 @@ test(function(t) {
     assert_frames_equal(frames[i], expected[i], "ComputedKeyframe #" + i);
   }
 }, 'KeyframeEffectReadOnly.getKeyframes() returns expected frames for a simple'
    + ' transition with a non-default easing function');
 
 test(function(t) {
   var div = addDiv(t);
   div.style.left = '0px';
-  window.getComputedStyle(div).transitionProperty;
+  getComputedStyle(div).transitionProperty;
   div.style.transition = 'left 100s';
   div.style.left = 'var(--var-100px)';
 
   var frames = getKeyframes(div);
 
   // CSS transition endpoints are based on the computed value so we
   // shouldn't see the variable reference
   var expected = [
--- a/dom/animation/test/css-transitions/file_setting-effect.html
+++ b/dom/animation/test/css-transitions/file_setting-effect.html
@@ -16,17 +16,17 @@ promise_test(function(t) {
   div.style.left = '100px';
 
   var transition = div.getAnimations()[0];
   return transition.ready.then(function() {
     transition.currentTime = 50 * MS_PER_SEC;
     transition.effect = null;
     assert_equals(transition.transitionProperty, 'left');
     assert_equals(transition.playState, 'finished');
-    assert_equals(window.getComputedStyle(div).left, '100px');
+    assert_equals(getComputedStyle(div).left, '100px');
     return watcher.wait_for('transitionend');
   });
 }, 'Test for removing a transition effect');
 
 promise_test(function(t) {
   var div = addDiv(t);
   var watcher = new EventWatcher(t, div, [ 'transitionend',
                                            'transitioncancel' ]);
@@ -39,18 +39,18 @@ promise_test(function(t) {
   var transition = div.getAnimations()[0];
   return transition.ready.then(function() {
     transition.currentTime = 50 * MS_PER_SEC;
     transition.effect = new KeyframeEffect(div,
                                            { marginLeft: [ '0px' , '100px'] },
                                            100 * MS_PER_SEC);
     assert_equals(transition.transitionProperty, 'left');
     assert_equals(transition.playState, 'running');
-    assert_equals(window.getComputedStyle(div).left, '100px');
-    assert_equals(window.getComputedStyle(div).marginLeft, '50px');
+    assert_equals(getComputedStyle(div).left, '100px');
+    assert_equals(getComputedStyle(div).marginLeft, '50px');
   });
 }, 'Test for replacing the transition effect by a new keyframe effect');
 
 promise_test(function(t) {
   var div = addDiv(t);
   var watcher = new EventWatcher(t, div, [ 'transitionend',
                                            'transitioncancel' ]);
   div.style.left = '0px';
--- a/dom/animation/test/document-timeline/file_document-timeline.html
+++ b/dom/animation/test/document-timeline/file_document-timeline.html
@@ -97,27 +97,27 @@ test(function() {
 async_test(function(t) {
   var hiddenIFrame = document.getElementById('hidden-iframe');
 
   // Don't run the test until after the iframe has completed loading or else the
   // contentDocument may change.
   var testToRunOnLoad = t.step_func(function() {
     // Remove display:none
     hiddenIFrame.style.display = 'block';
-    window.getComputedStyle(hiddenIFrame).display;
+    getComputedStyle(hiddenIFrame).display;
 
     window.requestAnimationFrame(t.step_func(function() {
       assert_true(hiddenIFrame.contentDocument.timeline.currentTime > 0,
         'document.timeline.currentTime is positive after removing'
         + ' display:none');
       var previousValue = hiddenIFrame.contentDocument.timeline.currentTime;
 
       // Re-introduce display:none
       hiddenIFrame.style.display = 'none';
-      window.getComputedStyle(hiddenIFrame).display;
+      getComputedStyle(hiddenIFrame).display;
 
       window.requestAnimationFrame(t.step_func(function() {
         assert_true(
           hiddenIFrame.contentDocument.timeline.currentTime >= previousValue,
           'document.timeline.currentTime does not go backwards after'
           + ' re-setting display:none');
         t.done();
       }));
--- a/dom/animation/test/mozilla/file_deferred_start.html
+++ b/dom/animation/test/mozilla/file_deferred_start.html
@@ -32,17 +32,17 @@ function waitForDocLoad() {
 function waitForPaints() {
   return new Promise(function(resolve, reject) {
     waitForAllPaintsFlushed(resolve);
   });
 }
 
 promise_test(function(t) {
   var div = addDiv(t);
-  var cs = window.getComputedStyle(div);
+  var cs = getComputedStyle(div);
 
   // Test that empty animations actually start.
   //
   // Normally we tie the start of animations to when their first frame of
   // the animation is rendered. However, for animations that don't actually
   // trigger a paint (e.g. because they are empty, or are animating something
   // that doesn't render or is offscreen) we want to make sure they still
   // start.
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -247,17 +247,17 @@ function waitForAllAnimations(animations
 
 /**
  * Flush the computed style for the given element. This is useful, for example,
  * when we are testing a transition and need the initial value of a property
  * to be computed so that when we synchronouslyet set it to a different value
  * we actually get a transition instead of that being the initial value.
  */
 function flushComputedStyle(elem) {
-  var cs = window.getComputedStyle(elem);
+  var cs = getComputedStyle(elem);
   cs.marginLeft;
 }
 
 if (opener) {
   for (var funcName of ["async_test", "assert_not_equals", "assert_equals",
                         "assert_approx_equals", "assert_less_than",
                         "assert_less_than_equal", "assert_greater_than",
                         "assert_greater_than_equal",