зеркало из https://github.com/mozilla/gecko-dev.git
Bug 997973: Call typed array and arraybuffer constructors with new in the tree; r=bz
This commit is contained in:
Родитель
9a9595fa64
Коммит
a68d2993a2
|
@ -57,7 +57,7 @@ function test() {
|
|||
|
||||
// Create an ArrayBuffer of 80 bytes to test TypedArrays. 80 bytes is
|
||||
// enough to get 10 items in all different TypedArrays.
|
||||
jsterm.execute("let buf = ArrayBuffer(80);");
|
||||
jsterm.execute("let buf = new ArrayBuffer(80);");
|
||||
|
||||
// Array
|
||||
yield testNotSorted("Array(0,1,2,3,4,5,6,7,8,9,10)");
|
||||
|
@ -66,7 +66,7 @@ function test() {
|
|||
|
||||
// Typed arrays.
|
||||
for (let type of typedArrayTypes) {
|
||||
yield testNotSorted(type + "(buf)");
|
||||
yield testNotSorted("new " + type + "(buf)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ function checkData(xhr, data, mapped, cb) {
|
|||
ok(ct.indexOf("mem-mapped") == -1, "Data is not memory-mapped");
|
||||
}
|
||||
ok(xhr.response, "Data is non-null");
|
||||
var str = String.fromCharCode.apply(null, Uint8Array(xhr.response));
|
||||
var str = String.fromCharCode.apply(null, new Uint8Array(xhr.response));
|
||||
ok(str == data, "Data is correct");
|
||||
cb();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ function is(a, b, msg) {
|
|||
|
||||
function checkData(response, data_head, cb) {
|
||||
ok(response, "Data is non-null");
|
||||
var str = String.fromCharCode.apply(null, Uint8Array(response));
|
||||
var str = String.fromCharCode.apply(null, new Uint8Array(response));
|
||||
ok(str.length == data_head.length + gPaddingSize, "Data size is correct");
|
||||
ok(str.slice(0, data_head.length) == data_head, "Data head is correct");
|
||||
ok(str.slice(data_head.length) == gPadding, "Data padding is correct");
|
||||
|
|
|
@ -27,7 +27,7 @@ function bail(message)
|
|||
function ArrayBufferToString(arr)
|
||||
{
|
||||
var str = '';
|
||||
var view = Uint8Array(arr);
|
||||
var view = new Uint8Array(arr);
|
||||
for (var i = 0; i < view.length; i++) {
|
||||
str += String.fromCharCode(view[i]);
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ function ArrayBufferToString(arr)
|
|||
|
||||
function StringToArrayBuffer(str)
|
||||
{
|
||||
var arr = ArrayBuffer(str.length);
|
||||
var view = Uint8Array(arr);
|
||||
var arr = new ArrayBuffer(str.length);
|
||||
var view = new Uint8Array(arr);
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
view[i] = str.charCodeAt(i);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
}
|
||||
var data = xhr.response;
|
||||
ok(data, "Data is non-null");
|
||||
var str = String.fromCharCode.apply(null, Uint8Array(data));
|
||||
var str = String.fromCharCode.apply(null, new Uint8Array(data));
|
||||
is(str.length, data_head.length + gPaddingSize, "Data size is correct");
|
||||
is(str.slice(0, data_head.length), data_head, "Data head is correct");
|
||||
ok(str.slice(data_head.length) == gPadding, "Data padding is correct");
|
||||
|
|
|
@ -61,7 +61,7 @@ let gTestCases = [
|
|||
// Create with array buffer view data.
|
||||
{
|
||||
text: "Kunming is in Yunnan province of China.",
|
||||
get data() { return Uint8Array(str2array(this.text)); },
|
||||
get data() { return new Uint8Array(str2array(this.text)); },
|
||||
shouldPass: true,
|
||||
mode: "replace"
|
||||
},
|
||||
|
|
|
@ -32,7 +32,7 @@ function test_binary_streams() {
|
|||
const HelloArray = Array.map(HelloStr, function(c) {return c.charCodeAt(0)});
|
||||
var countObj = {};
|
||||
var msg = {};
|
||||
var buffer = ArrayBuffer(HelloArray.length);
|
||||
var buffer = new ArrayBuffer(HelloArray.length);
|
||||
|
||||
// Test reading immediately after writing.
|
||||
os.writeBoolean(true);
|
||||
|
@ -75,7 +75,7 @@ function test_binary_streams() {
|
|||
do_check_eq(is.available(), 0);
|
||||
os.writeByteArray(HelloArray, HelloArray.length);
|
||||
do_check_eq(is.readArrayBuffer(buffer.byteLength, buffer), HelloArray.length);
|
||||
do_check_eq([b for (b of Uint8Array(buffer))].toSource(), HelloArray.toSource());
|
||||
do_check_eq([b for (b of new Uint8Array(buffer))].toSource(), HelloArray.toSource());
|
||||
do_check_eq(is.available(), 0);
|
||||
|
||||
// Test writing in one big chunk.
|
||||
|
|
Загрузка…
Ссылка в новой задаче