3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
9 WebInspector.showPanel("elements");
11 var namePrompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspector.CSSMetadata.cssPropertiesMetainfo, null, true);
12 var valuePrompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspector.CSSMetadata.keywordsForProperty("color"), null, false);
14 InspectorTest.runTestSuite([
15 function testEmptyName(next)
17 testAgainstGolden(namePrompt, "", false, [], ["width"], next);
20 function testEmptyNameForce(next)
22 testAgainstGolden(namePrompt, "", true, ["width"], [], next);
25 function testSingleCharName(next)
27 testAgainstGolden(namePrompt, "w", false, ["width"], [], next);
30 function testEmptyValue(next)
32 testAgainstGolden(valuePrompt, "", false, ["aliceblue", "red", "inherit"], [], next);
35 function testValueR(next)
37 testAgainstGolden(valuePrompt, "R", false, ["red", "rosybrown"], ["aliceblue", "inherit"], next);
40 function testValueWithParenthesis(next)
42 testAgainstGolden(valuePrompt, "saturate(0%)", false, [], ["inherit"], next);
46 function testAgainstGolden(prompt, inputText, force, golden, antiGolden, callback)
48 var proxyElement = document.createElement("div");
49 document.body.appendChild(proxyElement);
50 proxyElement.style = "webkit-user-select: text; -webkit-user-modify: read-write-plaintext-only";
51 proxyElement.textContent = inputText;
52 var selectionRange = document.createRange();
53 var textNode = proxyElement.childNodes[0];
55 selectionRange.setStart(textNode, inputText.length);
56 selectionRange.setEnd(textNode, inputText.length);
58 selectionRange.selectNodeContents(proxyElement);
60 var range = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, prompt._completionStopCharacters, proxyElement, "backward");
61 prompt._buildPropertyCompletions(proxyElement, range, force, completions);
63 function completions(result, index)
66 for (i = 0; i < golden.length; ++i) {
67 if (result.indexOf(golden[i]) === -1)
68 InspectorTest.addResult("NOT FOUND: " + golden[i]);
70 for (i = 0; i < antiGolden.length; ++i) {
71 if (result.indexOf(antiGolden[i]) !== -1)
72 InspectorTest.addResult("FOUND: " + antiGolden[i]);
74 proxyElement.remove();
82 <body onload="runTest()">
84 Tests that autocompletions are computed correctly when editing the Styles pane.