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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1107443
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1107443</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
var { AppConstants } = SpecialPowers.ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
/**
* Test for Bug 1107443, modified when it was backed out in bug 1329323.
* This is now testing the _current_ behavior, not the desired one; expect
* failures in this test and needing to update it when bug 1329324 is
* fixed.
*/
var retval = Object.defineProperty(window, "nosuchprop",
{ value: 5, configurable: false });
todo_is(retval, null,
"Should return null when 'failing' to define non-configurable property via Object.defineProperty.")
var desc = Object.getOwnPropertyDescriptor(window, "nosuchprop");
is(typeof(desc), "object", "Should have a property 'nosuchprop' now");
todo_is(desc.configurable, true,
"Property 'nosuchprop' should be configurable");
is(desc.writable, false, "Property 'nosuchprop' should be readonly");
is(desc.value, 5, "Property 'nosuchprop' should have the right value");
retval = Object.defineProperties(window, {
"firstProp": { value: 1 },
"secondProp": { value: 2, configurable: false },
"thirdProp": { value: 3 },
});
todo_is(retval, null,
"Should return null when 'failing' to define non-configurable property via Object.defineProperties.")
// The properties should all be defined.
for (var [prop, val] of [["firstProp", 1], ["secondProp", 2], ["thirdProp", 3]]) {
desc = Object.getOwnPropertyDescriptor(window, prop);
is(typeof(desc), "object", `Should have a property '${prop}' now`);
todo_is(desc.configurable, true,
`Property '${prop}' should be configurable`);
is(desc.writable, false, `Property '${prop}' should be readonly`);
is(desc.value, val, `Property '${prop}' should have the right value`);
}
retval = Object.defineProperty(window, "nosuchprop2", { value: 6 });
is(retval, window,
"Should return object when succesfully defining 'nosuchprop2'");
desc = Object.getOwnPropertyDescriptor(window, "nosuchprop2");
is(typeof(desc), "object", "Should have a property 'nosuchprop2' now");
todo_is(desc.configurable, true,
"Property 'nosuchprop2' should be configurable");
is(desc.writable, false, "Property 'nosuchprop2' should be readonly");
is(desc.value, 6, "Property 'nosuchprop2' should have the right value");
retval = Object.defineProperty(window, "nosuchprop3",
{ value: 7, configurable: true });
is(retval, window,
"Should return object when succesfully defining 'nosuchprop3'");
desc = Object.getOwnPropertyDescriptor(window, "nosuchprop3");
is(typeof(desc), "object", "Should have a property 'nosuchprop3' now");
is(desc.configurable, true,
"Property 'nosuchprop3' should be configurable");
is(desc.writable, false, "Property 'nosuchprop3' should be readonly");
is(desc.value, 7, "Property 'nosuchprop3' should have the right value");
retval = Reflect.defineProperty(window, "nosuchprop4",
{ value: 8, configurable: false });
todo_is(retval, false,
"Should not be able to Reflect.defineProperty if non-configurable");
desc = Object.getOwnPropertyDescriptor(window, "nosuchprop4");
is(typeof(desc), "object", "Should have a property 'nosuchprop4' now");
todo_is(desc.configurable, true,
"Property 'nosuchprop4' should be configurable");
is(desc.writable, false, "Property 'nosuchprop4' should be readonly");
is(desc.value, 8, "Property 'nosuchprop4' should have the right value");
retval = Reflect.defineProperty(window, "nosuchprop5",
{ value: 9 });
is(retval, true,
"Should be able to Reflect.defineProperty with default configurability");
desc = Object.getOwnPropertyDescriptor(window, "nosuchprop5");
is(typeof(desc), "object", "Should have a property 'nosuchprop5' now");
todo_is(desc.configurable, true,
"Property 'nosuchprop5' should be configurable");
is(desc.writable, false, "Property 'nosuchprop5' should be readonly");
is(desc.value, 9, "Property 'nosuchprop5' should have the right value");
retval = Reflect.defineProperty(window, "nosuchprop6",
{ value: 10, configurable: true });
is(retval, true,
"Should be able to Reflect.defineProperty if configurable");
desc = Object.getOwnPropertyDescriptor(window, "nosuchprop6");
is(typeof(desc), "object", "Should have a property 'nosuchprop6' now");
is(desc.configurable, true, "Property 'nosuchprop6' should be configurable");
is(desc.writable, false, "Property 'nosuchprop6' should be readonly");
is(desc.value, 10, "Property 'nosuchprop6' should have the right value");
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107443">Mozilla Bug 1107443</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>
|