forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobservable-array-setter.html
56 lines (45 loc) · 1.83 KB
/
observable-array-setter.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<body>
<script src="../resources/js-test.js"></script>
<script>
description("Tests for ObservableArray's [[Put]]");
let sheet1 = null;
let sheet2 = null;
let descriptor = null;
function runTest() {
"use strict";
sheet1 = new CSSStyleSheet()
sheet1.replaceSync('div { color: red }')
document.adoptedStyleSheets.push(sheet1)
shouldBe("document.adoptedStyleSheets.length", "1");
descriptor = Object.getOwnPropertyDescriptor(document.adoptedStyleSheets, 'length');
shouldBeFalse("descriptor.configurable");
shouldBeFalse("descriptor.enumerable");
shouldBeTrue("descriptor.writable");
shouldBe("descriptor.value", "1");
shouldBe("document.adoptedStyleSheets[0]", "sheet1");
evalAndLog("document.adoptedStyleSheets.length = 0");
shouldBe("document.adoptedStyleSheets.length", "0");
shouldBeUndefined("document.adoptedStyleSheets[0]");
sheet2 = new CSSStyleSheet()
sheet2.replaceSync('div { color: blue }')
document.adoptedStyleSheets.push(sheet1)
document.adoptedStyleSheets.push(sheet2)
shouldBe("document.adoptedStyleSheets.length", "2");
evalAndLog("document.adoptedStyleSheets.length = 1");
shouldBe("document.adoptedStyleSheets.length", "1");
shouldBe("document.adoptedStyleSheets[0]", "sheet1");
shouldBeUndefined("document.adoptedStyleSheets[1]");
evalAndLog("document.adoptedStyleSheets.length = 5");
shouldBe("document.adoptedStyleSheets.length", "1");
shouldBe("document.adoptedStyleSheets[0]", "sheet1");
shouldBeUndefined("document.adoptedStyleSheets[1]");
shouldThrowErrorName("document.adoptedStyleSheets.length = 0.5", "RangeError");
evalAndLog("document.adoptedStyleSheets.foo = 1;");
shouldBe("document.adoptedStyleSheets.foo", "1");
document.adoptedStyleSheets.length = 0;
}
runTest();
</script>
</body>