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 testImportantDeclarationDoNotToggleOnExclamationMark(next
)
41 testAgainstGolden(valuePrompt
, "red !", false, [], ["!important"], next
);
44 function testImportantDeclaration(next
)
46 testAgainstGolden(valuePrompt
, "red !i", false, ["!important"], [], next
);
49 function testValueR(next
)
51 testAgainstGolden(valuePrompt
, "R", false, ["RED", "ROSYBROWN"], ["aliceblue", "inherit"], next
);
54 function testValueWithParenthesis(next
)
56 testAgainstGolden(valuePrompt
, "saturate(0%)", false, [], ["inherit"], next
);
59 function testValuePrefixed(next
)
61 testAgainstGolden(valuePromptFor("-webkit-transform"), "t", false, ["translate", "translateY", "translate3d"], ["initial", "inherit"], next
);
64 function testValueUnprefixed(next
)
66 testAgainstGolden(valuePromptFor("transform"), "t", false, ["translate", "translateY", "translate3d"], ["initial", "inherit"], next
);
70 function testAgainstGolden(prompt
, inputText
, force
, golden
, antiGolden
, callback
)
72 var proxyElement
= document
.createElement("div");
73 document
.body
.appendChild(proxyElement
);
74 proxyElement
.style
= "webkit-user-select: text; -webkit-user-modify: read-write-plaintext-only";
75 proxyElement
.textContent
= inputText
;
76 var selectionRange
= document
.createRange();
77 var textNode
= proxyElement
.childNodes
[0];
79 selectionRange
.setStart(textNode
, inputText
.length
);
80 selectionRange
.setEnd(textNode
, inputText
.length
);
82 selectionRange
.selectNodeContents(proxyElement
);
84 var range
= selectionRange
.startContainer
.rangeOfWord(selectionRange
.startOffset
, prompt
._completionStopCharacters
, proxyElement
, "backward");
85 prompt
._buildPropertyCompletions(proxyElement
, range
, force
, completions
);
87 function completions(result
, index
)
90 for (i
= 0; i
< golden
.length
; ++i
) {
91 if (result
.indexOf(golden
[i
]) === -1)
92 InspectorTest
.addResult("NOT FOUND: " + golden
[i
]);
94 for (i
= 0; i
< antiGolden
.length
; ++i
) {
95 if (result
.indexOf(antiGolden
[i
]) !== -1)
96 InspectorTest
.addResult("FOUND: " + antiGolden
[i
]);
98 proxyElement
.remove();
106 <body onload=
"runTest()">
108 Tests that autocompletions are computed correctly when editing the Styles pane.