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

Side by Side Diff: LayoutTests/fast/dom/shadow/tabstop-property.html

Issue 1046853002: Implement 'tabstop' as an HTML attribute (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add invlid value case Created 5 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p>This is basic behavior test for tabStop attribute.</p> 7 <p>This is basic behavior test for tabStop attribute.</p>
8 <pre id="console"></pre> 8 <pre id="console"></pre>
9 <script> 9 <script>
10 var div; 10 var div;
11 11
12 function resetAttributes(el)
13 {
14 el.removeAttribute("tabindex");
15 el.removeAttribute("tabstop");
16 }
17
18 function tabStopShouldBe(el, expected)
19 {
20 shouldBe(el + ".tabStop", expected);
21 shouldBeEqualToString(el + ".getAttribute('tabstop')", expected);
22 }
23
12 function test() { 24 function test() {
13 debug("Testing tabStop property and attribute"); 25 debug("Testing tabStop property and attribute");
14 26
15 debug("Test tabStop normal assignment behavior"); 27 debug("Test tabStop normal assignment behavior");
16 div = document.createElement("div"); 28 div = document.createElement("div");
29
30 resetAttributes(div);
17 var flag = div.tabStop; 31 var flag = div.tabStop;
18 shouldBe("div.tabStop", "false"); 32 shouldBe("div.tabStop", "false");
19 33
20 div.tabStop = flag; 34 div.tabStop = flag;
35 tabStopShouldBe("div", "false");
36
37 div.removeAttribute('tabstop');
21 shouldBe("div.tabStop", "false"); 38 shouldBe("div.tabStop", "false");
39 shouldBe("div.hasAttribute('tabstop')", "false");
tkent 2015/03/31 08:11:18 nit: shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
22 40
23 div.removeAttribute('isTabstop'); 41 div.tabStop = true;
42 tabStopShouldBe("div", "true");
43
44 div.removeAttribute('tabstop');
24 shouldBe("div.tabStop", "false"); 45 shouldBe("div.tabStop", "false");
46 shouldBe("div.hasAttribute('tabstop')", "false");
tkent 2015/03/31 08:11:18 nit: shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
25 47
26 debug("Test tabStop override by tabindex property"); 48
49 debug("Test tabStop value implicitly set by tabindex property");
50 resetAttributes(div);
27 div.tabIndex = 0; 51 div.tabIndex = 0;
28 shouldBe("div.tabStop", "true"); 52 shouldBe("div.tabStop", "true");
29 53
30 div.tabIndex = -1; 54 div.tabIndex = -1;
31 shouldBe("div.tabStop", "false"); 55 shouldBe("div.tabStop", "false");
32 56
33 div.tabIndex = 1; 57 div.tabIndex = 1;
34 shouldBe("div.tabStop", "true"); 58 shouldBe("div.tabStop", "true");
35 59
36 debug("Test tabStop override by tabindex attribute"); 60 resetAttributes(div);
61 shouldBe("div.tabStop", "false");
tkent 2015/03/31 08:11:18 nit: shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
62
63
64 debug("Test explicit tabStop not overridable by tabindex attribute");
65 resetAttributes(div);
37 div.tabStop = false; 66 div.tabStop = false;
38 div.setAttribute("tabindex", "0"); 67 div.setAttribute("tabindex", "0");
39 shouldBe("div.tabStop", "true"); 68 tabStopShouldBe("div", "false");
40 69
41 div.tabStop = true; 70 div.tabStop = true;
42 div.setAttribute("tabindex", "-1"); 71 div.setAttribute("tabindex", "-1");
43 shouldBe("div.tabStop", "false"); 72 tabStopShouldBe("div", "true");
44 73
45 div.tabStop = false; 74 div.tabStop = false;
46 div.setAttribute("tabIndex", "1"); 75 div.setAttribute("tabIndex", "1");
76 tabStopShouldBe("div", "false");
77
78 resetAttributes(div);
79 shouldBe("div.tabStop", "false");
tkent 2015/03/31 08:11:18 shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
80 shouldBe("div.hasAttribute('tabstop')", "false");
tkent 2015/03/31 08:11:18 shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
81
82
83 debug("Test tabStop change with explicit tabindex change");
84 resetAttributes(div);
85
86 div.tabIndex = 0;
47 shouldBe("div.tabStop", "true"); 87 shouldBe("div.tabStop", "true");
88 div.tabStop = false;
89 tabStopShouldBe("div", "false");
90 resetAttributes(div);
48 91
49 debug("Test tabStop change after tabindex change"); 92 div.tabIndex = -1;
93 shouldBe("div.tabStop", "false");
tkent 2015/03/31 08:11:18 shouldBeFalse()
kochi 2015/03/31 08:46:08 Done.
94 div.tabStop = true;
95 tabStopShouldBe("div", "true");
96 resetAttributes(div);
97
98 debug("Test tabStop with invalid value");
99 resetAttributes(div);
100
50 div.tabIndex = 0; 101 div.tabIndex = 0;
51 div.tabStop = false; 102 div.tabStop = false;
52 shouldBe("div.tabStop", "false"); 103 tabStopShouldBe("div", "false");
104 div.setAttribute("tabstop", "invalid");
105 shouldBe("div.tabStop", "true");
tkent 2015/03/31 08:11:18 shouldBeTrue()
kochi 2015/03/31 08:46:08 Done.
106 shouldBeEqualToString("div.getAttribute('tabstop')", "invalid");
53 107
54 div.tabIndex = -1; 108 div.tabIndex = -1;
55 div.tabStop = true; 109 div.tabStop = true;
56 shouldBe("div.tabStop", "true"); 110 tabStopShouldBe("div", "true");
57 111 div.setAttribute("tabstop", "invalid");
58 debug("Test tabStop change before tabindex change which will be overridden") ;
59 div.tabStop = false;
60 div.tabIndex = 0;
61 shouldBe("div.tabStop", "true");
62
63 div.tabStop = true;
64 div.tabIndex = -1;
65 shouldBe("div.tabStop", "false"); 112 shouldBe("div.tabStop", "false");
113 shouldBeEqualToString("div.getAttribute('tabstop')", "invalid");
66 } 114 }
67 115
68 function run_test() { 116 function run_test() {
69 if (window.testRunner) 117 if (window.testRunner)
70 testRunner.dumpAsText(); 118 testRunner.dumpAsText();
71 119
72 test(); 120 test();
73 121
74 debug('Test finished.'); 122 debug('Test finished.');
75 } 123 }
76 124
77 run_test(); 125 run_test();
78 </script> 126 </script>
79 </body> 127 </body>
80 </html> 128 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698