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

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

Issue 701723007: 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-closest-general-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 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script>
6 if (window.testRunner)
7 testRunner.dumpAsText();
8 </script>
9 </head>
10 <body>
11
12 <tribe>
13 <realm>
14 <throne></throne>
15 <ancestor id="doe" name="young" class="classic">
16 <target id="anotherTarget"></target>
17 </ancestor>
18 </realm>
19 <ancestor id="john" name="old" class="classic">
20 <sibling id="sibling"></sibling>
21 <target id="theTarget" webkit="fast"></target>
22 </ancestor>
23 </tribe>
24
25 <foo>
26 <bar>
27 <a id="a">
28 <b id="b">
29 <c id="c">
30 <d id="d">
31 <e id="e">
32 <lemon id="sour"></lemon>
33 </e>
34 </d>
35 </c>
36 </b>
37 </a>
38 </bar>
39 </foo>
40 </body>
41
42 <script>
43 description('This test makes sure the closest() API works correctly');
44
45 var theTarget = document.getElementById('theTarget');
46 var ancestor = document.getElementById('john');
47 var sour = document.getElementById('sour');
48 var sibling = document.getElementById('sibling');
49 var a = document.getElementById('a');
50 var b = document.getElementById('b');
51 var c = document.getElementById('c');
52 var d = document.getElementById('d');
53 var e = document.getElementById('e');
54
55 shouldBe('theTarget.closest("#theTarget")', 'theTarget');
56 shouldBe('theTarget.closest("ancestor")', 'ancestor');
57 shouldBe('theTarget.closest("tribe ancestor")', 'ancestor');
58 shouldBe('theTarget.closest("tribe > ancestor")', 'ancestor');
59 shouldBe('theTarget.closest("realm + ancestor")', 'ancestor');
60 shouldBe('theTarget.closest("realm ~ ancestor")', 'ancestor');
61 shouldBe('theTarget.closest("tribe, ancestor")', 'ancestor');
62 shouldBe('theTarget.closest("ancestor, tribe")', 'ancestor');
63
64 shouldBeNull('theTarget.closest("tribe realm")');
65 shouldBeNull('theTarget.closest("tribe realm throne")');
66 shouldBeNull('theTarget.closest("tribe realm ancestor")');
67 shouldBeNull('theTarget.closest("realm > ancestor")');
68 shouldBeNull('theTarget.closest("throne + ancestor")');
69 shouldBeNull('theTarget.closest("throne ~ ancestor")');
70
71 shouldBe('theTarget.closest(".classic")', 'ancestor');
72 shouldBe('theTarget.closest("#john")', 'ancestor');
73 shouldBeNull('theTarget.closest("doe")');
74 shouldBe('theTarget.closest("ancestor[name=old]")', 'ancestor');
75 shouldBeNull('theTarget.closest("ancestor[name=young]")');
76
77 shouldBeNull('theTarget.closest(null)');
78 shouldBeNull('theTarget.closest(undefined)');
79
80 shouldBe('sour.closest("lemon")', 'sour');
81
82 shouldBe('sour.closest("a, b, c, d, e")', 'e');
83 shouldBe('sour.closest("a, b, c")', 'c');
84 shouldBe('sour.closest("a, b")', 'b');
85 shouldBe('sour.closest("e, d, c, b, a")', 'e');
86 shouldBe('sour.closest("d, c, b, a")', 'd');
87 shouldBe('sour.closest("c, b, a")', 'c');
88 shouldBe('sour.closest("b, a")', 'b');
89 shouldBe('sour.closest("a")', 'a');
90
91 shouldBe('document.closest', 'undefined');
92 shouldThrow('document.closest()');
93 shouldThrow('theTarget.closest()');
94 shouldThrow('theTarget.closest("")');
95 shouldThrow('theTarget.closest(".123")');
96 shouldThrow('theTarget.closest(" ")');
97 shouldThrow('theTarget.closest(")")');
98 shouldThrow('theTarget.closest("(")');
99 shouldThrow('theTarget.closest("()")');
100 shouldThrow('theTarget.closest("^_^")');
101 shouldThrow('theTarget.closest("{")');
102 shouldThrow('theTarget.closest("}")');
103 shouldThrow('theTarget.closest("{}")');
104 </script>
105 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/selectors/element-closest-general-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698