OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <head> | |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../../http/tests/inspector/elements-test.js"></script> | |
5 <script> | |
6 | |
7 function test() | |
8 { | |
9 WebInspector.inspectorView.showPanel("elements"); | |
10 var prompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspect or.CSSMetadata.cssPropertiesMetainfo, null, true); | |
11 | |
12 InspectorTest.runTestSuite([ | |
13 function testForUpperCase(next) | |
14 { | |
15 testAutoCompletionsAgainstCase(prompt, "C", next); | |
16 }, | |
17 | |
18 function testForLowerCase(next) | |
19 { | |
20 testAutoCompletionsAgainstCase(prompt, "b", next); | |
21 }, | |
22 | |
23 function testForMixedCase(next) | |
24 { | |
25 testAutoCompletionsAgainstCase(prompt, "bAcK", next); | |
26 }, | |
27 ]); | |
28 | |
29 function testAutoCompletionsAgainstCase(prompt, inputText, callback) | |
30 { | |
31 var proxyElement = document.createElement("span"); | |
apavlov
2014/07/14 11:25:53
... = document.createChild("span");
| |
32 document.body.appendChild(proxyElement); | |
apavlov
2014/07/14 11:25:53
this is not required given the change above
| |
33 proxyElement.textContent = inputText; | |
34 var selectionRange = document.createRange(); | |
35 selectionRange.selectNodeContents(proxyElement); | |
36 prompt._buildPropertyCompletions(proxyElement, selectionRange, true, com pletions); | |
37 | |
38 function completions(result, index) | |
39 { | |
40 function isUpperCase(str) { | |
apavlov
2014/07/14 11:25:53
brace on the next line
| |
41 return str === str.toUpperCase(); | |
42 } | |
43 | |
44 function isLowerCase(str) { | |
apavlov
2014/07/14 11:25:53
ditto
| |
45 return str === str.toLowerCase(); | |
46 } | |
47 | |
48 var Case = { | |
49 Upper: 0, | |
50 Lower: 1, | |
51 Mixed: 2 | |
52 }; | |
53 | |
54 var inputCase = isUpperCase(inputText) ? Case.Upper : isLowerCase(in putText) ? Case.Lower : Case.Mixed; | |
55 | |
56 for (var i = 0; i < result.length; ++i) { | |
57 switch (inputCase) { | |
58 case Case.Upper: | |
apavlov
2014/07/14 11:25:53
no "case" indentation
| |
59 if (!isUpperCase(result[i])) | |
60 InspectorTest.addResult("Error: Suggestion " + resul t[i] + " must be in UPPERCASE."); | |
61 break; | |
62 case Case.Lower: | |
63 if (!isLowerCase(result[i])) | |
64 InspectorTest.addResult("Error: Suggestion " + resul t[i] + " must be in lowercase."); | |
65 break; | |
66 } | |
67 } | |
68 proxyElement.remove(); | |
69 callback(); | |
70 } | |
71 } | |
72 } | |
73 </script> | |
74 </head> | |
75 | |
76 <body onload="runTest()"> | |
77 <p> | |
78 Tests that text prompt suggestions are case sensitive, either UPPERCASE or lower case, to user input. | |
79 </p> | |
80 </body> | |
81 </html> | |
OLD | NEW |