Commit a1391806 authored by xidachen's avatar xidachen Committed by Commit bot

Removed some duplicate layout tests under fast/canvas/webgl

Most of these tests are testing conformance for TypedArrays, ArrayBuffer,
bufferData, and some basic WebGL functions. I believe all these tests
are upstreamed in Github, so there is no reason to keep it here.

Note that I didn't delete all tests under this dir, only the ones I
can quickly locate its duplicates on conformance test suite.

BUG=none

Review-Url: https://codereview.chromium.org/2447493002
Cr-Commit-Position: refs/heads/master@{#427194}
parent d2c61e49
......@@ -5,9 +5,6 @@
crbug.com/420198 [ Linux ] fast/js/regress [ Skip ]
crbug.com/420198 [ Linux ] virtual/slimmingpaint/fast/js/regress [ Skip ]
crbug.com/420198 [ Linux ] editing/selection/move-by-word-visually-crash-test-5.html [ Skip ]
crbug.com/420198 [ Linux ] fast/canvas/webgl/webgl-large-texture.html [ Skip ]
crbug.com/420198 [ Linux ] virtual/display_list_2d_canvas/fast/canvas/webgl/webgl-large-texture.html [ Skip ]
crbug.com/420198 [ Linux ] virtual/slimmingpaint/fast/canvas/webgl/webgl-large-texture.html [ Skip ]
crbug.com/420198 [ Linux ] perf/array-nested-loop.html [ Skip ]
crbug.com/420198 [ Linux ] fast/css/fontface-arraybuffer.html [ Skip ]
crbug.com/420198 [ Linux ] virtual/slimmingpaint/fast/css/fontface-arraybuffer.html [ Skip ]
......@@ -43,4 +40,4 @@ crbug.com/462190 [ Linux ] inspector-protocol/heap-profiler/heap-snapshot-with-e
crbug.com/577889 [ Linux ] fast/js/typed-array-allocation-failure.html [ Crash ]
# These tests use OpenGl, which crashes on MSAN builds due to missing instrumentation
crbug.com/555703 [ Linux ] virtual/media-gpu-accelerated [ Skip ]
\ No newline at end of file
crbug.com/555703 [ Linux ] virtual/media-gpu-accelerated [ Skip ]
......@@ -247,8 +247,6 @@ crbug.com/490511 imported/wpt/html/semantics/embedded-content/media-elements/pla
crbug.com/490511 imported/wpt/html/semantics/forms/textfieldselection/selection.html [ Slow ]
crbug.com/346259 http/tests/websocket/no-crash-on-cookie-flood.html [ Slow ]
crbug.com/358313 virtual/gpu/fast/canvas/webgl/webgl-large-texture.html [ Slow ]
crbug.com/522646 http/tests/media/encrypted-media/encrypted-media-encrypted-event-different-origin.html [ Slow ]
crbug.com/411164 [ Win ] http/tests/security/powerfulFeatureRestrictions/serviceworker-on-insecure-origin.html [ Slow ]
crbug.com/510337 inspector/console/console-format.html [ Slow ]
......
PASS successfullyParsed is true
TEST COMPLETE
Test that the event passed to a listener of webglcontextlost is a WebGLContextEvent.
PASS evt.toString() is '[object WebGLContextEvent]'
PASS evt.statusMessage is ''
PASS context.getError() is context.NO_ERROR
Test that the event passed to a listener of webglcontextrestored is a WebGLContextEvent.
PASS evt.toString() is '[object WebGLContextEvent]'
PASS evt.statusMessage is ''
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
<script>
var evt;
var canvas;
var context;
var extension;
function createNewCanvas()
{
canvas = document.createElement("canvas");
canvas.width = 1;
canvas.height = 1;
context = WebGLTestUtils.create3DContext(canvas);
extension = context.getExtension("WEBGL_lose_context");
if (!extension) {
debug("Could not find the WEBGL_lose_context extension.");
return;
}
}
function runTest1()
{
if (window.initNonKhronosFramework)
window.initNonKhronosFramework(true);
createNewCanvas();
canvas.addEventListener("webglcontextlost", function(e) {
evt = e;
debug("Test that the event passed to a listener of webglcontextlost is a WebGLContextEvent.")
shouldBe("evt.toString()", "'[object WebGLContextEvent]'");
shouldBe("evt.statusMessage", "''");
// Start the next test when event dispatch has finished.
setTimeout(function() {
runTest2();
}, 0);
}, false);
extension.loseContext();
}
function runTest2()
{
createNewCanvas();
canvas.addEventListener("webglcontextlost", function(e) {
e.preventDefault();
// Restore the context after event dispatch has finished.
setTimeout(function() {
// Because context restoration is specified as being asynchronous, we can not verify
// that the GL error state is empty here.
extension.restoreContext();
}, 0);
}, false);
canvas.addEventListener("webglcontextrestored", function(e) {
evt = e;
shouldBe("context.getError()", "context.NO_ERROR");
debug("Test that the event passed to a listener of webglcontextrestored is a WebGLContextEvent.")
shouldBe("evt.toString()", "'[object WebGLContextEvent]'");
shouldBe("evt.statusMessage", "''");
setTimeout(finish, 0);
}, false);
extension.loseContext();
}
function finish() {
finishJSTest();
}
</script>
</head>
<body onload="runTest1()">
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas">
</body>
</html>
Checks that array access in a shader can not read out of bounds
PASS Top left corner should clamp to index 0
PASS Inside top right corner should clamp to index 0
PASS Inside bottom left corner should clamp to index 0
PASS Bottom right corner should clamp to index 7
PASS Outside bottom left corner should clamp to index 7
PASS Outside top right corner should clamp to index 7
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL array bounds clamping conformance test.</title>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"> </script>
</head>
<body>
<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
#ifdef GL_ES
precision highp float;
#endif
attribute vec4 vPosition;
attribute float index;
uniform float shades[8];
varying vec4 texColor;
void main()
{
gl_Position = vPosition;
texColor = vec4(shades[int(index)], 0, 0, 1.0);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;
#endif
varying vec4 texColor;
void main()
{
gl_FragColor = texColor;
}
</script>
<script>
function init()
{
if (window.initNonKhronosFramework)
window.initNonKhronosFramework(false);
debug("Checks that array access in a shader can not read out of bounds");
debug("");
gl = initWebGL("example", "vshader", "fshader", [ "vPosition", "index" ],
[ 1, 1, 1, 1 ], 1);
gl.disable(gl.DEPTH_TEST);
gl.disable(gl.BLEND);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER,
new Float32Array([ -1,1,0, 1,1,0, -1,-1,0,
-1,-1,0, 1,1,0, 1,-1,0 ]),
gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER,
// Create an array that exercises well outside the
// limits on each side, near the limits, and the
// exact limits.
// This should be clamped to [0, 0, 0, 7, 7, 7]
new Float32Array([ -123456789, -1, 0, 7, 8, 123456789]),
gl.STATIC_DRAW);
gl.enableVertexAttribArray(1);
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, 0, 0);
var loc = gl.getUniformLocation(gl.program, "shades");
gl.uniform1fv(loc, [0.25, 0.5, 0, 0, 0, 0, 0.75, 1]);
checkRedValue(0, 38, 64, "Top left corner should clamp to index 0");
checkRedValue(37, 38, 64, "Inside top right corner should clamp to index 0");
checkRedValue(0, 1, 64, "Inside bottom left corner should clamp to index 0");
checkRedValue(38, 0, 255, "Bottom right corner should clamp to index 7");
checkRedValue(3, 1, 255, "Outside bottom left corner should clamp to index 7");
checkRedValue(38, 37, 255, "Outside top right corner should clamp to index 7");
function checkRedValue(x, y, value, msg) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 6);
gl.flush();
var buf = new Uint8Array(4);
gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
if (buf[0] != value || buf[1] != 0 || buf[2] != 0 || buf[3] != 255) {
debug('expected: rgb(' + value + ', 0, 0, 255) was rgb(' + buf[0] + ', ' + buf[1] + ', ' + buf[2] + ', ' + buf[3] + ')');
testFailed(msg);
return;
}
testPassed(msg);
}
}
init();
</script>
</body>
</html>
Verify that reassigning typed array constructor does not crash.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS reassigning typed array constructor did not crash
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Verify that reassigning typed array constructor does not crash.');
<!-- The following used to cause a crash in Chrome -->
Uint8Array = 0;
Uint16Array = "string";
Uint32Array = function() {};
Int16Array = function() {};
Int16Array.prototype.set = 0;
new Float64Array(function () {});
new Float32Array([1, 2, 3], 1);
new Int16Array(function() {});
testPassed("reassigning typed array constructor did not crash");
</script>
<script>
</script>
</body>
</html>
Verifies that when constructing WebGLArray with nan values, it results in a 0
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 10 is 10
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 10 is 10
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS 0 is 0
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Verifies that when constructing WebGLArray with nan values, it results in a 0");
var source, target, idx;
source = new Array(10);
target = new Uint8Array(source);
shouldBe(target.length.toString(), source.length.toString())
for (idx = 0; idx < target.length; idx++) {
shouldBeZero(target[idx].toString());
}
source = {length: 10};
target = new Uint8Array(source);
shouldBe(target.length.toString(), source.length.toString())
for (idx = 0; idx < target.length; idx++) {
shouldBeZero(target[idx].toString());
}
</script>
</body>
</html>
Verifies that the get method, and the set method for individual elements, on the WebGLArray types no longer exist.
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=38039
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS webGLArray.get is undefined.
PASS webGLArray.set(0, 1) threw exception.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Verifies that the get method, and the set method for individual elements, on the WebGLArray types no longer exist.");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=38039">https://bugs.webkit.org/show_bug.cgi?id=38039</a>');
// Global scope so shouldThrow can see it
var webGLArray;
function negativeTestGetAndSetMethods(typeName) {
var type = window[typeName];
webGLArray = new type([2, 3]);
shouldBeUndefined("webGLArray.get");
var exceptionThrown = false;
// We deliberately check for an exception here rather than using
// shouldThrow here because the precise contents of the syntax
// error are not specified.
try {
webGLArray.set(0, 1);
} catch (e) {
exceptionThrown = true;
}
var output = "webGLArray.set(0, 1) ";
if (exceptionThrown) {
testPassed(output + "threw exception.");
} else {
testFailed(output + "did not throw exception.");
}
}
negativeTestGetAndSetMethods("Int8Array");
negativeTestGetAndSetMethods("Uint8Array");
negativeTestGetAndSetMethods("Int16Array");
negativeTestGetAndSetMethods("Uint16Array");
negativeTestGetAndSetMethods("Int32Array");
negativeTestGetAndSetMethods("Uint32Array");
negativeTestGetAndSetMethods("Float32Array");
</script>
</body>
</html>
Verifies that calling the indexing operator on WebGLArrays with out-of-range indices returns undefined.
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=38039
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS webGLArray[2] is undefined.
PASS webGLArray[-1] is undefined.
PASS webGLArray[0x20000000] is undefined.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Verifies that calling the indexing operator on WebGLArrays with out-of-range indices returns undefined.");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=38039">https://bugs.webkit.org/show_bug.cgi?id=38039</a>');
// Global scope so shouldThrow can see it
var webGLArray;
function testGetWithOutOfRangeIndices(typeName) {
var type = window[typeName];
webGLArray = new type([2, 3]);
shouldBeUndefined("webGLArray[2]");
shouldBeUndefined("webGLArray[-1]");
shouldBeUndefined("webGLArray[0x20000000]");
}
testGetWithOutOfRangeIndices("Int8Array");
testGetWithOutOfRangeIndices("Uint8Array");
testGetWithOutOfRangeIndices("Int16Array");
testGetWithOutOfRangeIndices("Uint16Array");
testGetWithOutOfRangeIndices("Int32Array");
testGetWithOutOfRangeIndices("Uint32Array");
testGetWithOutOfRangeIndices("Float32Array");
</script>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script src="script-tests/array-message-passing.js"></script>
</body>
</html>
Test overriding the set method of WebGL array
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=87862 : [v8] Crash after redefining setter on typed array to a number
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS array[0] is 0
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test overriding the set method of WebGL array");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=87862">https://bugs.webkit.org/show_bug.cgi?id=87862</a> : <code>[v8] Crash after redefining setter on typed array to a number</code>');
var array;
var typeNames = ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array',
'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array']
function overrideSetWithNumberAndConstruct(typeName) {
var type = window[typeName];
type.prototype.set = 0x3ffff;
array = new type([0], function() {});
shouldBe("array[0]", "0");
}
for (var i = 0; i < typeNames.length; i++) {
overrideSetWithNumberAndConstruct(typeNames[i]);
}
function overrideSetWithNumberAndSet(typeName) {
var type = window[typeName];
array = new type(10);
type.prototype.set = 0x3ffff;
array[0] = 8;
array.set([0], function() {});
shouldBe("array[0]", "0");
}
for (var i = 0; i < typeNames.length; i++) {
overrideSetWithNumberAndConstruct(typeNames[i]);
}
</script>
</body>
</html>
Verifies that attempting to set invalid elements to a Typed Array throws an exception
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS typedArray.set() threw exception TypeError: Cannot read property 'length' of undefined.
PASS typedArray.set('hello world') threw exception RangeError: Source is too large.
PASS typedArray.set(otherArray, 1) threw exception RangeError: Source is too large.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Verifies that attempting to set invalid elements to a Typed Array throws an exception");
// Global scope so shouldThrow can see it
var typedArray, otherArray;
function negativeTestSet(typeName) {
var type = window[typeName];
typedArray = new type(10);
shouldThrow("typedArray.set()");
shouldThrow("typedArray.set('hello world')");
otherArray = new type(typedArray.length);
shouldThrow("typedArray.set(otherArray, 1)");
}
negativeTestSet("Int8Array");
negativeTestSet("Uint8Array");
negativeTestSet("Int16Array");
negativeTestSet("Uint16Array");
negativeTestSet("Int32Array");
negativeTestSet("Uint32Array");
negativeTestSet("Float32Array");
</script>
</body>
</html>
Verifies that attempting to set out-of-bounds elements of a WebGLArray from a JavaScript array throws an exception
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=33352 : Passing array that is too large to set method of WebGLArrays does not throw an exception
Testing Int8Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Uint8Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Int16Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Uint16Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Int32Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Uint32Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
Testing Float32Array
PASS webGLArray.set([4, 5], 1) threw exception RangeError: Source is too large.
PASS webGLArray.set([4, 5, 6]) threw exception RangeError: Source is too large.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Verifies that attempting to set out-of-bounds elements of a WebGLArray from a JavaScript array throws an exception");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=33352">https://bugs.webkit.org/show_bug.cgi?id=33352</a> : <code>Passing array that is too large to set method of WebGLArrays does not throw an exception</code>');
// Global scope so shouldThrow can see it
var webGLArray;
function negativeTestSet(typeName) {
var type = window[typeName];
webGLArray = new type([2, 3]);
debug('Testing ' + typeName);
shouldThrow("webGLArray.set([4, 5], 1)");
shouldThrow("webGLArray.set([4, 5, 6])");
}
negativeTestSet("Int8Array");
negativeTestSet("Uint8Array");
negativeTestSet("Int16Array");
negativeTestSet("Uint16Array");
negativeTestSet("Int32Array");
negativeTestSet("Uint32Array");
negativeTestSet("Float32Array");
</script>
</body>
</html>
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
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test setting WebGL array with offset");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76040">https://bugs.webkit.org/show_bug.cgi?id=76040</a> : <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>
</body>
</html>
Test all permutations of WebGLArray setters to make sure values don't get truncated
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=33350 : WebGLArray subclasses do the wrong conversion in indexSetter
Testing Int8Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Uint8Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Int16Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Uint16Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Int32Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Uint32Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
Testing Float32Array
PASS webGLArray is array
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[0] is 0
PASS webGLArray[1] is 0
PASS webGLArray[0] is array[0]
PASS webGLArray[1] is array[1]
PASS webGLArray[2] is 88
PASS webGLArray[3] is 99
PASS webGLArray[1] is 88
PASS webGLArray[2] is 99
PASS array[0] is 99
PASS array[1] is 99
PASS webGLArray[3] is 99
PASS webGLArray[4] is 77
PASS array[0] is 99
PASS array[1] is 99
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test all permutations of WebGLArray setters to make sure values don't get truncated");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=33350">https://bugs.webkit.org/show_bug.cgi?id=33350</a> : <code>WebGLArray subclasses do the wrong conversion in indexSetter</code>');
var webGLArray = null;
var array = null;
function testSetters(typeName, low, high) {
var type = window[typeName];
webGLArray = new type(2);
array = [low, high];
debug("Testing " + typeName);
webGLArray.set(array);
shouldBe("webGLArray", "array");
shouldBe("webGLArray[0]", "array[0]");
shouldBe("webGLArray[1]", "array[1]");
webGLArray[0] = 0;
webGLArray[1] = 0;
shouldBe("webGLArray[0]", "0");
shouldBe("webGLArray[1]", "0");
webGLArray[0] = array[0];
shouldBe("webGLArray[0]", "array[0]");
webGLArray[1] = array[1];
shouldBe("webGLArray[1]", "array[1]");
// Verify set() behaves correctly with shared underlying buffer.
array = [0, 1, 2, 3, 4, 5];
webGLArray = new type(6);
webGLArray.set(array);
array = webGLArray.subarray(2, 4);
array[0] = 88;
array[1] = 99;
shouldBe("webGLArray[2]", "88");
shouldBe("webGLArray[3]", "99");
// pre-overlap
webGLArray.set(array, 1);
shouldBe("webGLArray[1]", "88");
shouldBe("webGLArray[2]", "99");
shouldBe("array[0]", "99");
shouldBe("array[1]", "99");
array[1] = 77;
// post-overlap
webGLArray.set(array, 3);
shouldBe("webGLArray[3]", "99");
shouldBe("webGLArray[4]", "77");
shouldBe("array[0]", "99");
shouldBe("array[1]", "99");
}
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>
</body>
</html>
Test transfer of control semantics for ArrayBuffers.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS sanity check
PASS raw ArrayBuffer
PASS sending buffers is sane even if cloning doesn't special-case
PASS send every view
PASS transfer list multiple
PASS transfer neuters unmentioned
PASS raw Int32
PASS raw Uint32
PASS raw Int8
PASS raw Uint8
PASS raw Uint8Clamped
PASS raw Int16
PASS raw Uint16
PASS raw Float32
PASS raw Float64
PASS raw DataView
PASS send view, buffer for Int32
PASS send view, buffer for Uint32
PASS send view, buffer for Int8
PASS send view, buffer for Uint8
PASS send view, buffer for Uint8Clamped
PASS send view, buffer for Int16
PASS send view, buffer for Uint16
PASS send view, buffer for Float32
PASS send view, buffer for Float64
PASS send view, buffer for DataView
PASS send buffer, view for Int32
PASS send buffer, view for Uint32
PASS send buffer, view for Int8
PASS send buffer, view for Uint8
PASS send buffer, view for Uint8Clamped
PASS send buffer, view for Int16
PASS send buffer, view for Uint16
PASS send buffer, view for Float32
PASS send buffer, view for Float64
PASS send buffer, view for DataView
PASS squash unrelated views for Int32
PASS squash unrelated views for Uint32
PASS squash unrelated views for Int8
PASS squash unrelated views for Uint8
PASS squash unrelated views for Uint8Clamped
PASS squash unrelated views for Int16
PASS squash unrelated views for Uint16
PASS squash unrelated views for Float32
PASS squash unrelated views for Float64
PASS squash unrelated views for DataView
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script src="script-tests/arraybuffer-transfer-of-control.js"></script>
</body>
</html>
Test bufferData/bufferSubData with ArrayBuffer input
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=41884 : Implement bufferData and bufferSubData with ArrayBuffer as input
PASS gl is non-null.
PASS array is non-null.
PASS [object WebGLBuffer] is non-null.
PASS getError was expected value: INVALID_OPERATION :
PASS getError was expected value: NO_ERROR :
PASS getError was expected value: INVALID_VALUE :
PASS getError was expected value: INVALID_VALUE :
PASS getError was expected value: NO_ERROR :
PASS getError was expected value: INVALID_VALUE :
PASS getError was expected value: INVALID_VALUE :
PASS getError was expected value: NO_ERROR :
PASS getError was expected value: INVALID_VALUE :
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test bufferData/bufferSubData with ArrayBuffer input");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=41884">https://bugs.webkit.org/show_bug.cgi?id=41884</a> : <code>Implement bufferData and bufferSubData with ArrayBuffer as input</code>');
if (window.internals)
window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
var gl = create3DContext();
shouldBeNonNull("gl");
var array = new ArrayBuffer(128);
shouldBeNonNull("array");
var buf = gl.createBuffer();
shouldBeNonNull(buf);
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
glErrorShouldBe(gl, gl.INVALID_OPERATION);
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferData(gl.ARRAY_BUFFER, -10, gl.STATIC_DRAW);
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
glErrorShouldBe(gl, gl.NO_ERROR);
array = new ArrayBuffer(64);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, array);
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, new Float32Array(8));
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, null);
glErrorShouldBe(gl, gl.INVALID_VALUE);
</script>
</body>
</html>
Checks that copying canvas results to a WebGL texture functions without error.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
PASS Should have rendered red.
PASS Should have rendered blue.
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<script>
description("Checks that copying canvas results to a WebGL texture functions without error.");
var wtu = WebGLTestUtils;
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var canvas;
var gl;
var ctx;
function draw()
{
ctx.fillStyle = "rgb(200, 0, 0)";
ctx.fillRect(0, 0, 256, 256);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
wtu.drawQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [200, 0, 0, 255], "Should have rendered red.", 1);
ctx.fillStyle = "rgb(0, 0, 200)";
ctx.fillRect(0, 0, 256, 256);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
ctx.fillStyle = "rgb(200, 0, 0)";
ctx.fillRect(0, 0, 256, 256);
wtu.drawQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 0, 200, 255], "Should have rendered blue.", 1);
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = function()
{
if (window.initNonKhronosFramework)
window.initNonKhronosFramework(false);
canvas = document.getElementById("webgl-canvas");
gl = create3DContext(canvas);
canvas2d = document.getElementById("canvas-2d");
// Set a size that ensures a hardware-accelerated canvas.
canvas2d.width = 256;
canvas2d.height = 256;
ctx = canvas2d.getContext("2d");
var program = wtu.setupTexturedQuad(gl);
var bufferObjects = wtu.setupUnitQuad(gl);
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
gl.viewport(0, 0, canvas.width, canvas.height);
// Ensure that the compositor has become active.
setTimeout(draw, 0);
}
</script>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="webgl-canvas" width="32px" height="32px"></canvas>
<canvas id="canvas-2d" style="transform: translateZ(0);"></canvas>
</body>
</html>
uniform float u_floats[4];
void main()
{
float sum = u_floats[0] + u_floats[1] + u_floats[2] + u_floats[3];
gl_Position = vec4(sum, 0.0, 0.0, 1.0);
}
\ No newline at end of file
uniform int u_ints[4];
void main()
{
int sum = u_ints[0] + u_ints[1] + u_ints[2] + u_ints[3];
gl_Position = vec4(sum, 0.0, 0.0, 1.0);
}
\ No newline at end of file
onmessage = function(evt) {
var array = new Uint32Array(1);
var view = new DataView(array.buffer);
view.setUint32(0, 12345678, true);
postMessage(view.getUint32(0, true));
}
window.jsTestIsAsync = true;
description('Test passing ArrayBuffers and ArrayBufferViews in messages.');
window.testsComplete = 0;
function classCompare(testName, got, sent) {
var classString = Object.prototype.toString;
var gotClass = classString.call(got);
var sentClass = classString.call(sent);
if (gotClass !== sentClass) {
testFailed(testName + ": class " + sentClass + " became " + gotClass);
return false;
} else {
testPassed(testName + ": classes are " + sentClass);
return true;
}
}
function bufferCompare(testName, got, sent) {
if (!classCompare(testName, got, sent)) {
return false;
}
if (got.byteLength !== sent.byteLength) {
testFailed(testName + ": expected byteLength " + sent.byteLength + " bytes, got " + got.byteLength);
return false;
} else {
testPassed(testName + ": buffer lengths are " + sent.byteLength);
}
var gotReader = new Uint8Array(got);
var sentReader = new Uint8Array(sent);
for (var i = 0; i < sent.byteLength; ++i) {
if (gotReader[i] !== sentReader[i]) {
testFailed(testName + ": buffers differ starting at byte " + i);
return false;
}
}
testPassed(testName + ": buffers have the same contents");
return true;
}
function viewCompare(testName, got, sent) {
if (!classCompare(testName, got, sent)) {
return false;
}
if (!bufferCompare(testName, got.buffer, sent.buffer)) {
return false;
}
if (got.byteOffset !== sent.byteOffset) {
testFailed(testName + ": offset " + sent.byteOffset + " became " + got.byteOffset);
return false;
} else {
testPassed(testName + ": offset is " + sent.byteOffset);
}
if (got.byteLength !== sent.byteLength) {
testFailed(testName + ": length " + sent.byteLength + " became " + got.byteLength);
return false;
} else {
testPassed(testName + ": length is " + sent.byteLength);
}
return true;
}
function typedArrayCompare(testName, got, sent) {
if (!viewCompare(testName, got, sent)) {
return false;
}
if (got.BYTES_PER_ELEMENT !== sent.BYTES_PER_ELEMENT) {
// Sanity checking.
testFailed(testName + ": expected BYTES_PER_ELEMENT " + sent.BYTES_PER_ELEMENT + ", saw " + got.BYTES_PER_ELEMENT);
return false;
}
return true;
}
function dataViewCompare(testName, got, sent) {
return viewCompare(testName, got, sent);
}
function dataViewCompare2(testName, got, sent) {
for (var i = 0; i < 2; ++i) {
if (!dataViewCompare(testName, got[i], sent[i])) {
return false;
}
}
if (got[0].buffer !== got[1].buffer) {
testFailed(testName + ": expected the same ArrayBuffer for both views");
return false;
}
return true;
}
function dataViewCompare3(testName, got, sent) {
for (var i = 0; i < 3; i += 2) {
if (!dataViewCompare(testName, got[i], sent[i])) {
return false;
}
}
if (got[1].x !== sent[1].x || got[1].y !== sent[1].y) {
testFailed(testName + ": {x:1, y:1} was not transferred properly");
return false;
}
if (got[0].buffer !== got[2].buffer) {
testFailed(testName + ": expected the same ArrayBuffer for both views");
return false;
}
return false;
}
function createBuffer(length) {
var buffer = new ArrayBuffer(length);
var view = new Uint8Array(buffer);
for (var i = 0; i < length; ++i) {
view[i] = i + 1;
}
return buffer;
}
function createTypedArray(typedArrayType, length) {
var view = new typedArrayType(length);
for (var i = 0; i < length; ++i) {
view[i] = i + 1;
}
return view;
}
function createTypedArrayOverBuffer(typedArrayType, typedArrayElementSize, length, subStart, subLength) {
var buffer = new ArrayBuffer(length * typedArrayElementSize);
if (subStart === undefined) {
subStart = 0;
subLength = length;
}
return new typedArrayType(buffer, subStart * typedArrayElementSize, subLength);
}
var basicBufferTypes = [
["Int32", Int32Array, 4],
["Uint32", Uint32Array, 4],
["Int8", Int8Array, 1],
["Uint8", Uint8Array, 1],
["Uint8Clamped", Uint8ClampedArray, 1],
["Int16", Int16Array, 2],
["Uint16", Uint16Array, 2],
["Float32", Float32Array, 4],
["Float64", Float64Array, 8]
];
var arrayBuffer1 = createBuffer(1);
var testList = [
['ArrayBuffer0', new ArrayBuffer(0), bufferCompare],
['ArrayBuffer1', createBuffer(1), bufferCompare],
['ArrayBuffer128', createBuffer(128), bufferCompare],
['DataView0', new DataView(new ArrayBuffer(0)), dataViewCompare],
['DataView1', new DataView(createBuffer(1)), dataViewCompare],
['DataView1-dup', [new DataView(arrayBuffer1), new DataView(arrayBuffer1)], dataViewCompare2],
['DataView1-dup2', [new DataView(arrayBuffer1), {x:1, y:1}, new DataView(arrayBuffer1)], dataViewCompare3],
['DataView128', new DataView(createBuffer(128)), dataViewCompare],
['DataView1_offset_at_end', new DataView(createBuffer(1), 1, 0), dataViewCompare],
['DataView128_offset_at_end', new DataView(createBuffer(128), 128, 0), dataViewCompare],
['DataView128_offset_slice_length_0', new DataView(createBuffer(128), 64, 0), dataViewCompare],
['DataView128_offset_slice_length_1', new DataView(createBuffer(128), 64, 1), dataViewCompare],
['DataView128_offset_slice_length_16', new DataView(createBuffer(128), 64, 16), dataViewCompare],
['DataView128_offset_slice_unaligned', new DataView(createBuffer(128), 63, 15), dataViewCompare]
];
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_0", createTypedArray(t[1], 0), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_1", createTypedArray(t[1], 1), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128", createTypedArray(t[1], 128), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_0_buffer", createTypedArrayOverBuffer(t[1], t[2], 0), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_1_buffer", createTypedArrayOverBuffer(t[1], t[2], 1), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128_buffer", createTypedArrayOverBuffer(t[1], t[2], 128), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_1_buffer_offset_at_end", createTypedArrayOverBuffer(t[1], t[2], 1, 1, 0), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128_buffer_offset_at_end", createTypedArrayOverBuffer(t[1], t[2], 128, 128, 0), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128_buffer_offset_slice_length_0", createTypedArrayOverBuffer(t[1], t[2], 128, 64, 0), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128_buffer_offset_slice_length_1", createTypedArrayOverBuffer(t[1], t[2], 128, 64, 1), typedArrayCompare];}));
testList = testList.concat(basicBufferTypes.map(function(t)
{return [t[0] + "_128_buffer_offset_slice_length_16", createTypedArrayOverBuffer(t[1], t[2], 128, 64, 16), typedArrayCompare];}));
function doneTest() {
if (++window.testsComplete == testList.length) {
finishJSTest();
}
}
function windowHandleMessage(e) {
var currentTest = testList[e.data.testNum];
var expectedResult = currentTest[1];
try {
currentTest[2](currentTest[0], e.data.testData, expectedResult);
} catch(e) {
testFailed(currentTest[0] + ": unexpected exception " + e);
}
doneTest();
}
window.addEventListener('message', windowHandleMessage);
for (var t = 0; t < testList.length; ++t) {
var currentTest = testList[t];
var message = {testNum: t, testData: currentTest[1]};
try {
window.postMessage(message, '*');
} catch(e) {
testFailed(currentTest[0], ": unexpected postMessage exception " + e);
doneTest();
}
}
description("Test of texImage2d and texSubImage2d");
if (window.internals)
window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
var context = create3DContext();
var image = document.createElement("img");
var video = document.createElement("video");
var canvas2d = document.createElement("canvas");
var context2d = canvas2d.getContext("2d");
var imageData = context2d.createImageData(64, 64);
var array = new Uint8Array([ 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255 ]);
shouldThrow("context.texImage2D(context.TEXTURE_2D)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 64, 64, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
shouldThrow("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, context.RGBA, context.UNSIGNED_BYTE, 0)");
shouldThrow("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, context.RGBA, context.UNSIGNED_BYTE, 0, 0)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 2, 2, 0, context.RGBA, context.UNSIGNED_BYTE, array)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, true)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, imageData)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, image)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, canvas2d)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, true)");
shouldBeUndefined("context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, video)");
shouldThrow("context.texSubImage2D(context.TEXTURE_2D)");
shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
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)");
shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, context.RGBA, context.UNSIGNED_BYTE, image)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, true)");
shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, context.RGBA, context.UNSIGNED_BYTE, canvas2d)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false)");
shouldBeUndefined("context.pixelStorei(context.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true)");
shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, context.RGBA, context.UNSIGNED_BYTE, video)");
implicit/00_shaders.txt
misc/00_shaders.txt
reserved/00_shaders.txt
add_int_float.vert
add_int_mat2.vert
add_int_mat3.vert
add_int_mat4.vert
add_int_vec2.vert
add_int_vec3.vert
add_int_vec4.vert
add_ivec2_vec2.vert
add_ivec3_vec3.vert
add_ivec4_vec4.vert
assign_int_to_float.vert
assign_ivec2_to_vec2.vert
assign_ivec3_to_vec3.vert
assign_ivec4_to_vec4.vert
construct_struct.vert
divide_int_float.vert
divide_int_mat2.vert
divide_int_mat3.vert
divide_int_mat4.vert
divide_int_vec2.vert
divide_int_vec3.vert
divide_int_vec4.vert
divide_ivec2_vec2.vert
divide_ivec3_vec3.vert
divide_ivec4_vec4.vert
equal_int_float.vert
equal_ivec2_vec2.vert
equal_ivec3_vec3.vert
equal_ivec4_vec4.vert
function_int_float.vert
function_ivec2_vec2.vert
function_ivec3_vec3.vert
function_ivec4_vec4.vert
greater_than.vert
greater_than_equal.vert
less_than.vert
less_than_equal.vert
multiply_int_float.vert
multiply_int_mat2.vert
multiply_int_mat3.vert
multiply_int_mat4.vert
multiply_int_vec2.vert
multiply_int_vec3.vert
multiply_int_vec4.vert
multiply_ivec2_vec2.vert
multiply_ivec3_vec3.vert
multiply_ivec4_vec4.vert
not_equal_int_float.vert
not_equal_ivec2_vec2.vert
not_equal_ivec3_vec3.vert
not_equal_ivec4_vec4.vert
subtract_int_float.vert
subtract_int_mat2.vert
subtract_int_mat3.vert
subtract_int_mat4.vert
subtract_int_vec2.vert
subtract_int_vec3.vert
subtract_int_vec4.vert
subtract_ivec2_vec2.vert
subtract_ivec3_vec3.vert
subtract_ivec4_vec4.vert
ternary_int_float.vert
ternary_ivec2_vec2.vert
ternary_ivec3_vec3.vert
ternary_ivec4_vec4.vert
// implicit cast adding integer to float should fail
void main()
{
float f = 1.0 + 1;
}
// implicit cast adding integer to mat2 should fail
void main()
{
mat2 f = mat2(1.0) + 1;
}
// implicit cast adding integer to mat3 should fail
void main()
{
mat3 f = mat3(1.0) + 1;
}
// implicit cast adding integer to mat4 should fail
void main()
{
mat4 f = mat4(1.0) + 1;
}
// implicit cast adding integer to vec2 should fail
void main()
{
vec2 f = vec2(1.0, 2.0) + 1;
}
// implicit cast adding integer to vec3 should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) + 1;
}
// implicit cast adding integer to vec4 should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) + 1;
}
// implicit cast adding ivec2 to vec2 should fail
void main()
{
vec2 f = vec2(1.0, 2.0) + ivec2(1, 2);
}
// implicit cast adding ivec3 to vec3 should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) + ivec3(1, 2, 3);
}
// implicit cast adding ivec4 to vec4 should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) + ivec4(1, 2, 3, 4);
}
// implicit cast assing int to float should fail
void main()
{
float f = -123;
}
// implicit cast assigning ivec2 to vec2 should fail
void main()
{
vec2 f = ivec2(1, 2);
}
// implicit cast assigning ivec3 to vec3 should fail
void main()
{
vec3 f = ivec3(1, 2, 3);
}
// implicit cast assigning ivec4 to vec4 should fail
void main()
{
vec4 f = ivec4(1, 2, 3, 4);
}
// implicit cast from int to float in struct initializer should fail
struct Foo {
float bar;
};
void main() {
Foo foo = Foo(1);
}
// implicit cast of float divided by int should fail
void main()
{
float f = 1.0 / 1;
}
// implicit cast of mat2 divided by int should fail
void main()
{
mat2 f = mat2(1.0) / 1;
}
// implicit cast of mat3 divided by int should fail
void main()
{
mat3 f = mat3(1.0) / 1;
}
// implicit cast of mat4 divided by int should fail
void main()
{
mat4 f = mat4(1.0) / 1;
}
// implicit cast of vec2 divided by int should fail
void main()
{
vec2 f = vec2(1.0, 2.0) / 1;
}
// implicit cast of vec3 divided by int should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) / 1;
}
// implicit cast of vec4 divided by int should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) / 1;
}
// implicit cast of vec2 divided by ivec2 should fail
void main()
{
vec2 f = vec2(1.0, 2.0) / ivec2(1, 2);
}
// implicit cast of vec3 divided by ivec3 should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) / ivec3(1, 2, 3);
}
// implicit cast of vec4 divided by ivec4 should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) / ivec4(1, 2, 3, 4);
}
// implicit cast of int to float in comparison should fail
void main()
{
bool b = 1.0 == 1;
}
// implicit cast of ivec2 to vec2 in comparison should fail
void main()
{
bool b = vec2(1.0, 2.0) == ivec2(1, 2);
}
// implicit cast of ivec3 to vec3 in comparison should fail
void main()
{
bool b = vec3(1.0, 2.0, 3.0) == ivec3(1, 2, 3);
}
// implicit cast of ivec4 to vec4 in comparison should fail
void main()
{
bool b = vec4(1.0, 2.0, 3.0, 4.0) == ivec4(1, 2, 3, 4);
}
// implicit cast of int to float in function argument should fail
float foo(float f) {
return f;
}
void main() {
float f = foo(1);
}
// implicit cast of ivec2 to vec2 in function argument should fail
vec2 foo(vec2 f) {
return f;
}
void main() {
vec2 f = foo(ivec2(1, 2));
}
// implicit cast of ivec3 to vec3 in function argument should fail
vec3 foo(vec3 f) {
return f;
}
void main() {
vec3 f = foo(ivec3(1, 2, 3));
}
// implicit cast of ivec4 to vec4 in function argument should fail
vec4 foo(vec4 f) {
return f;
}
void main() {
vec4 f = foo(ivec4(1, 2, 3, 4));
}
// implicit cast of int to float with greater than should fail
void main()
{
bool b = 1.0 > 1;
}
// implicit cast of int to float with greater than or equal to should fail
void main()
{
bool b = 1.0 >= 1;
}
// implicit cast of int to float with less than should fail
void main()
{
bool b = 1.0 < 1;
}
// implicit cast of int to float with less than or equal to should fail
void main()
{
bool b = 1.0 <= 1;
}
// implicit cast of int to float in multiply should fail
void main()
{
float f = 1.0 * 1;
}
// implicit cast of int to mat2 in multiply should fail
void main()
{
mat2 f = mat2(1.0) * 1;
}
// implicit cast of int to mat3 in multiply should fail
void main()
{
mat3 f = mat3(1.0) * 1;
}
// implicit cast of int to mat4 in multiply should fail
void main()
{
mat4 f = mat4(1.0) * 1;
}
// implicit cast of int to vec2 in multiply should fail
void main()
{
vec2 f = vec2(1.0, 2.0) * 1;
}
// implicit cast of int to vec3 in multiply should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) * 1;
}
// implicit cast of int to vec4 in multiply should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) * 1;
}
// implicit cast of ivec2 to vec2 in multiply should fail
void main()
{
vec2 f = vec2(1.0, 2.0) * ivec2(1, 2);
}
// implicit cast of ivec3 to vec3 in multiply should fail
void main()
{
vec3 f = vec3(1.0, 2.0, 3.0) * ivec3(1, 2, 3);
}
// implicit cast of ivec4 to vec4 in multiply should fail
void main()
{
vec4 f = vec4(1.0, 2.0, 3.0, 4.0) * ivec4(1, 2, 3, 4);
}
// implicit cast of int to float in not equal comparison should fail
void main()
{
bool b = 1.0 != 1;
}
// implicit cast of ivec2 to vec2 in not equal comparison should fail
void main()
{
bool b = vec2(1.0, 2.0) != ivec2(1, 2);
}
// implicit cast of ivec3 to vec3 in not equal comparison should fail
void main()
{
bool b = vec3(1.0, 2.0, 3.0) != ivec3(1, 2, 3);
}
// implicit cast of ivec4 to vec4 in not equal comparison should fail
void main()
{
bool b = vec4(1.0, 2.0, 3.0, 4.0) != ivec4(1, 2, 3, 4);
}
// implicit cast of int to float in subtraction should fail
void main()
{
float f = 1.0 - 1;
}
// implicit cast of int to mat2 in subtraction should fail
void main()
{
mat2 f = mat2(1.0) - 1;
}
// implicit cast of int to mat3 in subtraction should fail
void main()
{
mat3 f = mat3(1.0) - 1;
}
// implicit cast of int to mat4 in subtraction should fail
void main()
{
mat4 f = mat4(1.0) - 1;
}
// implicit cast of int to vec2 in subtraction should fail
void main()
{
vec2 f = vec2(1.0, 2.0) - 1;
}
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