Bug 1247777 - Part4.2: add compatible webkit prefixed properties in

CSS properties ordering check test. r=bz

--HG--
extra : commitid : 3L1KflCYhR3
This commit is contained in:
Jeremy Chen 2016-03-25 15:54:50 +08:00
Родитель b28e75fd40
Коммит ca58c7482d
1 изменённых файлов: 37 добавлений и 12 удалений

Просмотреть файл

@ -18,23 +18,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=657143
:root { --test: some value; }
</style>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 657143 **/
// Checks ordering of CSS properties in nsComputedDOMStyle.cpp
// by splitting the getComputedStyle() into four sublists
// Check ordering of CSS properties in nsComputedDOMStylePropertyList.h
// by splitting the getComputedStyle() into five sublists
// then cloning and sort()ing the lists and comparing with originals.
function isPrefixed(aProp) {
function isMozPrefixed(aProp) {
return aProp.startsWith("-moz");
}
function isNotPrefixed(aProp) {
return !isPrefixed(aProp);
function isNotMozPrefixed(aProp) {
return !isMozPrefixed(aProp);
}
function isWebkitPrefixed(aProp) {
return aProp.startsWith("-webkit");
}
function isNotWebkitPrefixed(aProp) {
return !isWebkitPrefixed(aProp);
}
function isCustom(aProp) {
@ -46,7 +54,7 @@ function isNotCustom(aProp) {
}
var styleList = window.getComputedStyle(document.documentElement);
cssA = [], mozA = [], svgA = [], customA = [];
cssA = [], mozA = [], webkitA = [], svgA = [], customA = [];
// Partition the list of property names into four lists:
//
@ -61,13 +69,18 @@ for (var i = 0, j = styleList.length; i < j; i++) {
switch (list) {
case cssA:
if (isPrefixed(prop)) {
if (isMozPrefixed(prop)) {
list = mozA;
}
// fall through
case mozA:
if (isWebkitPrefixed(prop)) {
list = webkitA;
}
// fall through
case webkitA:
// Assume that the first SVG property is 'clip-path'.
if (prop == "clip-path") {
// Assumes that the first SVG property is 'clip-path'.
list = svgA;
}
// fall through
@ -83,21 +96,33 @@ for (var i = 0, j = styleList.length; i < j; i++) {
var cssB = cssA.slice(0).sort(),
mozB = mozA.slice(0).sort(),
webkitB = webkitA.slice(0).sort(),
svgB = svgA.slice(0).sort();
is(cssA.toString(), cssB.toString(), 'CSS property list should be alphabetical');
is(mozA.toString(), mozB.toString(), 'Experimental -moz- CSS property list should be alphabetical');
is(webkitA.toString(), webkitB.toString(), 'Compatible -webkit- CSS property list should be alphabetical');
is(svgA.toString(), svgB.toString(), 'SVG property list should be alphabetical');
// We don't test that the custom property list is sorted, as the CSSOM
// specification does not yet require it, and we don't return them
// in sorted order.
ok(!cssA.find(isPrefixed), 'Experimental -moz- CSS properties should not be in the mature CSS property list');
ok(!cssA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the mature CSS property list');
ok(!cssA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the mature CSS property list');
ok(!cssA.find(isCustom), 'Custom CSS properties should not be in the mature CSS property list');
ok(!mozA.find(isNotPrefixed), 'Experimental -moz- CSS property list should not contain mature CSS properties');
ok(!mozA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the experimental -moz- CSS '
+ 'property list');
ok(!mozA.find(isNotMozPrefixed), 'Experimental -moz- CSS property list should not contain non -moz- prefixed '
+ 'CSS properties');
ok(!mozA.find(isCustom), 'Custom CSS properties should not be in the experimental -moz- CSS property list');
ok(!svgA.find(isPrefixed), 'Experimental -moz- CSS properties should not be in the SVG property list');
ok(!webkitA.find(isNotWebkitPrefixed), 'Compatible -webkit- CSS properties should not contain non -webkit- prefixed '
+ 'CSS properties');
ok(!webkitA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the compatible -webkit- CSS '
+ 'property list');
ok(!webkitA.find(isCustom), 'Custom CSS properties should not be in the compatible -webkit- CSS property list');
ok(!svgA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the SVG property list');
ok(!svgA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the SVG property list');
ok(!svgA.find(isCustom), 'Custom CSS properties should not be in the SVG property list');
ok(!customA.find(isNotCustom), 'Non-custom CSS properties should not be in the custom property list');