Title: [207632] trunk
Revision
207632
Author
[email protected]
Date
2016-10-20 12:17:06 -0700 (Thu, 20 Oct 2016)

Log Message

Improve error message when passing a null ArrayBuffer to bufferData()
https://bugs.webkit.org/show_bug.cgi?id=163745

Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/canvas/webgl/bufferData-nullable-array-buffer-view.html

Update the idl file to accept a nullable ArrayBuffer, and throw
the relevant error with a more helpful error string.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::bufferData):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLRenderingContextBase.idl:

LayoutTests:

* fast/canvas/webgl/bufferData-nullable-array-buffer-view-expected.txt: Added.
* fast/canvas/webgl/bufferData-nullable-array-buffer-view.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207631 => 207632)


--- trunk/LayoutTests/ChangeLog	2016-10-20 19:15:59 UTC (rev 207631)
+++ trunk/LayoutTests/ChangeLog	2016-10-20 19:17:06 UTC (rev 207632)
@@ -1,3 +1,13 @@
+2016-10-20  Myles C. Maxfield  <[email protected]>
+
+        Improve error message when passing a null ArrayBuffer to bufferData()
+        https://bugs.webkit.org/show_bug.cgi?id=163745
+
+        Reviewed by Dean Jackson.
+
+        * fast/canvas/webgl/bufferData-nullable-array-buffer-view-expected.txt: Added.
+        * fast/canvas/webgl/bufferData-nullable-array-buffer-view.html: Added.
+
 2016-10-20  Zalan Bujtas  <[email protected]>
 
         Stop searching for first-letter containers at multi-column boundary.

Added: trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view-expected.txt (0 => 207632)


--- trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view-expected.txt	2016-10-20 19:17:06 UTC (rev 207632)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 19: WebGL: INVALID_VALUE: bufferData: null data
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS undefined did not throw exception.
+PASS context.getError() is context.NO_ERROR
+PASS undefined did not throw exception.
+PASS context.getError() is context.INVALID_VALUE
+PASS context.getError() is context.NO_ERROR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view.html (0 => 207632)


--- trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/bufferData-nullable-array-buffer-view.html	2016-10-20 19:17:06 UTC (rev 207632)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+var canvas = document.createElement("canvas");
+canvas.width = 2;
+canvas.height = 2;
+var context = canvas.getContext("webgl");
+shouldBe("context.getError()", "context.NO_ERROR");
+var buffer = context.createBuffer();
+shouldBe("context.getError()", "context.NO_ERROR");
+context.bindBuffer(context.ARRAY_BUFFER, buffer);
+shouldBe("context.getError()", "context.NO_ERROR");
+shouldNotThrow(context.bufferData(context.ARRAY_BUFFER, new ArrayBuffer(10), context.STATIC_DRAW));
+shouldBe("context.getError()", "context.NO_ERROR");
+shouldNotThrow(context.bufferData(context.ARRAY_BUFFER, null, context.STATIC_DRAW));
+shouldBe("context.getError()", "context.INVALID_VALUE");
+shouldBe("context.getError()", "context.NO_ERROR");
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (207631 => 207632)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 19:15:59 UTC (rev 207631)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 19:17:06 UTC (rev 207632)
@@ -1,3 +1,20 @@
+2016-10-20  Myles C. Maxfield  <[email protected]>
+
+        Improve error message when passing a null ArrayBuffer to bufferData()
+        https://bugs.webkit.org/show_bug.cgi?id=163745
+
+        Reviewed by Dean Jackson.
+
+        Test: fast/canvas/webgl/bufferData-nullable-array-buffer-view.html
+
+        Update the idl file to accept a nullable ArrayBuffer, and throw
+        the relevant error with a more helpful error string.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::bufferData):
+        * html/canvas/WebGLRenderingContextBase.h:
+        * html/canvas/WebGLRenderingContextBase.idl:
+
 2016-10-20  Zalan Bujtas  <[email protected]>
 
         Stop searching for first-letter containers at multi-column boundary.

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (207631 => 207632)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2016-10-20 19:15:59 UTC (rev 207631)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2016-10-20 19:17:06 UTC (rev 207632)
@@ -1075,15 +1075,19 @@
     }
 }
 
-void WebGLRenderingContextBase::bufferData(GC3Denum target, ArrayBuffer& data, GC3Denum usage, ExceptionCode&)
+void WebGLRenderingContextBase::bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&)
 {
     if (isContextLostOrPending())
         return;
+    if (!data) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "null data");
+        return;
+    }
     WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage);
     if (!buffer)
         return;
     if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
-        if (!buffer->associateBufferData(&data)) {
+        if (!buffer->associateBufferData(data)) {
             synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer");
             return;
         }
@@ -1090,7 +1094,7 @@
     }
 
     m_context->moveErrorsToSyntheticErrorList();
-    m_context->bufferData(target, data.byteLength(), data.data(), usage);
+    m_context->bufferData(target, data->byteLength(), data->data(), usage);
     if (m_context->moveErrorsToSyntheticErrorList()) {
         // The bufferData function failed. Tell the buffer it doesn't have the data it thinks it does.
         buffer->disassociateBufferData();
@@ -1097,15 +1101,19 @@
     }
 }
 
-void WebGLRenderingContextBase::bufferData(GC3Denum target, ArrayBufferView& data, GC3Denum usage, ExceptionCode&)
+void WebGLRenderingContextBase::bufferData(GC3Denum target, RefPtr<ArrayBufferView>&& data, GC3Denum usage, ExceptionCode&)
 {
     if (isContextLostOrPending())
         return;
+    if (!data) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "null data");
+        return;
+    }
     WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usage);
     if (!buffer)
         return;
     if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
-        if (!buffer->associateBufferData(&data)) {
+        if (!buffer->associateBufferData(data.get())) {
             synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "invalid buffer");
             return;
         }
@@ -1112,7 +1120,7 @@
     }
 
     m_context->moveErrorsToSyntheticErrorList();
-    m_context->bufferData(target, data.byteLength(), data.baseAddress(), usage);
+    m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage);
     if (m_context->moveErrorsToSyntheticErrorList()) {
         // The bufferData function failed. Tell the buffer it doesn't have the data it thinks it does.
         buffer->disassociateBufferData();

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (207631 => 207632)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2016-10-20 19:15:59 UTC (rev 207631)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2016-10-20 19:17:06 UTC (rev 207632)
@@ -139,8 +139,8 @@
     void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
 
     void bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode&);
-    void bufferData(GC3Denum target, ArrayBuffer& data, GC3Denum usage, ExceptionCode&);
-    void bufferData(GC3Denum target, ArrayBufferView& data, GC3Denum usage, ExceptionCode&);
+    void bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&);
+    void bufferData(GC3Denum target, RefPtr<ArrayBufferView>&& data, GC3Denum usage, ExceptionCode&);
     void bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data, ExceptionCode&);
     void bufferSubData(GC3Denum target, long long offset, RefPtr<ArrayBufferView>&& data, ExceptionCode&);
 

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl (207631 => 207632)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl	2016-10-20 19:15:59 UTC (rev 207631)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl	2016-10-20 19:17:06 UTC (rev 207632)
@@ -484,8 +484,8 @@
     void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
     void blendFunc(GLenum sfactor, GLenum dfactor);
     void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-    [MayThrowLegacyException] void bufferData(GLenum target, ArrayBuffer data, GLenum usage);
-    [MayThrowLegacyException] void bufferData(GLenum target, ArrayBufferView data, GLenum usage);
+    [MayThrowLegacyException] void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
+    [MayThrowLegacyException] void bufferData(GLenum target, ArrayBufferView? data, GLenum usage);
     [MayThrowLegacyException] void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
     [MayThrowLegacyException] void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer? data);
     [MayThrowLegacyException] void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView? data);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to