Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test verifying that the OrdinaryCreateFromConstructor call in the DataView constructor is checked for underlying-buffer detachedness before its result is used #1504

Merged
merged 1 commit into from
Apr 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/built-ins/DataView/custom-proto-access-detaches-buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2018 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Jeff Walden <[email protected]>
esid: sec-dataview-buffer-byteoffset-bytelength
description: >
The `DataView` constructor shouldn't be able to return a `DataView` instance
backed by a detached `ArrayBuffer` when `OrdinaryCreateFromConstructor`
returns an instance so backed.
info: |
`OrdinaryCreateFromConstructor` has the potential to invoke user-defined code
that may detach the `ArrayBuffer` intended to underlie the fresh instance.
Verify that a final is-detached check is performed before the new instance is
returned.
features: [Reflect.construct]
---*/

var buffer = new ArrayBuffer(8);

var called = false;
var byteOffset = { valueOf() { called = true; return 0; } };

var newTarget = function() {}.bind(null);
Object.defineProperty(newTarget, "prototype", {
get() {
$262.detachArrayBuffer(buffer);
return DataView.prototype;
}
});

assert.throws(TypeError, function() {
Reflect.construct(DataView, [buffer, byteOffset], newTarget);
});
assert.sameValue(called, true);