Bug 1402170 - Add tests for error handling when parsing the 'easing' property on keyframes; r=hiro
authorBrian Birtles <birtles@gmail.com>
Mon, 02 Oct 2017 12:30:33 +0900
changeset 426724 5a881fba2333c0050a87e425ea3e43b56ce33ab0
parent 426723 ecf5976e67acde133ea8630524a4130146fba606
child 426725 16ec8168e8af3ef34578edc827aaa7eaf715c02a
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewershiro
bugs1402170
milestone58.0a1
Bug 1402170 - Add tests for error handling when parsing the 'easing' property on keyframes; r=hiro This tests the behavior clarified in the following spec changeset: https://github.com/w3c/web-animations/commit/d696468777c12a13bc7c46aa1a72c358e8da15fc MozReview-Commit-ID: 3hS7rHcTpUn
testing/web-platform/meta/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-002.html.ini
testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-002.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-002.html.ini
@@ -0,0 +1,8 @@
+[processing-a-keyframes-argument-002.html]
+  type: testharness
+  [Errors from invalid easings on a property-indexed keyframe are thrown after reading all properties]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1404774
+  [Errors from invalid easings on a keyframe sequence are thrown after reading all properties]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1404774
--- a/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-002.html
+++ b/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-002.html
@@ -48,9 +48,55 @@ test(function() {
   for (const invalidEasing of gInvalidEasings) {
     assert_throws(new TypeError, () => {
       new KeyframeEffect(target, [{ easing: invalidEasing }]);
     }, `TypeError is thrown for easing '${invalidEasing}'`);
   }
 }, 'Invalid easing values are correctly rejected when using a keyframe'
    + ' sequence');
 
+test(function(t) {
+  let propAccessCount = 0;
+  const keyframe = {};
+  const addProp = prop => {
+    Object.defineProperty(keyframe, prop, {
+      get: () => { propAccessCount++; },
+      enumerable: true
+    });
+  }
+  addProp('height');
+  addProp('width');
+  keyframe.easing = 'easy-peasy';
+
+  assert_throws({ name: 'TypeError' }, () => {
+    new KeyframeEffect(target, keyframe);
+  });
+  assert_equals(propAccessCount, 2,
+    'All properties were read before throwing the easing error');
+}, 'Errors from invalid easings on a property-indexed keyframe are thrown after reading all properties');
+
+test(function(t) {
+  let propAccessCount = 0;
+
+  const addProp = (keyframe, prop) => {
+    Object.defineProperty(keyframe, prop, {
+      get: () => { propAccessCount++; },
+      enumerable: true
+    });
+  }
+
+  const kf1 = {};
+  addProp(kf1, 'height');
+  addProp(kf1, 'width');
+  kf1.easing = 'easy-peasy';
+
+  const kf2 = {};
+  addProp(kf2, 'height');
+  addProp(kf2, 'width');
+
+  assert_throws({ name: 'TypeError' }, () => {
+    new KeyframeEffect(target, [ kf1, kf2 ]);
+  });
+  assert_equals(propAccessCount, 4,
+    'All properties were read before throwing the easing error');
+}, 'Errors from invalid easings on a keyframe sequence are thrown after reading all properties');
+
 </script>