Bug 1402170 - Add tests for error handling when parsing the 'easing' property on keyframes; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Mon, 02 Oct 2017 12:30:33 +0900
changeset 673299 028418deb1a740593a48a8876bb2c286a949244e
parent 673298 868a29b895cb5608ed75969821b2db3447bdc76f
child 673300 a972e13c9c6e3ef29fc6af42577db3167b2c769b
push id82519
push userbmo:bbirtles@mozilla.com
push dateMon, 02 Oct 2017 08:06:17 +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>