forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobservable-array-delete.html
59 lines (45 loc) · 1.84 KB
/
observable-array-delete.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
57
58
59
<!DOCTYPE html>
<html>
<body>
<script src="../resources/js-test.js"></script>
<script>
description("Tests for ObservableArray's [[Delete]]");
let sheet1 = null;
let sheet2 = null;
let sheet3 = null;
function runTest() {
"use strict";
sheet1 = new CSSStyleSheet()
sheet1.replaceSync('div { color: red }')
document.adoptedStyleSheets.push(sheet1)
sheet2 = new CSSStyleSheet()
sheet2.replaceSync('div { color: blue }')
document.adoptedStyleSheets.push(sheet2)
sheet3 = new CSSStyleSheet()
sheet3.replaceSync('div { color: green }')
document.adoptedStyleSheets.push(sheet3)
shouldBe("document.adoptedStyleSheets.length", "3");
shouldBeFalse("delete document.adoptedStyleSheets.length;");
shouldBeFalse("delete document.adoptedStyleSheets[0]");
shouldBeFalse("delete document.adoptedStyleSheets[1]");
shouldBeFalse("delete document.adoptedStyleSheets[3]");
shouldBe("document.adoptedStyleSheets.length", "3");
shouldBeTrue("delete document.adoptedStyleSheets[2]");
shouldBe("document.adoptedStyleSheets.length", "2");
shouldBe("document.adoptedStyleSheets[0]", "sheet1");
shouldBe("document.adoptedStyleSheets[1]", "sheet2");
shouldBeUndefined("document.adoptedStyleSheets[2]");
shouldBeTrue("delete document.adoptedStyleSheets['1']");
shouldBe("document.adoptedStyleSheets.length", "1");
shouldBe("document.adoptedStyleSheets[0]", "sheet1");
shouldBeUndefined("document.adoptedStyleSheets[1]");
shouldBeTrue("delete document.adoptedStyleSheets[0]");
shouldBe("document.adoptedStyleSheets.length", "0");
shouldBeUndefined("document.adoptedStyleSheets[0]");
evalAndLog("document.adoptedStyleSheets.foo = 1");
shouldBeTrue("delete document.adoptedStyleSheets.foo;");
shouldBeUndefined("document.adoptedStyleSheets.foo");
}
runTest();
</script>
</body>