Bug 1232966 - Adapt Xrays tests for SharedArrayBuffer.prototype.slice. r=bz
authorLars T Hansen <lhansen@mozilla.com>
Tue, 01 Nov 2016 10:00:34 +0100
changeset 351424 00c0fdd359040cf9c5515522a620f06ea26cc6ba
parent 351423 55398c6f895777f83bdec5cc4bbef3af9f958930
child 351425 f7fe9d1a41f3ae291e4926de88559411ea0f0cd1
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1232966
milestone52.0a1
Bug 1232966 - Adapt Xrays tests for SharedArrayBuffer.prototype.slice. r=bz
js/xpconnect/tests/chrome/test_xrayToJS.xul
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -253,17 +253,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     constructorProps(["resolve", "reject", "all", "race", Symbol.species]);
 
   gPrototypeProperties['ArrayBuffer'] =
     ["constructor", "byteLength", "slice", Symbol.toStringTag];
   gConstructorProperties['ArrayBuffer'] =
     constructorProps(["isView", "slice", Symbol.species]);
 
   if (!isReleaseOrBeta) {
-    gPrototypeProperties['SharedArrayBuffer'] = ["constructor", "byteLength", Symbol.toStringTag];
+    gPrototypeProperties['SharedArrayBuffer'] = ["constructor", "slice", "byteLength", Symbol.toStringTag];
     gConstructorProperties['SharedArrayBuffer'] = constructorProps([Symbol.species]);
   } else {
     is(typeof SharedArrayBuffer, "undefined", "Enable tests!");
   }
 
   // Sort an array that may contain symbols as well as strings.
   function sortProperties(arr) {
     function sortKey(prop) {
@@ -899,30 +899,30 @@ for (var prop of props) {
     is(Cu.getGlobalForObject(pr.wrappedJSObject.then), iwin, "Underlying global is correct");
   }
 
   function testArrayBuffer() {
     let constructors = ['ArrayBuffer'];
 
     if (!isReleaseOrBeta) {
       constructors.push('SharedArrayBuffer');
-      // If this fails enable the test a bit below.
-      is(typeof SharedArrayBuffer.prototype.slice, "undefined", "SharedArrayBuffer doesn't have slice");
     }
 
     for (const c of constructors) {
       testXray(c, new iwin[c](0), new iwin[c](12));
 
       var t = new iwin[c](12);
       is(t.byteLength, 12, `${c} byteLength is correct`);
 
+      is(t.slice(4).byteLength, 8, `${c} byteLength is correct after slicing`);
+      is(Cu.getGlobalForObject(t.slice(4)), iwin, "Slice results lives in the target compartment");
+      is(Object.getPrototypeOf(t.slice(4)), iwin[c].prototype, "Slice results proto lives in target compartment")
+
+      // SharedArrayBuffer does not have static slice method
       if (c === 'ArrayBuffer') {
-        is(t.slice(4).byteLength, 8, `${c} byteLength is correct after slicing`);
-        is(Cu.getGlobalForObject(t.slice(4)), iwin, "Slice results lives in the target compartment");
-        is(Object.getPrototypeOf(t.slice(4)), iwin[c].prototype, "Slice results proto lives in target compartment")
         is(ArrayBuffer.slice(t, 4).byteLength, 8, `${c}.slice (deprecated) works`);
       }
 
       var i32Array = new Int32Array(t);
       // i32Array is going to be created in the buffer's target compartment,
       // but usually this is unobservable, because the proto is set to
       // the current compartment's prototype.
       // However Xrays ignore the object's proto and claim its proto is