-
Notifications
You must be signed in to change notification settings - Fork 3k
/
named-properties-object.html
33 lines (28 loc) · 1.14 KB
/
named-properties-object.html
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
<!doctype html>
<meta charset="utf-8">
<title>named properties object</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object">
<script>
"use strict";
test(() => {
const npo = Object.getPrototypeOf(Window.prototype);
assert_equals(npo.nonExistingProp, undefined);
assert_throws_js(TypeError, () => {
const desc = Object.create(null);
Object.defineProperty(npo, "nonExistingProp", desc);
}, "Cannot define a property with Object.defineProperty (string)");
assert_throws_js(TypeError, () => {
npo.nonExistingProp = "peach";
}, "Cannot create a property through assignment (string)");
assert_equals(npo[123], undefined);
assert_throws_js(TypeError, () => {
const desc = Object.create(null);
Object.defineProperty(npo, 123, desc);
}, "Cannot define a property with Object.defineProperty (index)");
assert_throws_js(TypeError, () => {
npo[123] = "peach";
}, "Cannot create a property through assignment (index)");
}, "Cannot create a property on a named property object");
</script>