Title: [207634] trunk
Revision
207634
Author
cdu...@apple.com
Date
2016-10-20 12:52:16 -0700 (Thu, 20 Oct 2016)

Log Message

Passing a number as the pixel parameter to texImage2D() doesn't thrown an exception
https://bugs.webkit.org/show_bug.cgi?id=163715

Reviewed by Darin Adler.

Source/WebCore:

Enable strict type checking for typed arrays in the bindings, similarly
do what we do for other wrapper types, as per Web IDL.

No new tests, updated existing tests.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateParametersCheck):

LayoutTests:

Update existing tests now that we throw a TypeError when passing an unexpected
type for a parameter where we expect a typed array.

* fast/canvas/webgl/script-tests/texImageTest.js:
* fast/canvas/webgl/texImageTest-expected.txt:
* webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207633 => 207634)


--- trunk/LayoutTests/ChangeLog	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/LayoutTests/ChangeLog	2016-10-20 19:52:16 UTC (rev 207634)
@@ -1,3 +1,17 @@
+2016-10-20  Chris Dumez  <cdu...@apple.com>
+
+        Passing a number as the pixel parameter to texImage2D() doesn't thrown an exception
+        https://bugs.webkit.org/show_bug.cgi?id=163715
+
+        Reviewed by Darin Adler.
+
+        Update existing tests now that we throw a TypeError when passing an unexpected
+        type for a parameter where we expect a typed array.
+
+        * fast/canvas/webgl/script-tests/texImageTest.js:
+        * fast/canvas/webgl/texImageTest-expected.txt:
+        * webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html:
+
 2016-10-20  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking media/modern-media-controls/media-controller/media-controller-resize.html as flaky.

Modified: trunk/LayoutTests/fast/canvas/webgl/script-tests/texImageTest.js (207633 => 207634)


--- trunk/LayoutTests/fast/canvas/webgl/script-tests/texImageTest.js	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/LayoutTests/fast/canvas/webgl/script-tests/texImageTest.js	2016-10-20 19:52:16 UTC (rev 207634)
@@ -25,7 +25,7 @@
 
 shouldThrow("context.texSubImage2D(context.TEXTURE_2D)");
 shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
-shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0)"); // We do not do strict type checking on ArrayBufferView.
+shouldThrow("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0)");
 shouldThrow("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, context.UNSIGNED_BYTE, 0)");
 shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false)");
 shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, context.RGBA, context.UNSIGNED_BYTE, imageData)");

Modified: trunk/LayoutTests/fast/canvas/webgl/texImageTest-expected.txt (207633 => 207634)


--- trunk/LayoutTests/fast/canvas/webgl/texImageTest-expected.txt	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/LayoutTests/fast/canvas/webgl/texImageTest-expected.txt	2016-10-20 19:52:16 UTC (rev 207634)
@@ -15,7 +15,7 @@
 PASS context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, video) is undefined.
 PASS context.texSubImage2D(context.TEXTURE_2D) threw exception TypeError: Not enough arguments.
 PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, null) is undefined.
-PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0) is undefined.
+PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0) threw exception TypeError: Argument 9 ('pixels') to WebGLRenderingContextBase.texSubImage2D must be an instance of ArrayBufferView.
 PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, context.UNSIGNED_BYTE, 0) threw exception TypeError: Type error.
 PASS context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false) is undefined.
 PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, context.RGBA, context.UNSIGNED_BYTE, imageData) is undefined.

Modified: trunk/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html (207633 => 207634)


--- trunk/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html	2016-10-20 19:52:16 UTC (rev 207634)
@@ -89,18 +89,17 @@
      },
      gl.INVALID_OPERATION);
 
-// We do not do strict type checking for ArrayBufferView type.
 test("Passing texImage2D parameter data of Number type should generate an INVALID_OPERATION",
      function () {
         gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, 42);
      },
-     gl.INVALID_OPERATION);
+     "exception");
 
 test("Passing texImage2D parameter data of String type should generate an INVALID_OPERATION",
      function () {
         gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
      },
-     gl.INVALID_OPERATION);
+     "exception");
 test("Passing a buffer not large enough to texSubImage2D should generate an INVALID_OPERATION",
      function () {
         var tooSmall = new Uint8Array(64);
@@ -112,13 +111,13 @@
      function () {
         gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, 42);
      },
-     gl.INVALID_VALUE);
+     "exception");
 
 test("Passing texSubImage2D parameter data of String type should generate an INVALID_VALUE",
      function () {
         gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
      },
-     gl.INVALID_VALUE);
+     "exception");
 
 debug("");
 var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (207633 => 207634)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 19:52:16 UTC (rev 207634)
@@ -1,3 +1,19 @@
+2016-10-20  Chris Dumez  <cdu...@apple.com>
+
+        Passing a number as the pixel parameter to texImage2D() doesn't thrown an exception
+        https://bugs.webkit.org/show_bug.cgi?id=163715
+
+        Reviewed by Darin Adler.
+
+        Enable strict type checking for typed arrays in the bindings, similarly
+        do what we do for other wrapper types, as per Web IDL.
+
+        No new tests, updated existing tests.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        (GenerateParametersCheck):
+
 2016-10-20  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Improve error message when passing a null ArrayBuffer to bufferData()

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207633 => 207634)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-20 19:48:01 UTC (rev 207633)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-20 19:52:16 UTC (rev 207634)
@@ -3444,7 +3444,7 @@
                 my $shouldPassByReference = ShouldPassWrapperByReference($attribute->signature, $interface);
 
                 my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $attribute->signature, "value", $attribute->signature->extendedAttributes->{Conditional}, "&state", "state", "thisObject");
-                if (!$shouldPassByReference && $codeGenerator->IsWrapperType($type)) {
+                if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
                     $implIncludes{"<runtime/Error.h>"} = 1;
                     push(@implContent, "    " . GetNativeTypeFromSignature($interface, $attribute->signature) . " nativeValue = nullptr;\n");
                     push(@implContent, "    if (!value.isUndefinedOrNull()) {\n");
@@ -4312,7 +4312,7 @@
             die "Variadic parameter is already handled here" if $parameter->isVariadic;
             my $argumentLookupMethod = $parameter->isOptional ? "argument" : "uncheckedArgument";
 
-            if (!$shouldPassByReference && $codeGenerator->IsWrapperType($type)) {
+            if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
                 $implIncludes{"<runtime/Error.h>"} = 1;
                 my $checkedArgument = "state->$argumentLookupMethod($argumentIndex)";
                 my $uncheckedArgument = "state->uncheckedArgument($argumentIndex)";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to