-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxy-defineProperty.PoC.js
More file actions
69 lines (60 loc) · 2.29 KB
/
Proxy-defineProperty.PoC.js
File metadata and controls
69 lines (60 loc) · 2.29 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
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: BlueOak-1.0.0
import { scoring } from "./score.js";
const property = "foo";
const value = "bar";
const object = { };
export const about = {
function: "new Proxy()",
link: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy",
properties: ["'defineProperty'"],
description: `
To create a Proxy users need to provide an object as a second argument. This
object allows specifying a myriad of traps. Usually, if a specific trap is not
specified it is not used and usual behavior is maintained. However, if any of
the traps is present on the prototype it will be used. This is also the case for
proxies created *before* the pollution happened.`,
test262: new Set([
"test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js",
"test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js",
"test/built-ins/Proxy/has/call-in-prototype-index.js",
"test/built-ins/Proxy/set/call-parameters-prototype-index.js",
"test/built-ins/Proxy/getOwnPropertyDescriptor/trap-is-missing-target-is-proxy.js",
"test/built-ins/Proxy/getOwnPropertyDescriptor/trap-is-null-target-is-proxy.js",
"test/built-ins/Proxy/getOwnPropertyDescriptor/trap-is-undefined-target-is-proxy.js",
"test/built-ins/Object/freeze/proxy-no-ownkeys-returned-keys-order.js",
"test/built-ins/Array/prototype/splice/create-proxy.js",
"test/built-ins/Proxy/set/trap-is-undefined-no-property.js",
"test/built-ins/Proxy/set/trap-is-missing-target-is-proxy.js",
"test/built-ins/Proxy/set/trap-is-null-target-is-proxy.js",
"test/built-ins/Proxy/set/trap-is-undefined-target-is-proxy.js",
"test/built-ins/Proxy/set/trap-is-undefined.js",
]),
};
export function prerequisite() {
const subject = new Proxy(object, {});
subject[property] = value;
const got = subject[property];
if (got === value) {
return [true, null];
} else {
return [false, `got ${got}`];
}
}
export function test() {
const subject = new Proxy(object, {});
let flag = false;
Object.prototype.defineProperty = () => {
flag = true;
return true;
};
subject[property] = value;
return flag;
}
export function cleanup() {
delete Object.prototype.defineProperty;
}
export function score() {
return [
scoring.POLLUTE_WITH_FUNCTION,
];
}