summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/TypedObject/map-neutered-midway.js
blob: 2e3892d7ad7e157a7e05aad7f7e4544a2febb0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// |reftest| skip-if(!this.hasOwnProperty("TypedObject")||!xulRuntime.shell) -- needs TypedObject, detachArrayBuffer()
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

var BUGNUMBER = 991981;
var summary =
  "Behavior of mapping from an array whose buffer is detached midway through " +
  "mapping";

function mapOneDimArrayOfUint8()
{
  var FourByteArray = TypedObject.uint8.array(4);
  var FourByteArrayArray = FourByteArray.array(4);

  var buf = new ArrayBuffer(16);
  var arr = new FourByteArrayArray(buf);

  var count = 0;
  assertThrowsInstanceOf(function()
  {
    arr.map(function(v)
    {
      if (count++ > 0)
        detachArrayBuffer(buf);
      return new FourByteArray();
    });
  }, TypeError, "mapping of a detached object worked?");
}

function runTests()
{
  print(BUGNUMBER + ": " + summary);

  mapOneDimArrayOfUint8();

  if (typeof reportCompare === "function")
    reportCompare(true, true);
  print("Tests complete");
}

runTests();