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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLElement/script-tests/spellcheck.js

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

Powered by Google App Engine
This is Rietveld 408576698