-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathdefineProperty.js
53 lines (43 loc) · 1.72 KB
/
defineProperty.js
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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function TestDefineProperty(desc, testName) {
WScript.Echo(testName);
CatchAndWriteExceptions(function () {
Object.defineProperty(new Object(), "foo", desc);
WScript.Echo("Success");
});
}
function CatchAndWriteExceptions(func) {
try {
func();
}
catch (e) {
WScript.Echo(e.name + ": " + e.number);
}
}
var bools = [true, false];
var boolsExtended = [true, false];
boolsExtended[2] = undefined; // Work around WOOB 1099317 in compat mode
var desc;
for (var includeValue in bools) {
for (var includeWritable in boolsExtended) {
for (var includeGetter in bools) {
for (var includeSetter in bools) {
var s = "";
var b;
desc = {};
b = bools[includeValue];
if (b) { desc.value = "fooValue"; s += "value; "; }
b = boolsExtended[includeWritable];
if (b !== undefined) { desc.writable = b; s += "writable=" + b + "; "; }
b = bools[includeGetter];
if (b) { desc.get = function () { return "aValue"; }; s += "getter; "; }
b = bools[includeSetter];
if (b) { desc.set = function (v) { }; s += "setter; "; }
TestDefineProperty(desc, s);
}
}
}
}