-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharedArrayBuffer-maxByteLength.PoC.js
More file actions
58 lines (49 loc) · 1.37 KB
/
SharedArrayBuffer-maxByteLength.PoC.js
File metadata and controls
58 lines (49 loc) · 1.37 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: BlueOak-1.0.0
import { scoring } from "./score.js";
const length = 8;
const maxByteLength = 7;
export const about = {
function: "new SharedArrayBuffer()",
link: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer",
properties: ["'maxByteLength'"],
description: `
When an SharedSharedSharedArrayBuffer is constructed it optionally accepts a maximum length
(in bytes). If not explicitly set on the 'options' object, it may read from the
prototype chain.`,
spectrace: [
"https://tc39.es/ecma262/#sec-sharedSharedSharedArrayBuffer-length",
"https://tc39.es/ecma262/#sec-getSharedSharedArrayBuffermaxbytelengthoption",
],
test262: new Set([
"test/built-ins/SharedArrayBuffer/options-maxbytelength-undefined.js",
]),
};
export function prerequisite() {
if (length <= maxByteLength) {
return [false, `${maxByteLength} < ${length} must hold`];
}
try {
new SharedArrayBuffer(length);
new SharedArrayBuffer(length, {});
return [true, null];
} catch (error) {
return [false, error.toString()];
}
}
export function test() {
Object.prototype.maxByteLength = maxByteLength;
try {
new SharedArrayBuffer(8, {});
return false;
} catch {
return true;
}
}
export function cleanup() {
delete Object.prototype.maxByteLength;
}
export function score() {
return [
scoring.OPTIONAL_OBJECT,
];
}