Diff
Modified: trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt (223610 => 223611)
--- trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt 2017-10-18 16:59:52 UTC (rev 223611)
@@ -10,10 +10,10 @@
PASS new ImageData(0, 0) threw exception IndexSizeError: The index is not in the allowed range..
PASS new ImageData(20, 0) threw exception IndexSizeError: The index is not in the allowed range..
PASS new ImageData(0, 20) threw exception IndexSizeError: The index is not in the allowed range..
-PASS new ImageData(-20, 20) threw exception TypeError: Type error.
-PASS new ImageData(20, -20) threw exception TypeError: Type error.
+PASS new ImageData(-20, 20) threw exception RangeError: Cannot allocate a buffer of this size.
+PASS new ImageData(20, -20) threw exception RangeError: Cannot allocate a buffer of this size.
PASS new ImageData(null, 20) threw exception IndexSizeError: The index is not in the allowed range..
-PASS new ImageData(32768, 32768) threw exception TypeError: Type error.
+PASS new ImageData(32768, 32768) threw exception RangeError: Cannot allocate a buffer of this size.
PASS new ImageData(null, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(imageData, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(imageData, 0) threw exception IndexSizeError: The index is not in the allowed range..
@@ -20,17 +20,18 @@
PASS new ImageData(imageData, 20, 0) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(imageData, 0, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(imageData, 10, 5) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
-PASS new ImageData(imageData.data, 10, 5) threw exception IndexSizeError: The index is not in the allowed range..
-PASS new ImageData(imageData.data, -10, 5) threw exception InvalidStateError: The object is in an invalid state..
-PASS new ImageData(imageData.data, 10, -10) threw exception IndexSizeError: The index is not in the allowed range..
-PASS new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2); threw exception InvalidStateError: The object is in an invalid state..
+PASS new ImageData(imageData.data, 10, 5) threw exception IndexSizeError: sh value is not equal to height.
+PASS new ImageData(imageData.data, -10, 5) threw exception IndexSizeError: Length is not a multiple of sw.
+PASS new ImageData(imageData.data, 10, -10) threw exception IndexSizeError: sh value is not equal to height.
+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.
PASS new ImageData({},2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(undefined,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData("none",2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
PASS new ImageData(0,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
-PASS new ImageData(imageData.data, 32768, 32768) threw exception InvalidStateError: The object is in an invalid state..
-PASS new ImageData(imageData.data, Infinity, Infinity) threw exception IndexSizeError: The index is not in the allowed range..
-PASS new ImageData(imageData.data, NaN, NaN) threw exception IndexSizeError: The index is not in the allowed range..
+PASS new ImageData(imageData.data, 32768, 32768) threw exception IndexSizeError: Length is not a multiple of sw.
+PASS new ImageData(imageData.data, Infinity, Infinity) threw exception IndexSizeError: Length is not a multiple of sw.
+PASS new ImageData(imageData.data, NaN, NaN) threw exception IndexSizeError: Length is not a multiple of sw.
+PASS new ImageData(imageData.data, 10, 0) threw exception IndexSizeError: sh value is not equal to height.
Test valid ImageData constructors.
Test that we got the pixel array from imageData.
Modified: trunk/LayoutTests/fast/canvas/canvas-imageData.html (223610 => 223611)
--- trunk/LayoutTests/fast/canvas/canvas-imageData.html 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/LayoutTests/fast/canvas/canvas-imageData.html 2017-10-18 16:59:52 UTC (rev 223611)
@@ -19,10 +19,10 @@
shouldThrowErrorName('new ImageData(0, 0)', 'IndexSizeError');
shouldThrowErrorName('new ImageData(20, 0)', 'IndexSizeError');
shouldThrowErrorName('new ImageData(0, 20)', 'IndexSizeError');
-shouldThrowErrorName('new ImageData(-20, 20)', 'TypeError');
-shouldThrowErrorName('new ImageData(20, -20)', 'TypeError');
+shouldThrowErrorName('new ImageData(-20, 20)', 'RangeError');
+shouldThrowErrorName('new ImageData(20, -20)', 'RangeError');
shouldThrowErrorName('new ImageData(null, 20)', 'IndexSizeError');
-shouldThrowErrorName('new ImageData(32768, 32768)', 'TypeError');
+shouldThrowErrorName('new ImageData(32768, 32768)', 'RangeError');
shouldThrowErrorName('new ImageData(null, 20, 20)', 'TypeError');
shouldThrowErrorName('new ImageData(imageData, 20, 20)', 'TypeError');
shouldThrowErrorName('new ImageData(imageData, 0)', 'IndexSizeError');
@@ -30,16 +30,17 @@
shouldThrowErrorName('new ImageData(imageData, 0, 20)', 'TypeError');
shouldThrowErrorName('new ImageData(imageData, 10, 5)', 'TypeError');
shouldThrowErrorName('new ImageData(imageData.data, 10, 5)', 'IndexSizeError');
-shouldThrowErrorName('new ImageData(imageData.data, -10, 5)', 'InvalidStateError');
+shouldThrowErrorName('new ImageData(imageData.data, -10, 5)', 'IndexSizeError');
shouldThrowErrorName('new ImageData(imageData.data, 10, -10)', 'IndexSizeError');
-shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', 'InvalidStateError');
+shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', 'IndexSizeError');
shouldThrowErrorName('new ImageData({},2,2);', 'TypeError');
shouldThrowErrorName('new ImageData(undefined,2,2);', 'TypeError');
shouldThrowErrorName('new ImageData("none",2,2);', 'TypeError');
shouldThrowErrorName('new ImageData(0,2,2);', 'TypeError');
-shouldThrowErrorName('new ImageData(imageData.data, 32768, 32768)', 'InvalidStateError');
+shouldThrowErrorName('new ImageData(imageData.data, 32768, 32768)', 'IndexSizeError');
shouldThrowErrorName('new ImageData(imageData.data, Infinity, Infinity)', 'IndexSizeError');
shouldThrowErrorName('new ImageData(imageData.data, NaN, NaN)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(imageData.data, 10, 0)', 'IndexSizeError');
debug('');
debug('Test valid ImageData constructors.')
@@ -46,8 +47,6 @@
new ImageData(10, 10);
new ImageData(imageData.data, 10, 10);
new ImageData(imageData.data, 10);
-// This should throw but doesn't because of a CodeGeneratorJS bug.
-new ImageData(imageData.data, 10, 0);
debug('Test that we got the pixel array from imageData.');
var newImageData = new ImageData(imageData.data, 10, 10);
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (223610 => 223611)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-18 16:59:52 UTC (rev 223611)
@@ -1,3 +1,14 @@
+2017-10-18 Chris Dumez <[email protected]>
+
+ Align ImageData constructor with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=178406
+
+ Reviewed by Youenn Fablet.
+
+ Rebaseline test now that one more check is passing.
+
+ * web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt:
+
2017-10-16 Youenn Fablet <[email protected]>
[FETCH] Remove Request.type getter
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt (223610 => 223611)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/imagedata-expected.txt 2017-10-18 16:59:52 UTC (rev 223611)
@@ -3,9 +3,7 @@
PASS ImageData(w, h), height cannot be 0
PASS ImageData(w, h), exposed attributes check
PASS ImageData(buffer, w), the buffer size must be a multiple of 4
-FAIL ImageData(buffer, w), buffer size must be a multiple of the image width assert_throws: function "function () {
- new ImageData(new Uint8ClampedArray(16), 3);
- }" threw object "InvalidStateError: The object is in an invalid state." that is not a DOMException IndexSizeError: property "code" is equal to 11, expected 1
+PASS ImageData(buffer, w), buffer size must be a multiple of the image width
PASS ImageData(buffer, w, h), buffer.lenght == 4 * w * h must be true
FAIL ImageData(buffer, w, opt h), Uint8ClampedArray argument type check assert_throws: function "function () {
new ImageData(new Int8Array(1), 1);
Modified: trunk/Source/WebCore/ChangeLog (223610 => 223611)
--- trunk/Source/WebCore/ChangeLog 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/Source/WebCore/ChangeLog 2017-10-18 16:59:52 UTC (rev 223611)
@@ -1,5 +1,24 @@
2017-10-18 Chris Dumez <[email protected]>
+ Align ImageData constructor with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=178406
+
+ Reviewed by Youenn Fablet.
+
+ Align ImageData constructor with the specification:
+ - https://html.spec.whatwg.org/multipage/canvas.html#dom-imagedata
+
+ It sometimes throws the wrong exception.
+
+ No new tests, rebaselined existing test.
+
+ * html/ImageData.cpp:
+ (WebCore::ImageData::create):
+ * html/ImageData.h:
+ * html/ImageData.idl:
+
+2017-10-18 Chris Dumez <[email protected]>
+
Add an efficient data structure for WebCore to query if there is a Service Worker registered for a given origin
https://bugs.webkit.org/show_bug.cgi?id=177876
<rdar://problem/34813129>
Modified: trunk/Source/WebCore/html/ImageData.cpp (223610 => 223611)
--- trunk/Source/WebCore/html/ImageData.cpp 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/Source/WebCore/html/ImageData.cpp 2017-10-18 16:59:52 UTC (rev 223611)
@@ -44,7 +44,7 @@
dataSize *= sw;
dataSize *= sh;
if (dataSize.hasOverflowed())
- return Exception { TypeError }; // FIXME: Seems a peculiar choice of exception here.
+ return Exception { RangeError, ASCIILiteral("Cannot allocate a buffer of this size") };
IntSize size(sw, sh);
auto data = "" ImageData(size));
@@ -77,22 +77,20 @@
return adoptRef(*new ImageData(size, WTFMove(byteArray)));
}
-ExceptionOr<RefPtr<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, unsigned sh)
+ExceptionOr<RefPtr<ImageData>> ImageData::create(Ref<Uint8ClampedArray>&& byteArray, unsigned sw, std::optional<unsigned> sh)
{
unsigned length = byteArray->length();
- if (!length || length % 4 != 0)
- return Exception { InvalidStateError };
+ if (!length || length % 4)
+ return Exception { InvalidStateError, ASCIILiteral("Length is not a non-zero multiple of 4") };
- if (!sw)
- return Exception { IndexSizeError };
-
+ ASSERT(length > 0);
length /= 4;
- if (length % sw != 0)
- return Exception { InvalidStateError };
+ if (!sw || length % sw)
+ return Exception { IndexSizeError, ASCIILiteral("Length is not a multiple of sw") };
unsigned height = length / sw;
- if (sh && sh != height)
- return Exception { IndexSizeError };
+ if (sh && sh.value() != height)
+ return Exception { IndexSizeError, ASCIILiteral("sh value is not equal to height") };
return create(IntSize(sw, height), WTFMove(byteArray));
}
Modified: trunk/Source/WebCore/html/ImageData.h (223610 => 223611)
--- trunk/Source/WebCore/html/ImageData.h 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/Source/WebCore/html/ImageData.h 2017-10-18 16:59:52 UTC (rev 223611)
@@ -39,7 +39,7 @@
static ExceptionOr<Ref<ImageData>> create(unsigned sw, unsigned sh);
static RefPtr<ImageData> create(const IntSize&);
static RefPtr<ImageData> create(const IntSize&, Ref<Uint8ClampedArray>&&);
- static ExceptionOr<RefPtr<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, unsigned sh);
+ static ExceptionOr<RefPtr<ImageData>> create(Ref<Uint8ClampedArray>&&, unsigned sw, std::optional<unsigned> sh);
IntSize size() const { return m_size; }
int width() const { return m_size.width(); }
Modified: trunk/Source/WebCore/html/ImageData.idl (223610 => 223611)
--- trunk/Source/WebCore/html/ImageData.idl 2017-10-18 16:54:36 UTC (rev 223610)
+++ trunk/Source/WebCore/html/ImageData.idl 2017-10-18 16:59:52 UTC (rev 223611)
@@ -28,7 +28,7 @@
[
Constructor(unsigned long sw, unsigned long sh),
- Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh = 0), // FIXME: sh should not have a default value
+ Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh),
ConstructorMayThrowException,
CustomToJSObject,
ExportMacro=WEBCORE_EXPORT,