2016-04-28 22:49:44 +00:00
|
|
|
// 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
|
|
|
|
|
2018-12-11 10:22:02 +00:00
|
|
|
// Detached source
|
2016-04-28 22:49:44 +00:00
|
|
|
var ab = new ArrayBuffer(10);
|
2018-12-11 10:22:02 +00:00
|
|
|
ab.constructor = { get [Symbol.species]() { %ArrayBufferDetach(ab); return ArrayBuffer; } };
|
2016-04-28 22:49:44 +00:00
|
|
|
assertThrows(() => ab.slice(0), TypeError);
|
|
|
|
|
2018-12-11 10:22:02 +00:00
|
|
|
// Detached target
|
|
|
|
class DetachedArrayBuffer extends ArrayBuffer {
|
2016-04-28 22:49:44 +00:00
|
|
|
constructor(...args) {
|
|
|
|
super(...args);
|
2018-12-11 10:22:02 +00:00
|
|
|
%ArrayBufferDetach(this);
|
2016-04-28 22:49:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var ab2 = new ArrayBuffer(10);
|
2018-12-11 10:22:02 +00:00
|
|
|
ab2.constructor = DetachedArrayBuffer;
|
2016-04-28 22:49:44 +00:00
|
|
|
assertThrows(() => ab2.slice(0), TypeError);
|