Changeset 223611 in webkit
- Timestamp:
- Oct 18, 2017 9:59:52 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt
r219663 r223611 11 11 PASS new ImageData(20, 0) threw exception IndexSizeError: The index is not in the allowed range.. 12 12 PASS new ImageData(0, 20) threw exception IndexSizeError: The index is not in the allowed range.. 13 PASS new ImageData(-20, 20) threw exception TypeError: Type error.14 PASS new ImageData(20, -20) threw exception TypeError: Type error.13 PASS new ImageData(-20, 20) threw exception RangeError: Cannot allocate a buffer of this size. 14 PASS new ImageData(20, -20) threw exception RangeError: Cannot allocate a buffer of this size. 15 15 PASS new ImageData(null, 20) threw exception IndexSizeError: The index is not in the allowed range.. 16 PASS new ImageData(32768, 32768) threw exception TypeError: Type error.16 PASS new ImageData(32768, 32768) threw exception RangeError: Cannot allocate a buffer of this size. 17 17 PASS new ImageData(null, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 18 18 PASS new ImageData(imageData, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. … … 21 21 PASS new ImageData(imageData, 0, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 22 22 PASS new ImageData(imageData, 10, 5) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 23 PASS new ImageData(imageData.data, 10, 5) threw exception IndexSizeError: The index is not in the allowed range..24 PASS new ImageData(imageData.data, -10, 5) threw exception In validStateError: The object is in an invalid state..25 PASS new ImageData(imageData.data, 10, -10) threw exception IndexSizeError: The index is not in the allowed range..26 PASS new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2); threw exception In validStateError: The object is in an invalid state..23 PASS new ImageData(imageData.data, 10, 5) threw exception IndexSizeError: sh value is not equal to height. 24 PASS new ImageData(imageData.data, -10, 5) threw exception IndexSizeError: Length is not a multiple of sw. 25 PASS new ImageData(imageData.data, 10, -10) threw exception IndexSizeError: sh value is not equal to height. 26 PASS new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2); threw exception IndexSizeError: Length is not a multiple of sw. 27 27 PASS new ImageData({},2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 28 28 PASS new ImageData(undefined,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 29 29 PASS new ImageData("none",2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 30 30 PASS new ImageData(0,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray. 31 PASS new ImageData(imageData.data, 32768, 32768) threw exception InvalidStateError: The object is in an invalid state.. 32 PASS new ImageData(imageData.data, Infinity, Infinity) threw exception IndexSizeError: The index is not in the allowed range.. 33 PASS new ImageData(imageData.data, NaN, NaN) threw exception IndexSizeError: The index is not in the allowed range.. 31 PASS new ImageData(imageData.data, 32768, 32768) threw exception IndexSizeError: Length is not a multiple of sw. 32 PASS new ImageData(imageData.data, Infinity, Infinity) threw exception IndexSizeError: Length is not a multiple of sw. 33 PASS new ImageData(imageData.data, NaN, NaN) threw exception IndexSizeError: Length is not a multiple of sw. 34 PASS new ImageData(imageData.data, 10, 0) threw exception IndexSizeError: sh value is not equal to height. 34 35 35 36 Test valid ImageData constructors. -
trunk/LayoutTests/fast/canvas/canvas-imageData.html
r217390 r223611 20 20 shouldThrowErrorName('new ImageData(20, 0)', 'IndexSizeError'); 21 21 shouldThrowErrorName('new ImageData(0, 20)', 'IndexSizeError'); 22 shouldThrowErrorName('new ImageData(-20, 20)', ' TypeError');23 shouldThrowErrorName('new ImageData(20, -20)', ' TypeError');22 shouldThrowErrorName('new ImageData(-20, 20)', 'RangeError'); 23 shouldThrowErrorName('new ImageData(20, -20)', 'RangeError'); 24 24 shouldThrowErrorName('new ImageData(null, 20)', 'IndexSizeError'); 25 shouldThrowErrorName('new ImageData(32768, 32768)', ' TypeError');25 shouldThrowErrorName('new ImageData(32768, 32768)', 'RangeError'); 26 26 shouldThrowErrorName('new ImageData(null, 20, 20)', 'TypeError'); 27 27 shouldThrowErrorName('new ImageData(imageData, 20, 20)', 'TypeError'); … … 31 31 shouldThrowErrorName('new ImageData(imageData, 10, 5)', 'TypeError'); 32 32 shouldThrowErrorName('new ImageData(imageData.data, 10, 5)', 'IndexSizeError'); 33 shouldThrowErrorName('new ImageData(imageData.data, -10, 5)', 'In validStateError');33 shouldThrowErrorName('new ImageData(imageData.data, -10, 5)', 'IndexSizeError'); 34 34 shouldThrowErrorName('new ImageData(imageData.data, 10, -10)', 'IndexSizeError'); 35 shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', 'In validStateError');35 shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', 'IndexSizeError'); 36 36 shouldThrowErrorName('new ImageData({},2,2);', 'TypeError'); 37 37 shouldThrowErrorName('new ImageData(undefined,2,2);', 'TypeError'); 38 38 shouldThrowErrorName('new ImageData("none",2,2);', 'TypeError'); 39 39 shouldThrowErrorName('new ImageData(0,2,2);', 'TypeError'); 40 shouldThrowErrorName('new ImageData(imageData.data, 32768, 32768)', 'In validStateError');40 shouldThrowErrorName('new ImageData(imageData.data, 32768, 32768)', 'IndexSizeError'); 41 41 shouldThrowErrorName('new ImageData(imageData.data, Infinity, Infinity)', 'IndexSizeError'); 42 42 shouldThrowErrorName('new ImageData(imageData.data, NaN, NaN)', 'IndexSizeError'); 43 shouldThrowErrorName('new ImageData(imageData.data, 10, 0)', 'IndexSizeError'); 43 44 debug(''); 44 45 … … 47 48 new ImageData(imageData.data, 10, 10); 48 49 new ImageData(imageData.data, 10); 49 // This should throw but doesn't because of a CodeGeneratorJS bug.50 new ImageData(imageData.data, 10, 0);51 50 52 51 debug('Test that we got the pixel array from imageData.'); -
trunk/LayoutTests/imported/w3c/ChangeLog
r223441 r223611 1 2017-10-18 Chris Dumez <cdumez@apple.com> 2 3 Align ImageData constructor with the specification 4 https://bugs.webkit.org/show_bug.cgi?id=178406 5 6 Reviewed by Youenn Fablet. 7 8 Rebaseline test now that one more check is passing. 9 10 * web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt: 11 1 12 2017-10-16 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt
r219663 r223611 4 4 PASS ImageData(w, h), exposed attributes check 5 5 PASS ImageData(buffer, w), the buffer size must be a multiple of 4 6 FAIL ImageData(buffer, w), buffer size must be a multiple of the image width assert_throws: function "function () { 7 new ImageData(new Uint8ClampedArray(16), 3); 8 }" threw object "InvalidStateError: The object is in an invalid state." that is not a DOMException IndexSizeError: property "code" is equal to 11, expected 1 6 PASS ImageData(buffer, w), buffer size must be a multiple of the image width 9 7 PASS ImageData(buffer, w, h), buffer.lenght == 4 * w * h must be true 10 8 FAIL ImageData(buffer, w, opt h), Uint8ClampedArray argument type check assert_throws: function "function () { -
trunk/Source/WebCore/ChangeLog
r223608 r223611 1 2017-10-18 Chris Dumez <cdumez@apple.com> 2 3 Align ImageData constructor with the specification 4 https://bugs.webkit.org/show_bug.cgi?id=178406 5 6 Reviewed by Youenn Fablet. 7 8 Align ImageData constructor with the specification: 9 - https://html.spec.whatwg.org/multipage/canvas.html#dom-imagedata 10 11 It sometimes throws the wrong exception. 12 13 No new tests, rebaselined existing test. 14 15 * html/ImageData.cpp: 16 (WebCore::ImageData::create): 17 * html/ImageData.h: 18 * html/ImageData.idl: 19 1 20 2017-10-18 Chris Dumez <cdumez@apple.com> 2 21 -
trunk/Source/WebCore/html/ImageData.cpp
r219856 r223611 45 45 dataSize *= sh; 46 46 if (dataSize.hasOverflowed()) 47 return Exception { TypeError }; // FIXME: Seems a peculiar choice of exception here.47 return Exception { RangeError, ASCIILiteral("Cannot allocate a buffer of this size") }; 48 48 49 49 IntSize size(sw, sh); … … 78 78 } 79 79 80 ExceptionOr<RefPtr<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, unsignedsh)80 ExceptionOr<RefPtr<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, std::optional<unsigned> sh) 81 81 { 82 82 unsigned length = byteArray->length(); 83 if (!length || length % 4 != 0)84 return Exception { InvalidStateError };83 if (!length || length % 4) 84 return Exception { InvalidStateError, ASCIILiteral("Length is not a non-zero multiple of 4") }; 85 85 86 if (!sw) 87 return Exception { IndexSizeError }; 88 86 ASSERT(length > 0); 89 87 length /= 4; 90 if ( length % sw != 0)91 return Exception { In validStateError};88 if (!sw || length % sw) 89 return Exception { IndexSizeError, ASCIILiteral("Length is not a multiple of sw") }; 92 90 93 91 unsigned height = length / sw; 94 if (sh && sh != height)95 return Exception { IndexSizeError };92 if (sh && sh.value() != height) 93 return Exception { IndexSizeError, ASCIILiteral("sh value is not equal to height") }; 96 94 97 95 return create(IntSize(sw, height), WTFMove(byteArray)); -
trunk/Source/WebCore/html/ImageData.h
r214806 r223611 40 40 static RefPtr<ImageData> create(const IntSize&); 41 41 static RefPtr<ImageData> create(const IntSize&, Ref<Uint8ClampedArray>&&); 42 static ExceptionOr<RefPtr<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, unsignedsh);42 static ExceptionOr<RefPtr<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, std::optional<unsigned> sh); 43 43 44 44 IntSize size() const { return m_size; } -
trunk/Source/WebCore/html/ImageData.idl
r221598 r223611 29 29 [ 30 30 Constructor(unsigned long sw, unsigned long sh), 31 Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh = 0), // FIXME: sh should not have a default value31 Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh), 32 32 ConstructorMayThrowException, 33 33 CustomToJSObject,
Note: See TracChangeset
for help on using the changeset viewer.