[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

zmo at google.com zmo at google.com
Wed Dec 22 15:29:42 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 16c6309b145c6c199b7e1c2efc65d0a1b16b25f1
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 5 00:52:47 2010 +0000

    2010-11-04  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            TypedArray should throw exception if length not a multiple of element size
            https://bugs.webkit.org/show_bug.cgi?id=45487
    
            * bindings/js/JSArrayBufferViewHelper.h:
            (WebCore::constructArrayBufferView):
            * bindings/v8/custom/V8ArrayBufferViewCustom.h:
            (WebCore::constructWebGLArray):
    2010-11-04  Zhenyao Mo  <zmo at google.com>
    
            Reviewed by Kenneth Russell.
    
            TypedArray should throw exception if length not a multiple of element size
            https://bugs.webkit.org/show_bug.cgi?id=45487
    
            * fast/canvas/webgl/array-unit-tests-expected.txt:
            * fast/canvas/webgl/array-unit-tests.html: Test against the non-multiplication exception behavior.
            * fast/canvas/webgl/gl-enum-tests-expected.txt:
            * fast/canvas/webgl/gl-enum-tests.html: Fix the ArrayBuffer size so it won't throw an error with this patch.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71371 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1fbdb99..ca401ee 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-04  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        TypedArray should throw exception if length not a multiple of element size
+        https://bugs.webkit.org/show_bug.cgi?id=45487
+
+        * fast/canvas/webgl/array-unit-tests-expected.txt:
+        * fast/canvas/webgl/array-unit-tests.html: Test against the non-multiplication exception behavior.
+        * fast/canvas/webgl/gl-enum-tests-expected.txt:
+        * fast/canvas/webgl/gl-enum-tests.html: Fix the ArrayBuffer size so it won't throw an error with this patch.
+
 2010-11-04  Kenneth Russell  <kbr at google.com>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt b/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
index 5d6fd06..994fdce 100644
--- a/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
@@ -20,12 +20,14 @@ PASS test Float32Array BoundaryConditions(-500.5, -500.5, 500.5, 500.5)
 PASS Construction of Float32Array with null buffer threw exception
 PASS Construction of Float32Array with (null buffer, 0) threw exception
 PASS Construction of Float32Array with (null buffer, 0, 0) threw exception
-PASS Construction of Float32Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Float32Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Float32Array with negative size threw exception
-PASS Construction of Float32Array with negative out-of-range values threw INDEX_SIZE_ERR exception
-PASS Construction of Float32Array with unaligned offset threw INDEX_SIZE_ERR exception
+PASS Construction of Float32Array with negative out-of-range values threw an exception
+PASS Construction of Float32Array with unaligned offset threw an exception
+PASS Construction of Float32Array with unaligned length threw an exception
 PASS Construction of huge Float32Array threw exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Float32Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
@@ -33,7 +35,7 @@ PASS array.slice(4, -2147483648).length is 0
 PASS array.length is 0
 Testing slicing with default inputs of Float32Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -60,17 +62,18 @@ PASS test Int8Array BoundaryConditions(-128, -128, 127, 127)
 PASS Construction of Int8Array with null buffer threw exception
 PASS Construction of Int8Array with (null buffer, 0) threw exception
 PASS Construction of Int8Array with (null buffer, 0, 0) threw exception
-PASS Construction of Int8Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Int8Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Int8Array with negative size threw exception
-PASS Construction of Int8Array with negative out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Int8Array with negative out-of-range values threw an exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Int8Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
 PASS array.slice(4, -2147483648).length is 0
 Testing slicing with default inputs of Int8Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -97,12 +100,14 @@ PASS test Int16Array BoundaryConditions(-32768, -32768, 32767, 32767)
 PASS Construction of Int16Array with null buffer threw exception
 PASS Construction of Int16Array with (null buffer, 0) threw exception
 PASS Construction of Int16Array with (null buffer, 0, 0) threw exception
-PASS Construction of Int16Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Int16Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Int16Array with negative size threw exception
-PASS Construction of Int16Array with negative out-of-range values threw INDEX_SIZE_ERR exception
-PASS Construction of Int16Array with unaligned offset threw INDEX_SIZE_ERR exception
+PASS Construction of Int16Array with negative out-of-range values threw an exception
+PASS Construction of Int16Array with unaligned offset threw an exception
+PASS Construction of Int16Array with unaligned length threw an exception
 PASS Construction of huge Int16Array threw exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Int16Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
@@ -110,7 +115,7 @@ PASS array.slice(4, -2147483648).length is 0
 PASS array.length is 0
 Testing slicing with default inputs of Int16Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -137,12 +142,14 @@ PASS test Int32Array BoundaryConditions(-2147483648, -2147483648, 2147483647, 21
 PASS Construction of Int32Array with null buffer threw exception
 PASS Construction of Int32Array with (null buffer, 0) threw exception
 PASS Construction of Int32Array with (null buffer, 0, 0) threw exception
-PASS Construction of Int32Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Int32Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Int32Array with negative size threw exception
-PASS Construction of Int32Array with negative out-of-range values threw INDEX_SIZE_ERR exception
-PASS Construction of Int32Array with unaligned offset threw INDEX_SIZE_ERR exception
+PASS Construction of Int32Array with negative out-of-range values threw an exception
+PASS Construction of Int32Array with unaligned offset threw an exception
+PASS Construction of Int32Array with unaligned length threw an exception
 PASS Construction of huge Int32Array threw exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Int32Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
@@ -150,7 +157,7 @@ PASS array.slice(4, -2147483648).length is 0
 PASS array.length is 0
 Testing slicing with default inputs of Int32Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -177,17 +184,18 @@ PASS test Uint8Array BoundaryConditions(0, 0, 255, 255)
 PASS Construction of Uint8Array with null buffer threw exception
 PASS Construction of Uint8Array with (null buffer, 0) threw exception
 PASS Construction of Uint8Array with (null buffer, 0, 0) threw exception
-PASS Construction of Uint8Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Uint8Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Uint8Array with negative size threw exception
-PASS Construction of Uint8Array with negative out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Uint8Array with negative out-of-range values threw an exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Uint8Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
 PASS array.slice(4, -2147483648).length is 0
 Testing slicing with default inputs of Uint8Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -214,12 +222,14 @@ PASS test Uint16Array BoundaryConditions(0, 0, 65535, 65535)
 PASS Construction of Uint16Array with null buffer threw exception
 PASS Construction of Uint16Array with (null buffer, 0) threw exception
 PASS Construction of Uint16Array with (null buffer, 0, 0) threw exception
-PASS Construction of Uint16Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Uint16Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Uint16Array with negative size threw exception
-PASS Construction of Uint16Array with negative out-of-range values threw INDEX_SIZE_ERR exception
-PASS Construction of Uint16Array with unaligned offset threw INDEX_SIZE_ERR exception
+PASS Construction of Uint16Array with negative out-of-range values threw an exception
+PASS Construction of Uint16Array with unaligned offset threw an exception
+PASS Construction of Uint16Array with unaligned length threw an exception
 PASS Construction of huge Uint16Array threw exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Uint16Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
@@ -227,7 +237,7 @@ PASS array.slice(4, -2147483648).length is 0
 PASS array.length is 0
 Testing slicing with default inputs of Uint16Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
@@ -254,12 +264,14 @@ PASS test Uint32Array BoundaryConditions(0, 0, 4294967295, 4294967295)
 PASS Construction of Uint32Array with null buffer threw exception
 PASS Construction of Uint32Array with (null buffer, 0) threw exception
 PASS Construction of Uint32Array with (null buffer, 0, 0) threw exception
-PASS Construction of Uint32Array with out-of-range values threw INDEX_SIZE_ERR exception
+PASS Construction of Uint32Array with out-of-range values threw an exception
 PASS Construction of ArrayBuffer with negative size threw exception
 PASS Construction of Uint32Array with negative size threw exception
-PASS Construction of Uint32Array with negative out-of-range values threw INDEX_SIZE_ERR exception
-PASS Construction of Uint32Array with unaligned offset threw INDEX_SIZE_ERR exception
+PASS Construction of Uint32Array with negative out-of-range values threw an exception
+PASS Construction of Uint32Array with unaligned offset threw an exception
+PASS Construction of Uint32Array with unaligned length threw an exception
 PASS Construction of huge Uint32Array threw exception
+PASS Array lengths matched with explicit and implicit creation of ArrayBuffer
 Testing slicing of Uint32Array
 PASS array.length is 32 / typeSize
 PASS array.slice(4, 0x3FFFFFFF).length is (32 / typeSize) - 4
@@ -267,7 +279,7 @@ PASS array.slice(4, -2147483648).length is 0
 PASS array.length is 0
 Testing slicing with default inputs of Uint32Array
 PASS array.length is 32 / typeSize
-PASS array.slice().length is (32 / typeSize)
+PASS array.slice(0).length is (32 / typeSize)
 PASS array.slice(2).length is (32 / typeSize) - 2
 PASS array.slice(-2).length is 2
 PASS array.slice(-2147483648).length is (32 / typeSize)
diff --git a/LayoutTests/fast/canvas/webgl/array-unit-tests.html b/LayoutTests/fast/canvas/webgl/array-unit-tests.html
index 850237d..7bfcfac 100644
--- a/LayoutTests/fast/canvas/webgl/array-unit-tests.html
+++ b/LayoutTests/fast/canvas/webgl/array-unit-tests.html
@@ -364,16 +364,12 @@ function testConstructionWithNullBuffer(type, name) {
 }
 
 function shouldThrowIndexSizeErr(func, text) {
-    var errorText = text + " should throw INDEX_SIZE_ERR exception";
+    var errorText = text + " should throw an exception";
     try {
         func();
         testFailed(errorText);
     } catch (e) {
-        if (e.code != DOMException.INDEX_SIZE_ERR) {
-            testFailed(errorText);
-        } else {
-            testPassed(text + " threw INDEX_SIZE_ERR exception");
-        }
+        testPassed(text + " threw an exception");
     }
 }
 
@@ -412,6 +408,15 @@ function testConstructionWithUnalignedOffset(type, name, elementSizeInBytes) {
     }
 }
 
+function testConstructionWithUnalignedLength(type, name, elementSizeInBytes) {
+    if (elementSizeInBytes > 1) {
+        shouldThrowIndexSizeErr(function() {
+            var buffer = new ArrayBuffer(elementSizeInBytes + 1);
+            var array = new type(buffer, 0);
+        }, "Construction of " + name + " with unaligned length");
+    }
+}
+
 function testConstructionOfHugeArray(type, name, sz) {
     if (sz == 1)
         return;
@@ -425,6 +430,18 @@ function testConstructionOfHugeArray(type, name, sz) {
     }
 }
 
+function testConstructionWithBothArrayBufferAndLength(type, name, elementSizeInBytes) {
+    var bufByteLength = 1000 * elementSizeInBytes;
+    var buf = new ArrayBuffer(bufByteLength);
+    var array1 = new type(buf);
+    var array2 = new type(bufByteLength / elementSizeInBytes);
+    if (array1.length == array2.length) {
+        testPassed("Array lengths matched with explicit and implicit creation of ArrayBuffer");
+    } else {
+        testFailed("Array lengths DID NOT MATCH with explicit and implicit creation of ArrayBuffer");
+    }
+}
+
 // These need to be global for shouldBe to see them
 var array;
 var typeSize;
@@ -465,7 +482,7 @@ function testSlicingWithDefaultValues(type, name, sz) {
         typeSize = sz;
         shouldBe("array.length", "32 / typeSize");
         try {
-            shouldBe("array.slice().length", "(32 / typeSize)");
+            shouldBe("array.slice(0).length", "(32 / typeSize)");
             shouldBe("array.slice(2).length", "(32 / typeSize) - 2");
             shouldBe("array.slice(-2).length", "2");
             shouldBe("array.slice(-2147483648).length", "(32 / typeSize)");
@@ -633,7 +650,9 @@ function runTests() {
     testConstructionWithOutOfRangeValues(type, name);
     testConstructionWithNegativeOutOfRangeValues(type, name);
     testConstructionWithUnalignedOffset(type, name, testCase.elementSizeInBytes);
+    testConstructionWithUnalignedLength(type, name, testCase.elementSizeInBytes);
     testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes);
+    testConstructionWithBothArrayBufferAndLength(type, name, testCase.elementSizeInBytes);
     testSlicingWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
     testSlicingWithDefaultValues(type, name, testCase.elementSizeInBytes);
     testSettingFromArrayWithOutOfRangeOffset(type, name);
diff --git a/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt b/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
index 50ec94a..7bd6f17 100644
--- a/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/gl-enum-tests-expected.txt
@@ -7,27 +7,27 @@ Canvas.getContext
 PASS context exists
 
 Checking gl enums.
-PASS gl.getError() is gl.NO_ERROR
-PASS gl.bindTexture(desktopGL['TEXTURE_3D'], tex) should return INVALID_ENUM.
-PASS gl.blendEquation(desktopGL['MIN']) should return INVALID_ENUM.
-PASS gl.blendEquation(desktopGL['MAX']) should return INVALID_ENUM.
-PASS gl.blendEquationSeparate(desktopGL['MIN'], gl.FUNC_ADD) should return INVALID_ENUM.
-PASS gl.blendEquationSeparate(desktopGL['MAX'], gl.FUNC_ADD) should return INVALID_ENUM.
-PASS gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MIN']) should return INVALID_ENUM.
-PASS gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MAX']) should return INVALID_ENUM.
-PASS gl.bufferData(gl.ARRAY_BUFFER, 3, desktopGL['STATIC_READ']) should return INVALID_ENUM.
-PASS gl.disable(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
-PASS gl.disable(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
-PASS gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER']) should return INVALID_ENUM.
-PASS gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST) should return INVALID_ENUM.
-PASS gl.isEnabled(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
-PASS gl.isEnabled(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
-PASS gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1) should return INVALID_ENUM.
-PASS gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf) should return INVALID_ENUM.
-PASS gl.getError() is gl.NO_ERROR
-PASS gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.
-PASS gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST) should return INVALID_ENUM.
-PASS gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1) should return INVALID_ENUM.
+PASS getError was expected value: NO_ERROR : 
+PASS getError was expected value: INVALID_ENUM : gl.bindTexture(desktopGL['TEXTURE_3D'], tex) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquation(desktopGL['MIN']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquation(desktopGL['MAX']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquationSeparate(desktopGL['MIN'], gl.FUNC_ADD) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquationSeparate(desktopGL['MAX'], gl.FUNC_ADD) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MIN']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MAX']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.bufferData(gl.ARRAY_BUFFER, 3, desktopGL['STATIC_READ']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.disable(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.disable(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.isEnabled(desktopGL['CLIP_PLANE0']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.isEnabled(desktopGL['POINT_SPRITE']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf) should return INVALID_ENUM.
+PASS getError was expected value: NO_ERROR : 
+PASS getError was expected value: INVALID_ENUM : gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP']) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST) should return INVALID_ENUM.
+PASS getError was expected value: INVALID_ENUM : gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1) should return INVALID_ENUM.
 
 PASS successfullyParsed is true
 
diff --git a/LayoutTests/fast/canvas/webgl/gl-enum-tests.html b/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
index ec46c31..604a422 100644
--- a/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
+++ b/LayoutTests/fast/canvas/webgl/gl-enum-tests.html
@@ -28,11 +28,11 @@ if (!gl) {
   debug("");
   debug("Checking gl enums.");
 
-  var buffer = new ArrayBuffer(1);
+  var buffer = new ArrayBuffer(2);
   var buf = new Uint16Array(buffer);
   var tex = gl.createTexture();
   gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
-  shouldBe("gl.getError()", "gl.NO_ERROR");
+  glErrorShouldBe(gl, gl.NO_ERROR);
 
   var tests = [
     "gl.bindTexture(desktopGL['TEXTURE_3D'], tex)",
@@ -54,12 +54,12 @@ if (!gl) {
   ];
   for (var ii = 0; ii < tests.length; ++ii) {
     eval(tests[ii]);
-    assertMsg(gl.getError() == gl.INVALID_ENUM,
+    glErrorShouldBe(gl, gl.INVALID_ENUM,
               tests[ii] + " should return INVALID_ENUM.");
   }
 
   gl.bindTexture(gl.TEXTURE_2D, tex);
-  shouldBe("gl.getError()", "gl.NO_ERROR");
+  glErrorShouldBe(gl, gl.NO_ERROR);
 
   tests = [
     "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])",
@@ -68,7 +68,7 @@ if (!gl) {
   ];
   for (var ii = 0; ii < tests.length; ++ii) {
     eval(tests[ii]);
-    assertMsg(gl.getError() == gl.INVALID_ENUM,
+    glErrorShouldBe(gl, gl.INVALID_ENUM,
               tests[ii] + " should return INVALID_ENUM.");
   }
 }
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c46b79a..e5133ce 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-04  Zhenyao Mo  <zmo at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        TypedArray should throw exception if length not a multiple of element size
+        https://bugs.webkit.org/show_bug.cgi?id=45487
+
+        * bindings/js/JSArrayBufferViewHelper.h:
+        (WebCore::constructArrayBufferView):
+        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+        (WebCore::constructWebGLArray):
+
 2010-11-04  Kenneth Russell  <kbr at google.com>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/bindings/js/JSArrayBufferViewHelper.h b/WebCore/bindings/js/JSArrayBufferViewHelper.h
index 27a9a98..ba712c6 100644
--- a/WebCore/bindings/js/JSArrayBufferViewHelper.h
+++ b/WebCore/bindings/js/JSArrayBufferViewHelper.h
@@ -115,6 +115,8 @@ PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec)
         RefPtr<ArrayBuffer> buffer = toArrayBuffer(exec->argument(0));
         if (buffer) {
             unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0;
+            if ((buffer->byteLength() - offset) % sizeof(T))
+                throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size."));
             unsigned int length = (buffer->byteLength() - offset) / sizeof(T);
             if (exec->argumentCount() > 2)
                 length = exec->argument(2).toUInt32(exec);
diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
index ffea07c..2566b67 100644
--- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
+++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
@@ -94,6 +94,8 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
             if (!ok)
                 return throwError("Could not convert argument 1 to a number");
         }
+        if ((buf->byteLength() - offset) % sizeof(ElementType))
+            return throwError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.", V8Proxy::RangeError);
         uint32_t length = (buf->byteLength() - offset) / sizeof(ElementType);
         if (argLen > 2) {
             length = toUInt32(args[2], ok);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list