4 <title>CSSValue comparison test
</title>
5 <script type=
"text/javascript" src=
"../resources/testharness.js"></script>
6 <script type=
"text/javascript" src=
"../resources/testharnessreport.js"></script>
9 <p>This test verifies that CSSValue objects comparison works correctly.
</p>
10 <div id=
"test" contenteditable
></div>
12 <script type=
"text/javascript">
13 setup({ "explicit_done": true });
16 var styleElement
= document
.createElement("style");
17 styleElement
.type
= "text/css";
18 var styleTextNode
= document
.createTextNode("");
19 styleElement
.appendChild(styleTextNode
);
20 document
.getElementsByTagName("head")[0].appendChild(styleElement
);
22 var div
= document
.getElementById("test");
25 function runTest(propertyName
, styleSheetPropertyValue
, inlineStylePropertyValue
, expectedResult
) {
26 styleTextNode
.data
= "div { " + propertyName
+ " : " + styleSheetPropertyValue
+ "; }";
27 document
.execCommand('insertHTML', false, "<div id=\"insertedDiv\" style=\"" + propertyName
+ " : " + inlineStylePropertyValue
+ "; \"></div>");
28 var insertedDiv
= document
.getElementById('insertedDiv');
29 var result
= expectedResult
;
30 if (propertyName
in insertedDiv
.style
)
31 result
= insertedDiv
.style
[propertyName
] === "";
36 var tests
= [ {"width" : ["20%", "2em", "2rem", "20px", "2cm", "20mm", "4in", "20pt", "10pc", "6vw", "6vh", "4vmin", "10vmax", "-webkit-calc(-100px + 100%)"]}, // lengths, calc
37 {"-webkit-transform" : ["rotate(15deg)", "rotate(1.55rad)", "rotate(200grad)", "rotate(0.5turn)"]}, // angle
38 {"background-image" : ["url(dummy://test.png)", "url(dummy://green.png)"]}, // uri
39 {"font-weight" : ["bold", "inherit"]}, // ident
40 {"content" : ["counter(a)", "counters(a, '.')"]}, // counter
41 {"content" : ["attr(a)", "attr(p)"]}, // attr
42 {"clip" : ["rect(40px, 0, 45px, -5px)", "rect(10px, 5px, 15px, -10px)"]}, // rect
43 {"border-radius" : ["30px 75px 15px 15px", "164px / 82px", "40px"]}, // quads
44 {"stop-color" : ["rgb(255,0,0)", "#FF5566"]}, // hex, rgb color
45 {"-webkit-clip-path" : ["polygon(evenodd, 10px 75px, 180px 180px, 100px 10px, 10px 180px, 180px 75px, 10px 75px)", "polygon(nonzero, 20% 20%, 80% 20%, 80% 80%, 20% 80%)"]}, // shape value
46 {"-webkit-animation-duration" : ["10s", "100ms"]}, // seconds, milliseconds
47 {"color" : ["red", "blue"]}, // ident
48 {"border-image-source" : ["url(resources/greenbox.png)", "url(resources/redbox.png)"]}, // image
49 {"border-image-slice" : ["1 2 3 4", "2 3 4 5"]}, // border image slice
50 {"cursor" : ["url(resources/greenbox.png) 0 0, pointer", "url(resources/cursor.png) 1 1, wait"]}, // cursor
51 {"font" : ["italic bold 12px/30px arial", "italic bold 8px/16px helvetica"]}, // font
52 {"background-image" : ["-webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000))", "-webkit-gradient(radial, 45 45, 0, 52 50, 0, from(#A7D30C), to(rgba(1,159,98,0)), color-stop(90%, #019F62))"]}, // gradients
53 {"background-image" : ["radial-gradient(circle, #ccc, #000)"]}, // gradients
54 {"background-image" : ["linear-gradient(#000, #234)", "linear-gradient(to top, #000, #234)"]}, // gradients
55 {"background-image" : ["-webkit-cross-fade(url(dummy://example.png), url(dummy://example.png), 50%)", "-webkit-cross-fade(url(dummy://background.png), url(dummy://foreground.png), 80%)"]}, // crossfade
56 {"-webkit-box-reflect" : ["below 10px", "below 0px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(10, 55, 234, 1)))"]}, // reflect
57 {"-webkit-box-shadow" : ["0 -20px 10px red, 0 20px 10px blue", "0 20px 10px blue", "5px 5px 5px rgba(0, 0, 0, 0.3)"]}, // shadow
58 {"-webkit-transition-timing-function" : ["cubic-bezier(0.25, 0.1, 0.25, 1)", "linear", "steps(3, end)"]}, // timing functions
59 {"-webkit-transform" : ["rotate(30deg)", "translate(50px,50px)", "scale(2,4)", "skew(30deg,20deg)", "matrix(0.4,0.5,-0.5,0.4,0,0)"]}, // transforms
60 {"-webkit-line-box-contain" : ["inline-box", "font", "glyphs", "replaced"]}, // line-box-contain
61 {"background-image" : ["-webkit-image-set(url(dummy://test.png) 1x, url(dummy://test.png) 2x)", "-webkit-image-set(url(dummy://small.png) 2x, url(dummy://big.png) 3x)"]}, // image set
62 {"-webkit-filter" : ["grayscale(100%) sepia(100%)", "sepia(10%) grayscale(50%)"]}, // filter
63 {"-webkit-dashboard-region" : ["dashboard-region(label circle)", "dashboard-region(label circle 1px 2px 3px 4px) dashboard-region(label rectangle 5px 6px 7px 8px)"]} // dashboard region
66 for (var index
in tests
) {
67 var testMap
= tests
[index
];
68 for (var key
in testMap
) {
69 var testValues
= testMap
[key
];
71 // Tests for equality.
72 for(var testIndex
in testValues
)
73 test(function() {assert_true(runTest(key
, testValues
[testIndex
], testValues
[testIndex
], true))}, "Two CSSValues \"" + testValues
[testIndex
] + "\" for property \"" + key
+ "\" are equal.");
75 // Test that comparison of non-equal cssvalues return false.
76 if (testValues
.length
> 1)
77 test(function() {assert_false(runTest(key
, testValues
[0], testValues
[1], false))}, "Two CSSValues \"" + testValues
[0] + "\" and \"" + testValues
[1] + "\" for property \"" + key
+ "\" are not equal.");