diff --git a/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html b/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html index 133fd579041792..b88c2537deb5e2 100644 --- a/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html +++ b/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html @@ -307,6 +307,20 @@ }, 'Keyframes are read from a custom iterator with where an offset is' + ' specified'); +test(() => { + const test_error = { name: 'test' }; + const bad_keyframe = { get left() { throw test_error; } }; + assert_throws(bad_keyframe, () => { + new KeyframeEffect(null, createIteratble([ + { done: false, value: { left: '100px' } }, + { done: false, value: bad_keyframe }, + { done: false, value: { left: '200px' } }, + { done: true }, + ])); + }); +}, 'If a keyframe throws for an animatable property, that exception should be' + + ' propagated'); + test(() => { assert_throws({ name: 'TypeError' }, () => { new KeyframeEffect(null, createIterable([ @@ -319,6 +333,30 @@ }, 'Reading from a custom iterator that returns a non-object keyframe' + ' should throw'); +test(() => { + assert_throws({ name: 'TypeError' }, () => { + new KeyframeEffect(null, createIterable([ + { done: false, value: { left: '100px' } }, + { done: false }, // No value member; keyframe is undefined. + { done: false, value: { left: '200px' } }, + { done: true }, + ])); + }); +}, 'Reading from a custom iterator that returns an undefined keyframe' + + ' should throw'); + +test(() => { + assert_throws({ name: 'TypeError' }, () => { + new KeyframeEffect(null, createIterable([ + { done: false, value: { left: '100px' } }, + { done: false, value: null }, + { done: false, value: { left: '200px' } }, + { done: true }, + ])); + }); +}, 'Reading from a custom iterator that returns a null keyframe' + + ' should throw'); + test(() => { const effect = new KeyframeEffect(null, createIterable([ { done: false, value: { left: ['100px', '200px'] } }, @@ -329,6 +367,32 @@ ]); }, 'A list of values returned from a custom iterator should be ignored'); +// Test handling of invalid Symbol.iterator + +test(() => { + const test_error = { name: 'test' }; + const keyframe_obj = { + [Symbol.iterator]() { + throw test_error; + }, + }; + assert_throws(test_error, () => { + new KeyframeEffect(null, keyframe_obj); + }); +}, 'Accessing a Symbol.iterator property that throws should rethrow'); + +test(() => { + const keyframe_obj = { + [Symbol.iterator]() { + return 42; // Not an object. + }, + }; + assert_throws(new TypeError(), () => { + new KeyframeEffect(null, keyframe_obj); + }); +}, 'A non-object returned from the Symbol.iterator property should cause a' + + ' TypeError to be thrown'); + test(() => { const keyframe = {}; Object.defineProperty(keyframe, 'width', { value: '200px' });