3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/elements-test.js"></script>
5 <script type=
"text/javascript">
9 function setColor(inputColor
, format
)
11 InspectorTest
.addResult("Testing: " + inputColor
);
12 var color
= WebInspector
.Color
.parse(inputColor
);
13 spectrum
.setColor(color
, format
);
16 function checkColorString(inputColor
, format
)
18 setColor(inputColor
, format
)
19 InspectorTest
.addResult(spectrum
.colorString());
22 function checkAlphaChange(inputColor
, format
)
24 setColor(inputColor
, format
)
26 spectrum
._innerSetColor(spectrum
._hsv
, undefined, undefined, WebInspector
.Spectrum
._ChangeSource
.Other
);
27 InspectorTest
.addResult(spectrum
.colorString());
30 function checkNextFormat(inputColor
, format
)
32 setColor(inputColor
, format
);
33 spectrum
._formatViewSwitch();
34 InspectorTest
.addResult(spectrum
._colorFormat
);
35 spectrum
._formatViewSwitch();
36 InspectorTest
.addResult(spectrum
._colorFormat
);
39 var spectrum
= new WebInspector
.Spectrum();
40 var cf
= WebInspector
.Color
.Format
;
42 { string
: "red", format
: cf
.Nickname
},
43 { string
: "#ABC", format
: cf
.ShortHEX
},
44 { string
: "#ABCDEF", format
: cf
.HEX
},
45 { string
: "rgb(1, 2, 3)", format
: cf
.RGB
},
46 { string
: "rgba(1, 2, 3, 0.2)", format
: cf
.RGB
},
47 { string
: "hsl(1, 100%, 50%)", format
: cf
.HSL
},
48 { string
: "hsla(1, 100%, 50%, 0.2)", format
: cf
.HSLA
}];
50 InspectorTest
.addResult("--- Testing colorString()");
51 for (var color
of inputColors
)
52 checkColorString(color
.string
, color
.format
);
54 InspectorTest
.addResult("--- Testing alpha changes");
55 for (var color
of inputColors
)
56 checkAlphaChange(color
.string
, color
.format
);
58 InspectorTest
.addResult("--- Testing _formatViewSwitch()");
59 for (var color
of inputColors
)
60 checkNextFormat(color
.string
, color
.format
);
62 InspectorTest
.completeTest();
67 <body onload=
"runTest()">
68 <p>Tests WebInspector.Spectrum
</p>