3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
10 var namePrompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspector.CSSMetadata.cssPropertiesMetainfo, null, true);
11 var valuePrompt = valuePromptFor("color");
13 function valuePromptFor(name)
15 return new WebInspector.StylesSidebarPane.CSSPropertyPrompt(WebInspector.CSSMetadata.keywordsForProperty(name), null, false);
18 InspectorTest.runTestSuite([
19 function testEmptyName(next)
21 testAgainstGolden(namePrompt, "", false, [], ["width"], next);
24 function testEmptyNameForce(next)
26 testAgainstGolden(namePrompt, "", true, ["width"], [], next);
29 function testSingleCharName(next)
31 testAgainstGolden(namePrompt, "w", false, ["width"], [], next);
34 function testEmptyValue(next)
36 testAgainstGolden(valuePrompt, "", false, ["aliceblue", "red", "inherit"], [], next);
39 function testValueR(next)
41 testAgainstGolden(valuePrompt, "R", false, ["RED", "ROSYBROWN"], ["aliceblue", "inherit"], next);
44 function testValueWithParenthesis(next)
46 testAgainstGolden(valuePrompt, "saturate(0%)", false, [], ["inherit"], next);
49 function testValuePrefixed(next)
51 testAgainstGolden(valuePromptFor("-webkit-transform"), "t", false, ["translate", "translateY", "translate3d"], ["initial", "inherit"], next);
54 function testValueUnprefixed(next)
56 testAgainstGolden(valuePromptFor("transform"), "t", false, ["translate", "translateY", "translate3d"], ["initial", "inherit"], next);
60 function testAgainstGolden(prompt, inputText, force, golden, antiGolden, callback)
62 var proxyElement = document.createElement("div");
63 document.body.appendChild(proxyElement);
64 proxyElement.style = "webkit-user-select: text; -webkit-user-modify: read-write-plaintext-only";
65 proxyElement.textContent = inputText;
66 var selectionRange = document.createRange();
67 var textNode = proxyElement.childNodes[0];
69 selectionRange.setStart(textNode, inputText.length);
70 selectionRange.setEnd(textNode, inputText.length);
72 selectionRange.selectNodeContents(proxyElement);
74 var range = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, prompt._completionStopCharacters, proxyElement, "backward");
75 prompt._buildPropertyCompletions(proxyElement, range, force, completions);
77 function completions(result, index)
80 for (i = 0; i < golden.length; ++i) {
81 if (result.indexOf(golden[i]) === -1)
82 InspectorTest.addResult("NOT FOUND: " + golden[i]);
84 for (i = 0; i < antiGolden.length; ++i) {
85 if (result.indexOf(antiGolden[i]) !== -1)
86 InspectorTest.addResult("FOUND: " + antiGolden[i]);
88 proxyElement.remove();
96 <body onload="runTest()">
98 Tests that autocompletions are computed correctly when editing the Styles pane.