Chromium Code Reviews| Index: LayoutTests/inspector/elements/styles/case-sensitive-suggestions.html |
| diff --git a/LayoutTests/inspector/elements/styles/case-sensitive-suggestions.html b/LayoutTests/inspector/elements/styles/case-sensitive-suggestions.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf302f245655e1bf3efb20178a5d0f5f5187a49c |
| --- /dev/null |
| +++ b/LayoutTests/inspector/elements/styles/case-sensitive-suggestions.html |
| @@ -0,0 +1,81 @@ |
| +<html> |
| +<head> |
| +<script src="../../../http/tests/inspector/inspector-test.js"></script> |
| +<script src="../../../http/tests/inspector/elements-test.js"></script> |
| +<script> |
| + |
| +function test() |
| +{ |
| + WebInspector.inspectorView.showPanel("elements"); |
| + var prompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspector.CSSMetadata.cssPropertiesMetainfo, null, true); |
| + |
| + InspectorTest.runTestSuite([ |
| + function testForUpperCase(next) |
| + { |
| + testAutoCompletionsAgainstCase(prompt, "C", next); |
| + }, |
| + |
| + function testForLowerCase(next) |
| + { |
| + testAutoCompletionsAgainstCase(prompt, "b", next); |
| + }, |
| + |
| + function testForMixedCase(next) |
| + { |
| + testAutoCompletionsAgainstCase(prompt, "bAcK", next); |
| + }, |
| + ]); |
| + |
| + function testAutoCompletionsAgainstCase(prompt, inputText, callback) |
| + { |
| + var proxyElement = document.createElement("span"); |
|
apavlov
2014/07/14 11:25:53
... = document.createChild("span");
|
| + document.body.appendChild(proxyElement); |
|
apavlov
2014/07/14 11:25:53
this is not required given the change above
|
| + proxyElement.textContent = inputText; |
| + var selectionRange = document.createRange(); |
| + selectionRange.selectNodeContents(proxyElement); |
| + prompt._buildPropertyCompletions(proxyElement, selectionRange, true, completions); |
| + |
| + function completions(result, index) |
| + { |
| + function isUpperCase(str) { |
|
apavlov
2014/07/14 11:25:53
brace on the next line
|
| + return str === str.toUpperCase(); |
| + } |
| + |
| + function isLowerCase(str) { |
|
apavlov
2014/07/14 11:25:53
ditto
|
| + return str === str.toLowerCase(); |
| + } |
| + |
| + var Case = { |
| + Upper: 0, |
| + Lower: 1, |
| + Mixed: 2 |
| + }; |
| + |
| + var inputCase = isUpperCase(inputText) ? Case.Upper : isLowerCase(inputText) ? Case.Lower : Case.Mixed; |
| + |
| + for (var i = 0; i < result.length; ++i) { |
| + switch (inputCase) { |
| + case Case.Upper: |
|
apavlov
2014/07/14 11:25:53
no "case" indentation
|
| + if (!isUpperCase(result[i])) |
| + InspectorTest.addResult("Error: Suggestion " + result[i] + " must be in UPPERCASE."); |
| + break; |
| + case Case.Lower: |
| + if (!isLowerCase(result[i])) |
| + InspectorTest.addResult("Error: Suggestion " + result[i] + " must be in lowercase."); |
| + break; |
| + } |
| + } |
| + proxyElement.remove(); |
| + callback(); |
| + } |
| + } |
| +} |
| +</script> |
| +</head> |
| + |
| +<body onload="runTest()"> |
| +<p> |
| +Tests that text prompt suggestions are case sensitive, either UPPERCASE or lowercase, to user input. |
| +</p> |
| +</body> |
| +</html> |