Bug 1277456 part 7 - Add tests for the prototypes of objects created using Animatable.animate(); r?bz draft
authorBrian Birtles <birtles@gmail.com>
Wed, 13 Jul 2016 13:22:25 +0900
changeset 388493 94fff51558e890bea83e60a442bf763ae4c451f4
parent 386963 548b28645091d97093663cbb6d6af6f692e33f95
child 388494 a6c8a6268a230a649f99f429eac0690f40dc1753
push id23192
push userbbirtles@mozilla.com
push dateSat, 16 Jul 2016 04:09:50 +0000
reviewersbz
bugs1277456
milestone50.0a1
Bug 1277456 part 7 - Add tests for the prototypes of objects created using Animatable.animate(); r?bz The spec now defines that we should use the relevant Realm of the target element for the created Animation and KeyframeEffect object.[1] As for the AnimationEffectTiming object associated with the KeyframeEffect object, the constructor for KeyframeEffect (or, actually the constructor for KeyframeEffectReadOnly), specifies that current realm is used (which, at this point corresponds to the relevant Realm of the target).[2] [1] https://w3c.github.io/web-animations/#dom-animatable-animate [2] https://w3c.github.io/web-animations/#dom-keyframeeffectreadonly-keyframeeffectreadonly MozReview-Commit-ID: HzlyCxeQZ3T
testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html
--- a/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html
+++ b/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html
@@ -3,34 +3,79 @@
 <title>Animatable.animate tests</title>
 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-animate">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="../../testcommon.js"></script>
 <script src="../../resources/keyframe-utils.js"></script>
 <body>
 <div id="log"></div>
+<iframe width="10" height="10" id="iframe"></iframe>
 <script>
 'use strict';
 
 // Tests on Element
 
 test(function(t) {
   var div = createDiv(t);
   var anim = div.animate(null);
   assert_class_string(anim, 'Animation', 'Returned object is an Animation');
 }, 'Element.animate() creates an Animation object');
 
 test(function(t) {
+  var iframe = window.frames[0];
+  var div = createDiv(t, iframe.document);
+  var anim = Element.prototype.animate.call(div, null);
+  assert_equals(Object.getPrototypeOf(anim), iframe.Animation.prototype,
+                'The prototype of the created Animation is that defined on'
+                + ' the relevant global for the target element');
+  assert_not_equals(Object.getPrototypeOf(anim), Animation.prototype,
+                    'The prototype of the created Animation is NOT that of'
+                    + ' the current global');
+}, 'Element.animate() creates an Animation object in the relevant realm of'
+   + ' the target element');
+
+test(function(t) {
   var div = createDiv(t);
-  var anim = div.animate(null);
+  var anim = Element.prototype.animate.call(div, null);
   assert_class_string(anim.effect, 'KeyframeEffect',
                       'Returned Animation has a KeyframeEffect');
 }, 'Element.animate() creates an Animation object with a KeyframeEffect');
 
+test(function(t) {
+  var iframe = window.frames[0];
+  var div = createDiv(t, iframe.document);
+  var anim = Element.prototype.animate.call(div, null);
+  assert_equals(Object.getPrototypeOf(anim.effect),
+                iframe.KeyframeEffect.prototype,
+                'The prototype of the created KeyframeEffect is that defined on'
+                + ' the relevant global for the target element');
+  assert_not_equals(Object.getPrototypeOf(anim.effect),
+                    KeyframeEffect.prototype,
+                    'The prototype of the created KeyframeEffect is NOT that of'
+                    + ' the current global');
+}, 'Element.animate() creates an Animation object with a KeyframeEffect'
+   + ' that is created in the relevant realm of the target element');
+
+test(function(t) {
+  var iframe = window.frames[0];
+  var div = createDiv(t, iframe.document);
+  var anim = div.animate(null);
+  assert_equals(Object.getPrototypeOf(anim.effect.timing),
+                iframe.AnimationEffectTiming.prototype,
+                'The prototype of the created AnimationEffectTiming is that'
+                + ' defined on the relevant global for the target element');
+  assert_not_equals(Object.getPrototypeOf(anim.effect.timing),
+                    AnimationEffectTiming.prototype,
+                    'The prototype of the created AnimationEffectTiming is NOT'
+                    + ' that of the current global');
+}, 'Element.animate() creates an Animation object with a KeyframeEffect'
+   + ' whose AnimationEffectTiming object is created in the relevant realm'
+   + ' of the target element');
+
 gPropertyIndexedKeyframesTests.forEach(function(subtest) {
   test(function(t) {
     var div = createDiv(t);
     var anim = div.animate(subtest.input, 2000);
     assert_frame_lists_equal(anim.effect.getKeyframes(), subtest.output);
   }, 'Element.animate() accepts ' + subtest.desc);
 });