Commit 37904a52 authored by cmarrin@apple.com's avatar cmarrin@apple.com

WebGL crashes with recent CanvasArray change

        https://bugs.webkit.org/show_bug.cgi?id=30018



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49027 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1c86a86b
2009-10-02 Kenneth Russell <kbr@google.com>
Reviewed by Oliver Hunt.
WebGL crashes with recent CanvasArray change
https://bugs.webkit.org/show_bug.cgi?id=30018
* fast/canvas/webgl/array-unit-tests-expected.html: Added.
* fast/canvas/webgl/array-unit-tests.html: Added.
2009-10-02 Ben Murdoch <benm@google.com>
Reviewed by David Kilzer.
......
Verifies the functionality of the new array-like objects in the WebGL spec
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS test CanvasByteArray SetAndGetPos10ToNeg10
PASS test CanvasByteArray ConstructWithArrayOfSignedValues
PASS test CanvasByteArray BoundaryConditions(-128, -128, 127, 127)
PASS test CanvasFloatArray SetAndGetPos10ToNeg10
PASS test CanvasFloatArray ConstructWithArrayOfSignedValues
PASS test CanvasFloatArray BoundaryConditions(-500, -500, 500, 500)
PASS test CanvasIntArray SetAndGetPos10ToNeg10
PASS test CanvasIntArray ConstructWithArrayOfSignedValues
PASS test CanvasIntArray BoundaryConditions(-2147483648, -2147483648, 2147483647, 2147483647)
PASS test CanvasShortArray SetAndGetPos10ToNeg10
PASS test CanvasShortArray ConstructWithArrayOfSignedValues
PASS test CanvasShortArray BoundaryConditions(-32768, -32768, 32767, 32767)
PASS test CanvasUnsignedByteArray SetAndGet10To1
PASS test CanvasUnsignedByteArray ConstructWithArrayOfUnsignedValues
PASS test CanvasUnsignedByteArray BoundaryConditions(0, 0, 255, 255)
PASS test CanvasUnsignedIntArray SetAndGet10To1
PASS test CanvasUnsignedIntArray ConstructWithArrayOfUnsignedValues
PASS test CanvasUnsignedIntArray BoundaryConditions(0, 0, 4294967295, 4294967295)
PASS test CanvasUnsignedShortArray SetAndGet10To1
PASS test CanvasUnsignedShortArray ConstructWithArrayOfUnsignedValues
PASS test CanvasUnsignedShortArray BoundaryConditions(0, 0, 65535, 65535)
Test passed.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitWebGLEnabled", "1");
description("Verifies the functionality of the new array-like objects in the WebGL spec");
var currentlyRunning = '';
var allPassed = true;
function running(str) {
currentlyRunning = str;
}
function output(str) {
debug(str);
}
function pass() {
testPassed(currentlyRunning);
}
function fail(str) {
var exc = 'FAILED: ' + currentlyRunning + ': ' + str;
testFailed(str);
}
function assertEq(prefix, expected, val) {
if (expected != val) {
fail(prefix + ': expected ' + expected + ', got ' + val);
}
}
function printSummary() {
if (allPassed) {
debug("Test passed.");
} else {
debug("TEST FAILED");
}
}
//
// Tests for unsigned array variants
//
function testSetAndGet10To1(type, name) {
running('test ' + name + ' SetAndGet10To1');
try {
var array = new type(10);
for (var i = 0; i < 10; i++) {
array[i] = 10 - i;
}
for (var i = 0; i < 10; i++) {
assertEq('Element ' + i, 10 - i, array[i]);
}
pass();
} catch (e) {
fail(e);
}
}
function testConstructWithArrayOfUnsignedValues(type, name) {
running('test ' + name + ' ConstructWithArrayOfUnsignedValues');
try {
var array = new type([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
assertEq('Array length', 10, array.length);
for (var i = 0; i < 10; i++) {
assertEq('Element ' + i, 10 - i, array[i]);
}
pass();
} catch (e) {
fail(e);
}
}
//
// Tests for signed array variants
//
function testSetAndGetPos10ToNeg10(type, name) {
running('test ' + name + ' SetAndGetPos10ToNeg10');
try {
var array = new type(21);
for (var i = 0; i < 21; i++) {
array[i] = 10 - i;
}
for (var i = 0; i < 21; i++) {
assertEq('Element ' + i, 10 - i, array[i]);
}
pass();
} catch (e) {
fail(e);
}
}
function testConstructWithArrayOfSignedValues(type, name) {
running('test ' + name + ' ConstructWithArrayOfSignedValues');
try {
var array = new type([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]);
assertEq('Array length', 21, array.length);
for (var i = 0; i < 21; i++) {
assertEq('Element ' + i, 10 - i, array[i]);
}
pass();
} catch (e) {
fail(e);
}
}
//
// Test cases for both signed and unsigned types
//
function testBoundaryConditions(type, name, lowValue, expectedLowValue, highValue, expectedHighValue) {
running('test ' + name + ' BoundaryConditions(' +
lowValue + ', ' + expectedLowValue + ', ' +
highValue + ', ' + expectedHighValue + ')');
try {
var array = new type(1);
assertEq('Array length', 1, array.length);
array[0] = lowValue;
assertEq('Element 0', expectedLowValue, array[0]);
array[0] = highValue;
assertEq('Element 0', expectedHighValue, array[0]);
pass();
} catch (e) {
fail(e);
}
}
//
// Test driver
//
function runTests() {
allPassed = true;
// The "name" attribute is a concession to browsers which don't
// implement the "name" property on function objects
var testCases =
[ {name: "CanvasByteArray",
unsigned: false,
low: -128,
expectedLow: -128,
high: 127,
expectedHigh: 127},
{name: "CanvasFloatArray",
unsigned: false,
low: -500,
expectedLow: -500,
high: 500,
expectedHigh: 500},
{name: "CanvasIntArray",
unsigned: false,
low: -2147483648,
expectedLow: -2147483648,
high: 2147483647,
expectedHigh: 2147483647},
{name: "CanvasShortArray",
unsigned: false,
low: -32768,
expectedLow: -32768,
high: 32767,
expectedHigh: 32767},
{name: "CanvasUnsignedByteArray",
unsigned: true,
low: 0,
expectedLow: 0,
high: 255,
expectedHigh: 255},
{name: "CanvasUnsignedIntArray",
unsigned: true,
low: 0,
expectedLow: 0,
high: 4294967295,
expectedHigh: 4294967295},
{name: "CanvasUnsignedShortArray",
unsigned: true,
low: 0,
expectedLow: 0,
high: 65535,
expectedHigh: 65535} ];
for (var i = 0; i < testCases.length; i++) {
var testCase = testCases[i];
running(testCase.name);
if (!(testCase.name in window)) {
fail("does not exist");
continue;
}
var type = window[testCase.name];
var name = testCase.name;
if (testCase.unsigned) {
testSetAndGet10To1(type, name);
testConstructWithArrayOfUnsignedValues(type, name);
} else {
testSetAndGetPos10ToNeg10(type, name);
testConstructWithArrayOfSignedValues(type, name);
}
testBoundaryConditions(type,
name,
testCase.low,
testCase.expectedLow,
testCase.high,
testCase.expectedHigh);
}
printSummary();
}
runTests();
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>
2009-10-02 Kenneth Russell <kbr@google.com>
Reviewed by Oliver Hunt.
WebGL crashes with recent CanvasArray change
https://bugs.webkit.org/show_bug.cgi?id=30018
Test: fast/canvas/webgl/array-unit-tests.html
* html/canvas/CanvasArray.cpp:
(WebCore::CanvasArray::CanvasArray):
Fix bug where PassRefPtr was tested after transferring value to RefPtr.
2009-10-02 Steve Falkenburg <sfalken@apple.com>
Reviewed by Mark Rowe.
......@@ -36,7 +36,7 @@ namespace WebCore {
: m_offset(offset)
, m_buffer(buffer)
{
m_baseAddress = buffer ? (static_cast<char*>(m_buffer->data()) + m_offset) : 0;
m_baseAddress = m_buffer ? (static_cast<char*>(m_buffer->data()) + m_offset) : 0;
}
CanvasArray::~CanvasArray()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment