regress-4964.js 653 Bytes
Newer Older
1 2 3 4 5 6
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

7
// Detached source
8
var ab = new ArrayBuffer(10);
9
ab.constructor = { get [Symbol.species]() { %ArrayBufferDetach(ab); return ArrayBuffer; } };
10 11
assertThrows(() => ab.slice(0), TypeError);

12 13
// Detached target
class DetachedArrayBuffer extends ArrayBuffer {
14 15
  constructor(...args) {
    super(...args);
16
    %ArrayBufferDetach(this);
17 18 19 20
  }
}

var ab2 = new ArrayBuffer(10);
21
ab2.constructor = DetachedArrayBuffer;
22
assertThrows(() => ab2.slice(0), TypeError);