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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLElement/spellcheck.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 10 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
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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 <script src="script-tests/spellcheck.js"></script> 7 <script>
8 description('Tests the spellcheck attribute.');
9
10 var parent = document.createElement("div");
11 document.body.appendChild(parent);
12
13 function testFor(initialAttribute, initialExpectation, setValue, lastExpectation , lastAttributeExpectation)
14 {
15 var target = document.createElement("span");
16 parent.appendChild(target);
17
18 window.target = target;
19 window.initialExpectation = initialExpectation;
20 window.lastExpectation = lastExpectation;
21 window.lastAttributeExpectation = lastAttributeExpectation;
22
23 if (undefined !== initialAttribute)
24 target.setAttribute("spellcheck", initialAttribute);
25 shouldBe("target.spellcheck", "initialExpectation");
26
27 if (undefined !== setValue)
28 target.spellcheck = setValue;
29 shouldBe("target.spellcheck", "lastExpectation");
30 shouldBe("target.getAttribute('spellcheck')", "lastAttributeExpectation");
31
32 parent.removeChild(target);
33 }
34
35 function testUsingSetAttributes()
36 {
37 var target = document.createElement("span");
38 parent.appendChild(target);
39 window.target = target;
40
41 shouldBe("target.spellcheck", "true");
42 shouldBe("target.getAttribute('spellcheck')", "'true'");
43 // Set using property.
44 target.spellcheck = false;
45 shouldBe("target.spellcheck", "false");
46 shouldBe("target.getAttribute('spellcheck')", "'false'");
47 // Set using setAttribute().
48 target.setAttribute("spellcheck", "true");
49 shouldBe("target.spellcheck", "true");
50 shouldBe("target.getAttribute('spellcheck')", "'true'");
51
52 // Set using setAttribute(), valid but non canonical value.
53 target.spellcheck = false; // clear at first
54 target.setAttribute("spellcheck", "TRUE");
55 shouldBe("target.spellcheck", "true");
56 shouldBe("target.getAttribute('spellcheck')", "'TRUE'");
57 // Set using setAttribute(), invalid value.
58 target.spellcheck = false; // clear at first
59 target.setAttribute("spellcheck", "INVALID");
60 shouldBe("target.spellcheck", "true");
61 shouldBe("target.getAttribute('spellcheck')", "'INVALID'");
62
63 parent.removeChild(target);
64 }
65
66 testFor(undefined, true, undefined, true, null);
67 testFor(undefined, true, false, false, "false");
68 testFor(undefined, true, true, true, "true");
69 testFor(undefined, true, 0, false, "false"); // 0 will be coerced to false
70 testFor(undefined, true, 1, true, "true"); // 0 will be coerced to true
71 testFor(undefined, true, "invalid", true, "true"); // string will be coerced to true
72 testFor(undefined, true, "false", true, "true"); // ...even if the string is "fa lse" (as Firefox does).
73
74 testFor("true", true, undefined, true, "true");
75 testFor("true", true, false, false, "false");
76 testFor("true", true, true, true, "true");
77 testFor("true", true, 0, false, "false");
78 testFor("true", true, 1, true, "true");
79 testFor("true", true, "invalid", true, "true");
80 testFor("true", true, "false", true, "true");
81
82 testFor("false", false, undefined, false, "false");
83 testFor("false", false, false, false, "false");
84 testFor("false", false, true, true, "true");
85 testFor("false", false, 0, false, "false");
86 testFor("false", false, 1, true, "true");
87 testFor("false", false, "invalid", true, "true");
88 testFor("false", false, "false", true, "true");
89
90 // various initial values
91 testFor("", true, undefined, true, "");
92 testFor("", true, 1, true, "true");
93 testFor("TRUE", true, undefined, true, "TRUE");
94 testFor("TRUE", true, 1, true, "true");
95 testFor("FALSE", false, undefined, false, "FALSE");
96 testFor("FALSE", false, 0, false, "false");
97 testFor("invalid", true, undefined, true, "invalid");
98 testFor("invalid", true, 1, true, "true");
99 testFor("false ", true, undefined, true, "false ");
100 testFor("false ", true, 1, true, "true");
101 testFor("false ", true, 0, false, "false");
102 testFor("0", true, undefined, true, "0");
103 testFor("0", true, 0, false, "false");
104 testFor("1", true, undefined, true, "1");
105 testFor("1", true, 0, false, "false");
106
107 testUsingSetAttributes();
108 </script>
8 </body> 109 </body>
9 </html> 110 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698