Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: LayoutTests/fast/selectors/element-closeset.html

Issue 693203004: Revert of Adding Element.closest() API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/selectors/element-closeset-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 if (window.testRunner)
5 testRunner.dumpAsText();
6 </script>
7 <body>
8 <tribe>
9
10 <realm>
11 <throne></throne>
12 <ancestor id="doe" name="young" class="classic">
13 <target id="anotherTarget"></target>
14 </ancestor>
15 </realm>
16
17 <ancestor id="john" name="old" class="classic">
18 <sibling></sibling>
19 <target id="theTarget" webkit="fast"></target>
20 </ancestor>
21
22 </tribe>
23
24 <foo>
25 <bar>
26 <a id="a">
27 <b id="b">
28 <c id="c">
29 <d id="d">
30 <lemon id="sour"></lemon>
31 </d>
32 <c/>
33 </b>
34 </a>
35 </bar>
36 </foo>
37 </body>
38 <script>
39 description('This test makes sure the closest() API works correctly');
40
41 var theTarget = document.getElementById('theTarget');
42 var ancestor = document.getElementById('john');
43 var sour = document.getElementById('sour');
44 var a = document.getElementById('a');
45 var b = document.getElementById('b');
46 var c = document.getElementById('c');
47 var d = document.getElementById('d');
48
49 shouldBe('theTarget.closest("#theTarget")', 'theTarget');
50 shouldBe('theTarget.closest("ancestor")', 'ancestor');
51 shouldBe('theTarget.closest("tribe ancestor")', 'ancestor');
52 shouldBe('theTarget.closest("tribe > ancestor")', 'ancestor');
53 shouldBe('theTarget.closest("realm + ancestor")', 'ancestor');
54 shouldBe('theTarget.closest("realm ~ ancestor")', 'ancestor');
55 shouldBe('theTarget.closest("tribe, ancestor")', 'ancestor');
56 shouldBe('theTarget.closest("ancestor, tribe")', 'ancestor');
57
58 shouldBeNull('theTarget.closest("tribe realm")');
59 shouldBeNull('theTarget.closest("tribe realm throne")');
60 shouldBeNull('theTarget.closest("tribe realm ancestor")');
61 shouldBeNull('theTarget.closest("realm > ancestor")');
62 shouldBeNull('theTarget.closest("throne + ancestor")');
63 shouldBeNull('theTarget.closest("throne ~ ancestor")');
64
65 shouldBe('theTarget.closest(".classic")', 'ancestor');
66 shouldBe('theTarget.closest("#john")', 'ancestor');
67 shouldBeNull('theTarget.closest("doe")');
68 shouldBe('theTarget.closest("ancestor[name=old]")', 'ancestor');
69 shouldBeNull('theTarget.closest("ancestor[name=young]")', 'ancestor');
70
71 shouldBeNull('theTarget.closest(null)');
72 shouldBeNull('theTarget.closest(undefined)');
73
74 shouldBe('sour.closest("lemon")', 'sour');
75
76 shouldBe('sour.closest("a, b, c, d")', 'd');
77 shouldBe('sour.closest("a, b, c")', 'c');
78 shouldBe('sour.closest("a, b")', 'b');
79 shouldBe('sour.closest("d, c, b, a")', 'd');
80 shouldBe('sour.closest("c, b, a")', 'c');
81 shouldBe('sour.closest("b, a")', 'b');
82 shouldBe('sour.closest("a")', 'a');
83
84 shouldBe('document.closest', 'undefined');
85 shouldThrow('document.closest()');
86 shouldThrow('theTarget.closest()');
87 shouldThrow('theTarget.closest("")');
88 shouldThrow('theTarget.closest(".123")');
89 shouldThrow('theTarget.closest(" ")');
90 shouldThrow('theTarget.closest(")")');
91 shouldThrow('theTarget.closest("(")');
92 shouldThrow('theTarget.closest("()")');
93 shouldThrow('theTarget.closest("^_^")');
94 shouldThrow('theTarget.closest("{")');
95 shouldThrow('theTarget.closest("}")');
96 shouldThrow('theTarget.closest("{}")');
97
98 shouldBe('theTarget.closest(":scope")', 'theTarget');
99 shouldBe('theTarget.closest("ancestor :scope")', 'theTarget');
100 shouldBe('theTarget.closest("ancestor > :scope")', 'theTarget');
101
102 shouldBe('theTarget.closest("sibling + :scope")', 'theTarget');
103 shouldBe('theTarget.closest("sibling ~ :scope")', 'theTarget');
104
105 shouldBe('theTarget.closest("#theTarget:scope")', 'theTarget');
106 shouldBe('theTarget.closest(":scope#theTarget")', 'theTarget');
107
108 shouldBe('theTarget.closest("[webkit]:scope#theTarget")', 'theTarget');
109 shouldBeNull('theTarget.closest(":not([webkit=fast]):scope#theTarget")');
110
111 shouldBeNull('theTarget.closest(":scope target")');
112 shouldBeNull('theTarget.closest(":scope > target")');
113 shouldBeNull('theTarget.closest(":scope + target")');
114 shouldBeNull('theTarget.closest(":scope ~ target")');
115
116 shouldBeNull('theTarget.closest(":scope *")');
117 shouldBeNull('theTarget.closest(":scope > *")');
118 shouldBeNull('theTarget.closest(":scope + *")');
119 shouldBeNull('theTarget.closest(":scope ~ *")');
120 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/selectors/element-closeset-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698