diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/typedarrays | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/typedarrays')
8 files changed, 325 insertions, 0 deletions
diff --git a/testing/web-platform/tests/typedarrays/ArrayBuffer_constructor.html b/testing/web-platform/tests/typedarrays/ArrayBuffer_constructor.html new file mode 100644 index 000000000..7a94bc683 --- /dev/null +++ b/testing/web-platform/tests/typedarrays/ArrayBuffer_constructor.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: ArrayBuffer constructor</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.khronos.org/registry/typedarray/specs/latest/#5"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +var args = [ + /* numbers */ + [NaN, 0], [+Infinity, 0], [-Infinity, 0], [+0, 0], [-0, 0], + [-0.4, 0], [-0.9, 0], [1.1, 1], [2.9, 2], + [1, 1], [-0xF1000000, 0], + /* strings */ + ["1", 1], ["1e2", 100], + /* null, undefined, booleans */ + [undefined, 0], [null, 0], [false, 0], [true, 1] +]; + +args.forEach(function (arg, i) { + test(function () { + var abuffer = new ArrayBuffer(arg[0]); + assert_equals(abuffer.byteLength, arg[1]); + }, "The argument " + format_value(arg[0]) + " should be interpreted as " + + arg[1] + " for ArrayBuffer constructor." + i); +}); + +</script> diff --git a/testing/web-platform/tests/typedarrays/ArrayBuffer_properties.html b/testing/web-platform/tests/typedarrays/ArrayBuffer_properties.html new file mode 100644 index 000000000..a4472980a --- /dev/null +++ b/testing/web-platform/tests/typedarrays/ArrayBuffer_properties.html @@ -0,0 +1,67 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: ArrayBuffer properties</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.khronos.org/registry/typedarray/specs/latest/#5"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +test(function () { + var intLen = 8; + var abuffer = new ArrayBuffer(intLen); + + //byteLength + test(function () { + var len = abuffer.byteLength; + abuffer.byteLength = len + 1; + assert_equals(len, intLen, "the byteLength of ArrayBuffer"); + assert_equals(abuffer.byteLength, len, "the byteLength of ArrayBuffer"); + }, "Check if the byteLength is fixed at construction time and readonly"); + + //slice() + test(function () { + var b = abuffer.slice(2); + assert_true(b instanceof ArrayBuffer, "Returns a new ArrayBuffer"); + assert_equals(b.byteLength, intLen-2, "The byteLength of ArrayBuffer"); + }, "Check if the new ArrayBuffer contains all bytes from begin to the end of this ArrayBuffer when the end is unspecified"); + + test(function () { + var b = abuffer.slice(2, 6); + assert_true(b instanceof ArrayBuffer, "Returns a new ArrayBuffer"); + assert_equals(b.byteLength, 4, "The byteLength of ArrayBuffer"); + }, "Check if the new ArrayBuffer contains the bytes from begin to the end of this ArrayBuffer when the end is specified"); + + test(function () { + b = abuffer.slice(2, 10); + assert_equals(b.byteLength, 6, "The byteLength of ArrayBuffer"); + }, "Check if the slice range specified by the begin and end values is clamped to the valid index range for the current array"); + + test(function () { + var b = abuffer.slice(2, -1); + assert_equals(b.byteLength, 5, "The byteLength of ArrayBuffer"); + b = abuffer.slice(-2, -1); + assert_equals(b.byteLength, 1, "The byteLength of ArrayBuffer"); + }, "Check if it refers to an index from the end of the array when either begin or end is negative"); + + test(function () { + var b = abuffer.slice(4, 2); + assert_equals(b.byteLength, 0, "The byteLength of ArrayBuffer"); + b = abuffer.slice(-1, -2); + assert_equals(b.byteLength, 0, "The byteLength of ArrayBuffer"); + }, "Check if the length is clamped to zero when the computed length of the new ArrayBuffer is negative"); + + //static isView() + test(function () { + var int8a = new Int8Array(8); + assert_true(ArrayBuffer.isView(int8a), "The return value of ArrayBufferView.isView"); + }, "Check if the isView returns true when the value is an object implementing the ArrayBufferView interface"); + + test(function () { + var arr = new Array(8); + assert_false(ArrayBuffer.isView(arr), "The return value of ArrayBufferView.isView"); + }, "Check if the isView returns false when the value is an object not implementing the ArrayBufferView interface"); +}); + +</script> diff --git a/testing/web-platform/tests/typedarrays/OWNERS b/testing/web-platform/tests/typedarrays/OWNERS new file mode 100644 index 000000000..f02987223 --- /dev/null +++ b/testing/web-platform/tests/typedarrays/OWNERS @@ -0,0 +1,4 @@ +@koustuvsinha +@zqzhang +@haoxli +@Ms2ger diff --git a/testing/web-platform/tests/typedarrays/Uint8ClampedArray_constructor.html b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_constructor.html new file mode 100644 index 000000000..056952a4f --- /dev/null +++ b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_constructor.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: Uint8ClampedArray constructor</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="http://www.khronos.org/registry/typedarray/specs/latest/#7.1"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +test(function() { + var obj = new Uint8ClampedArray(new Uint8ClampedArray(8)); + assert_true(obj instanceof Uint8ClampedArray, "The constructor return Uint8ClampedArray"); + assert_equals(obj.length, 8, "The length of Uint8ClampedArray"); +}, "Check if the constructor(Uint8ClampedArray) create new Uint8ClampedArray"); + +test(function() { + var obj = new Uint8ClampedArray(new ArrayBuffer(8)); + assert_true(obj instanceof Uint8ClampedArray, "The constructor return Uint8ClampedArray"); + assert_equals(obj.length, 8, "The length of Uint8ClampedArray"); +}, "Check if the constructor(ArrayBuffer) create new Uint8ClampedArray"); + +test(function() { + var obj = new Uint8ClampedArray(new ArrayBuffer(8), 2); + assert_true(obj instanceof Uint8ClampedArray, "The constructor return object Uint8ClampedArray"); + assert_equals(obj.length, 6, "The length of Uint8ClampedArray"); +}, "Check if the constructor(ArrayBuffer, byteOffset) create new Uint8ClampedArray"); + +test(function() { + var obj = new Uint8ClampedArray(new ArrayBuffer(8), 2, 4); + assert_true(obj instanceof Uint8ClampedArray, "The constructor return object Uint8ClampedArray"); + assert_equals(obj.length, 4, "The length of Uint8ClampedArray"); +}, "Check if the constructor(ArrayBuffer, byteOffset, length) create new Uint8ClampedArray"); + +</script> diff --git a/testing/web-platform/tests/typedarrays/Uint8ClampedArray_length.html b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_length.html new file mode 100644 index 000000000..6551cd780 --- /dev/null +++ b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_length.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: Uint8ClampedArray length</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="http://www.khronos.org/registry/typedarray/specs/latest/#7.1"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +test(function() { + var arr = new Uint8ClampedArray(8); + + test(function() { + assert_equals(arr.length, 8, "The Uint8ClampedArray.length"); + }, "Check if the Uint8ClampedArray.length should be the value given by constructor"); + + test(function() { + var len = arr.length; + arr.length = len + 1; + assert_equals(arr.length, len, "The Uint8ClampedArray.length"); + }, "Check if the Uint8ClampedArray.length is readonly"); +}); + +</script> diff --git a/testing/web-platform/tests/typedarrays/Uint8ClampedArray_setter_getter.html b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_setter_getter.html new file mode 100644 index 000000000..28c8ecacb --- /dev/null +++ b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_setter_getter.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: Uint8ClampedArray setter and getter</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="http://www.khronos.org/registry/typedarray/specs/latest/#7.1"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +var testData = [ + [1, 1], [257, 255], [3.2, 3], [-3.8, 0], [+0, 0], [-0, 0], + ["1", 1], [false, 0], [true, 1], [undefined, 0], [null, 0], + [NaN, 0], [+Infinity, 255], [-Infinity, 0] +]; + +testData.forEach(function (arg) { + test(function() { + var obj = new Uint8ClampedArray(8); + //set [Clamp] octet value + obj[0] = arg[0]; + assert_equals(obj[0], arg[1], "The value of Uint8ClampedArray"); + }, "Check if the getter can get " + arg[1] + " after set " + format_value(arg[0]) + " by the setter"); +}); + +test(function() { + var obj = new Uint8ClampedArray(8); + var arg = [1, 2, 3]; + //set octet[] + obj.set(arg); + assert_equals(obj[1], arg[1], "The value of Uint8ClampedArray"); +}, "Check if the parameter of Uint8ClampedArray.set() accept octet[]"); + +test(function() { + var obj = new Uint8ClampedArray(8); + var arg = [1, 2, 3]; + //set octet[] with offset + obj.set(arg, 1); + assert_equals(obj[1], arg[0], "The value of Uint8ClampedArray"); +}, "Check if the parameter of Uint8ClampedArray.set() accept octet[] and offset"); + +test(function() { + var obj = new Uint8ClampedArray(8); + var arg = new Uint8ClampedArray([1, 2, 3]); + //set Uint8ClampedArray + obj.set(arg); + assert_equals(obj[1], arg[1], "The value of Uint8ClampedArray"); +}, "Check if the parameter of Uint8ClampedArray.set() accept Uint8ClampedArray"); + +test(function() { + var obj = new Uint8ClampedArray(8); + var arg = new Uint8ClampedArray([1, 2, 3]); + //set Uint8ClampedArray with offset + obj.set(arg, 1); + assert_equals(obj[1], arg[0], "The value of Uint8ClampedArray"); +}, "Check if the parameter of Uint8ClampedArray.set() accept Uint8ClampedArray and offset"); + +test(function() { + var obj = new Uint8ClampedArray(3); + var arg = new Uint8ClampedArray([1, 2, 3]); + assert_throws(new RangeError(), function() { + obj.set(arg, 1); + }); +}, "Check if an exception is raised when the offset plus the length of the given array is out of range for the current array"); + +</script> diff --git a/testing/web-platform/tests/typedarrays/Uint8ClampedArray_subarray.html b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_subarray.html new file mode 100644 index 000000000..3c72d853d --- /dev/null +++ b/testing/web-platform/tests/typedarrays/Uint8ClampedArray_subarray.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Typed Arrays Test: Uint8ClampedArray subarray</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="http://www.khronos.org/registry/typedarray/specs/latest/#7.1"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +test(function() { + var arr = new Uint8ClampedArray([1, 2, 3, 4, 5, 6, 7, 8]); + + test(function() { + var subarr = arr.subarray(2); + assert_true(subarr instanceof Uint8ClampedArray, "Returns Uint8ClampedArray"); + assert_equals(subarr.length, 6, "The length of subarray"); + assert_equals(subarr[0], arr[2], "The value of subarray"); + }, "Check if a new Uint8ClampedArray is returned for the Uint8ClampedArray, referencing the elements at begin"); + + test(function() { + var subarr = arr.subarray(2, 6); + assert_equals(subarr.length, 4, "The length of subarray"); + assert_equals(subarr[0], arr[2], "The value of subarray"); + assert_equals(subarr[3], arr[5], "The value of subarray"); + }, "Check if a new Uint8ClampedArray is returned for the Uint8ClampedArray, referencing the elements at begin to end"); + + test(function() { + var subarr = arr.subarray(2, 10); + assert_equals(subarr.length, 6, "The length of subarray"); + assert_equals(subarr[0], arr[2], "The value of subarray"); + assert_equals(subarr[5], arr[7], "The value of subarray"); + }, "Check if the subarray range specified by the begin and end values is clamped to the valid index range for the current array"); + + test(function() { + var subarr = arr.subarray(2, -2); + assert_equals(subarr.length, 4, "The length of subarray"); + subarr = arr.subarray(-2, -1); + assert_equals(subarr.length, 1, "The length of subarray"); + }, "Check if it refers to an index from the end of the array when either begin or end is negative"); + + test(function() { + var subarr = arr.subarray(4, 2); + assert_equals(subarr.length, 0, "The length of subarray"); + subarr = arr.subarray(-1, -2); + assert_equals(subarr.length, 0, "The length of subarray"); + }, "Check if the length is clamped to zero when the computed length of the new Uint8ClampedArray is negative"); +}); + +</script> diff --git a/testing/web-platform/tests/typedarrays/constructors.html b/testing/web-platform/tests/typedarrays/constructors.html new file mode 100644 index 000000000..a5d0604e9 --- /dev/null +++ b/testing/web-platform/tests/typedarrays/constructors.html @@ -0,0 +1,48 @@ +<!doctype html> +<title>Typed Array constructors</title> +<link rel=author href=mailto:Ms2ger@gmail.com title=Ms2ger> +<link rel=help href=https://www.khronos.org/registry/typedarray/specs/latest/#7> +<link rel=help href=http://dev.w3.org/2006/webapi/WebIDL/#dfn-overload-resolution-algorithm> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> + +<div id=log></div> +<script> +var args = [ + /* numbers */ + [NaN, 0], [+Infinity, 0], [-Infinity, 0], [+0, 0], [-0, 0], // Step 2 + [-0.4, 0], [-0.9, 0], [1.1, 1], [2.9, 2], // Step 3 + [1, 1], [-0xF1000000, 0], // Step 4 + /* strings */ + ["1", 1], ["1e2", 100], + /* null, undefined, booleans */ + [undefined, 0], [null, 0], [false, 0], [true, 1], + /* objects */ + [{}, 0], [{ length: 2, 0: 0, 1: 0 }, 0], [[0, 0], 2] +]; +var interfaces = [ + "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", + "Int32Array", "Uint32Array", "Float32Array", "Float64Array" +]; + +test(function() { + interfaces.concat(["ArrayBuffer", "DataView"]).forEach(function(i) { + test(function() { + // XXX The spec is wrong here. + assert_throws(new TypeError(), function() { + new window[i](); + }); + }, "Constructing interface " + i + " with no arguments should throw."); + }); + interfaces.forEach(function(i) { + args.forEach(function(arg, j) { + var input = arg[0], expected = arg[1]; + test(function() { + var ta = new window[i](input); + assert_equals(ta.length, expected); + }, "The argument " + format_value(input) + " (" + j + ") should be interpreted as " + + expected + " for interface " + i + "."); + }); + }); +}); +</script> |