Diff
Copied: branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset-expected.txt (from rev 104736, trunk/LayoutTests/fast/canvas/webgl/array-set-with-offset-expected.txt) (0 => 104772)
--- branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset-expected.txt (rev 0)
+++ branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset-expected.txt 2012-01-12 01:15:38 UTC (rev 104772)
@@ -0,0 +1,51 @@
+Test setting WebGL array with offset
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Regression test for https://bugs.webkit.org/show_bug.cgi?id=76040 : Int16Array.set(array, offset) fails on first execution
+Testing Int8Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Uint8Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Int16Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Uint16Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Int32Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Uint32Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+Testing Float32Array
+PASS webGLArray[0] is 0
+PASS webGLArray[1] is 1
+PASS webGLArray[2] is 2
+PASS webGLArray[3] is bounds[0]
+PASS webGLArray[4] is bounds[1]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset.html (from rev 104736, trunk/LayoutTests/fast/canvas/webgl/array-set-with-offset.html) (0 => 104772)
--- branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset.html (rev 0)
+++ branches/chromium/963/LayoutTests/fast/canvas/webgl/array-set-with-offset.html 2012-01-12 01:15:38 UTC (rev 104772)
@@ -0,0 +1,45 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Test setting WebGL array with offset");
+
+debug('Regression test for <a href="" : <code>Int16Array.set(array, offset) fails on first execution</code>');
+
+var webGLArray = null;
+var array = null;
+var bounds = null;
+
+function testSetters(typeName, low, high) {
+ bounds = [low, high];
+ var type = window[typeName];
+ var array_buffer = new ArrayBuffer(32);
+ webGLArray = new type(array_buffer);
+ debug("Testing " + typeName);
+ array = [1, 2, low, high];
+ webGLArray.set(array, 1);
+ shouldBe("webGLArray[0]", "0");
+ shouldBe("webGLArray[1]", "1");
+ shouldBe("webGLArray[2]", "2");
+ shouldBe("webGLArray[3]", "bounds[0]");
+ shouldBe("webGLArray[4]", "bounds[1]");
+}
+
+testSetters("Int8Array", -128, 127);
+testSetters("Uint8Array", 0, 255);
+testSetters("Int16Array", -32768, 32767);
+testSetters("Uint16Array", 0, 65535);
+testSetters("Int32Array", -2147483648, 2147483647);
+testSetters("Uint32Array", 0, 4294967295);
+testSetters("Float32Array", -2.5, 3.5);
+</script>
+
+<script src=""
+</body>
+</html>
Modified: branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp (104771 => 104772)
--- branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp 2012-01-12 01:02:49 UTC (rev 104771)
+++ branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp 2012-01-12 01:15:38 UTC (rev 104772)
@@ -58,12 +58,18 @@
}
-void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray)
+void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray, uint32_t offset)
{
v8::Handle<v8::String> key = v8::String::New("set");
v8::Handle<v8::Function> set = destArray->Get(key).As<v8::Function>();
- v8::Handle<v8::Value> argument = srcArray;
- set->Call(destArray, 1, &argument);
+ v8::Handle<v8::Value> arguments[2];
+ int numberOfArguments = 1;
+ arguments[0] = srcArray;
+ if (offset) {
+ arguments[1] = v8::Uint32::New(offset);
+ numberOfArguments = 2;
+ }
+ set->Call(destArray, numberOfArguments, arguments);
}
}
Modified: branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (104771 => 104772)
--- branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2012-01-12 01:02:49 UTC (rev 104771)
+++ branches/chromium/963/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2012-01-12 01:15:38 UTC (rev 104772)
@@ -51,7 +51,7 @@
// Copy the elements from the source array to the typed destination array by
// invoking the 'set' method of the destination array in JS.
-void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray);
+void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray, uint32_t offset);
// Template function used by the ArrayBufferView*Constructor callbacks.
@@ -171,7 +171,7 @@
args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length());
if (!srcArray.IsEmpty())
- copyElements(args.Holder(), srcArray);
+ copyElements(args.Holder(), srcArray, 0);
return toV8(array.release(), args.Holder(), MarkIndependent);
}
@@ -212,7 +212,7 @@
else {
if (!fastSetInstalled(args.Holder())) {
installFastSet(args.Holder());
- copyElements(args.Holder(), array);
+ copyElements(args.Holder(), array, offset);
} else {
for (uint32_t i = 0; i < length; i++)
impl->set(offset + i, array->Get(i)->NumberValue());