Bug 997973: Call typed array and arraybuffer constructors with new in the tree; r=bz
authorBenjamin Bouvier <benj@benj.me>
Fri, 24 Oct 2014 11:26:20 +0200
changeset 212099 b05a7ee5188ad58379d924f935b7b653d9560354
parent 212098 420b72a2e9336b01128cf3f89d267406dfd60354
child 212100 5e7b73241e0353350892c15d0075100842bd7ea4
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs997973
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 997973: Call typed array and arraybuffer constructors with new in the tree; r=bz
browser/devtools/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
content/base/test/file_bug1008126_worker.js
content/base/test/file_bug945152_worker.js
content/media/test/test_encryptedMediaExtensions.html
dom/apps/tests/file_bug_945152.html
dom/devicestorage/test/test_fs_createFile.html
xpcom/tests/unit/test_streams.js
--- a/browser/devtools/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
+++ b/browser/devtools/webconsole/test/browser_console_variables_view_dont_sort_non_sortable_classes_properties.js
@@ -52,26 +52,26 @@ function test() {
                              "Float64Array"];
 
     const {tab} = yield loadTab(TEST_URI);
     const hud = yield openConsole(tab);
     jsterm = hud.jsterm;
 
     // 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)");
     // NodeList
     yield testNotSorted("document.querySelectorAll('div')");
 
     // Typed arrays.
     for (let type of typedArrayTypes) {
-      yield testNotSorted(type + "(buf)");
+      yield testNotSorted("new " + type + "(buf)");
     }
   }
 
   /**
    * A helper that ensures the properties are not sorted when an object
    * specified by aObject is inspected.
    *
    * @param string aObject
--- a/content/base/test/file_bug1008126_worker.js
+++ b/content/base/test/file_bug1008126_worker.js
@@ -26,17 +26,17 @@ function is(a, b, msg) {
 function checkData(xhr, data, mapped, cb) {
   var ct = xhr.getResponseHeader("Content-Type");
   if (mapped) {
     ok(ct.indexOf("mem-mapped") != -1, "Data is memory-mapped");
   } else {
     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();
 }
 
 self.onmessage = function onmessage(event) {
 
   var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
 
--- a/content/base/test/file_bug945152_worker.js
+++ b/content/base/test/file_bug945152_worker.js
@@ -13,17 +13,17 @@ function ok(a, msg) {
 }
 
 function is(a, b, msg) {
   postMessage({type: 'status', status: a === b, msg: 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");
   cb();
 }
 
 self.onmessage = function onmessage(event) {
 
--- a/content/media/test/test_encryptedMediaExtensions.html
+++ b/content/media/test/test_encryptedMediaExtensions.html
@@ -22,27 +22,27 @@ function bail(message)
     }
     SimpleTest.finish();
   }
 }
 
 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]);
   }
   return str;
 }
 
 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);
   }
   return arr;
 }
 
 function Base64ToHex(str)
 {
--- a/dom/apps/tests/file_bug_945152.html
+++ b/dom/apps/tests/file_bug_945152.html
@@ -42,17 +42,17 @@
         var ct = xhr.getResponseHeader("Content-Type");
         if (mapped) {
           ok(ct.indexOf("mem-mapped") != -1, "Data is memory-mapped");
         } else {
           ok(ct.indexOf("mem-mapped") == -1, "Data is not memory-mapped");
         }
         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");
         cb();
       } else {
         ok(false, "XHR error: " + xhr.status + " - " + xhr.statusText + "\n");
         cb();
       }
--- a/dom/devicestorage/test/test_fs_createFile.html
+++ b/dom/devicestorage/test/test_fs_createFile.html
@@ -56,17 +56,17 @@ let gTestCases = [
     get data() { return str2array(this.text); },
     shouldPass: true,
     mode: "replace"
   },
 
   // 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"
   },
 
   // Create with blob data.
   {
     text: "Kunming is in Yunnan province of China.",
     get data() { return new Blob([this.text], {type: 'image/png'}); },
--- a/xpcom/tests/unit/test_streams.js
+++ b/xpcom/tests/unit/test_streams.js
@@ -27,17 +27,17 @@ function test_binary_streams() {
   os = new BinaryOutput(p.outputStream);
 
   const LargeNum = Math.pow(2, 18) + Math.pow(2, 12) + 1;
   const HugeNum = Math.pow(2, 62);
   const HelloStr = "Hello World";
   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);
   do_check_eq(is.readBoolean(), true);
   os.write8(4);
   do_check_eq(is.read8(), 4);
   os.write16(4);
   do_check_eq(is.read16(), 4);
@@ -70,17 +70,17 @@ function test_binary_streams() {
   os.writeByteArray(HelloArray, HelloArray.length);
   do_check_eq(is.available(), HelloStr.length);
   msg = is.readByteArray(HelloStr.length)
   do_check_eq(typeof msg, typeof HelloArray);
   do_check_eq(msg.toSource(), HelloArray.toSource());
   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.
   os.writeBoolean(true);
   os.write8(4);
   os.write16(4);
   os.write16(1024);
   os.write32(7);