function xfail_value(property, value, is_initial, has_frame) {
if (!has_frame && (property in gBadComputedNoFrame) &&
gBadComputedNoFrame[property].includes(value))
return true;
return false;
}
var gSwapInitialWhenHaveFrame = {
// For the inline axis ('width' by default): when there's a frame,
// 'stretch' and its prefixed aliases work out to the same as 'auto',
// given the prerequisites of only 'display: block'. "width": [ "-moz-available", "-webkit-fill-available", "stretch" ],
// For the block axis ('height' by default): when there's a frame, these
// keywords work out to the same as the initial value, i.e. `auto`, given
// the prerequisites of only 'display: block'. (Notably, 'stretch' and
// its '-webkit-fill-available' alias *do not behave like auto* in the
// block axis, so they're not listed among the keywords here.) "height": [ "-moz-max-content", "-moz-min-content", "-moz-fit-content", "-moz-available", // TODO(dholbert): remove in bug 527285. "max-content", "min-content", "fit-content", "fit-content(100px)", "fit-content(10%)", "fit-content(calc(3*25px + 50%))" ],
};
// Use the same lists for logical versions of width/height properties:
gSwapInitialWhenHaveFrame["inline-size"] = gSwapInitialWhenHaveFrame.width;
gSwapInitialWhenHaveFrame["block-size"] = gSwapInitialWhenHaveFrame.height;
function swap_when_frame(property, value) {
return (property in gSwapInitialWhenHaveFrame) &&
gSwapInitialWhenHaveFrame[property].includes(value);
}
var gDisplayTree = document.getElementById("display"); var gElementN = document.getElementById("elementn"); var gElementF = document.getElementById("elementf"); var gStyleSheet = document.getElementById("stylesheet").sheet; var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#elementn, #elementf {}", gStyleSheet.cssRules.length)]; var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#elementn, #elementf {}", gStyleSheet.cssRules.length)];
var gInitialValuesN; var gInitialValuesF; var gInitialPrereqsRuleN; var gInitialPrereqsRuleF;
function setup_initial_values(id, ivalprop, prereqprop) { variframe = document.getElementById(id);
window[ivalprop] = iframe.contentWindow.getComputedStyle( iframe.contentDocument.documentElement.firstChild); var sheet = iframe.contentDocument.styleSheets[0];
// For 'width', 'height', etc., need a constant size container.
sheet.insertRule(":root { height: 200px; width: 500px }", sheet.cssRules.length);
function test_value(property, val, is_initial)
{ var info = gCSSProperties[property];
if ("prerequisites" in info) { var prereqs = info.prerequisites;
for (var prereq in prereqs) {
gRule1.style.setProperty(prereq, prereqs[prereq], "");
gInitialPrereqsRuleN.style.setProperty(prereq, prereqs[prereq], "");
gInitialPrereqsRuleF.style.setProperty(prereq, prereqs[prereq], "");
}
}
if (info.inherited && is_initial) {
gElementN.parentNode.style.setProperty(property, info.other_values[0], "");
gElementF.parentNode.style.setProperty(property, info.other_values[0], "");
}
var initial_computed_n = get_computed_value(gInitialValuesN, property); var initial_computed_f = get_computed_value(gInitialValuesF, property);
if (is_initial) {
gRule1.style.setProperty(property, info.other_values[0], ""); var other_computed_n = get_computed_value(getComputedStyle(gElementN, ""), property); var other_computed_f = get_computed_value(getComputedStyle(gElementF, ""), property);
isnot(other_computed_n, initial_computed_n, "should be testing with values that compute to different things " + "for '" + property + "'");
isnot(other_computed_f, initial_computed_f, "should be testing with values that compute to different things " + "for '" + property + "'");
}
// It used to be important for values that are supposed to compute to the
// initial value (given the design of the old rule tree, nsRuleNode) that
// we're modifying the most specific rule that matches the element, and
// that we've already requested style while that rule was empty. This
// means we'd have a cached aStartStruct from the parent in the rule
// tree (caching the "other" value), so we'd make sure we don't get the
// initial value from the luck of default-initialization. This means
// that it would've been important that we set the prereqs on
// gRule1.style rather than on gElement.style.
//
// However, the rule tree no longer stores cached structs, and we only
// temporarily cache reset structs during a single restyle. So the
// particular failure mode this was designed to test for isn't as
// likely to eventuate.
gRule2.style.setProperty(property, val, ""); var val_computed_n = get_computed_value(getComputedStyle(gElementN, ""), property); var val_computed_f = get_computed_value(getComputedStyle(gElementF, ""), property);
isnot(val_computed_n, "", "should not get empty value for '" + property + ":" + val + "'");
isnot(val_computed_f, "", "should not get empty value for '" + property + ":" + val + "'");
if (is_initial) {
(xfail_value(property, val, is_initial, false) ? todo_is : is)(
val_computed_n, initial_computed_n, "should get initial value for '" + property + ":" + val + "'");
(xfail_value(property, val, is_initial, true) ? todo_is : is)(
val_computed_f, initial_computed_f, "should get initial value for '" + property + ":" + val + "'");
} else {
(xfail_value(property, val, is_initial, false) ? todo_isnot : isnot)(
val_computed_n, initial_computed_n, "should not get initial value for '" + property + ":" + val + "' on elementn."); var swap = swap_when_frame(property, val);
(xfail_value(property, val, is_initial, true) ? todo_isnot : (swap ? is : isnot))(
val_computed_f, initial_computed_f, "should " + (swap ? "" : "not ") + "get initial value for '" + property + ":" + val + "' on elementf.");
}
if (is_initial)
gRule1.style.removeProperty(property);
gRule2.style.removeProperty(property);
if ("prerequisites" in info) { var prereqs = info.prerequisites;
for (var prereq in prereqs) {
gRule1.style.removeProperty(prereq);
gInitialPrereqsRuleN.style.removeProperty(prereq);
gInitialPrereqsRuleF.style.removeProperty(prereq);
}
}
if (info.inherited && is_initial) {
gElementN.parentNode.style.removeProperty(property);
gElementF.parentNode.style.removeProperty(property);
}
}
function test_property(prop) { var info = gCSSProperties[prop];
for (var idx in info.initial_values)
test_value(prop, info.initial_values[idx], true);
for (var idx in info.other_values)
test_value(prop, info.other_values[idx], false);
}
function run_tests() {
setup_initial_values("unstyledn", "gInitialValuesN", "gInitialPrereqsRuleN");
setup_initial_values("unstyledf", "gInitialValuesF", "gInitialPrereqsRuleF"); var props = [];
for (var prop in gCSSProperties)
props.push(prop);
props = props.reverse();
function do_one() {
if (props.length == 0) {
SimpleTest.finish();
return;
}
test_property(props.pop());
SimpleTest.executeSoon(do_one);
}
SimpleTest.executeSoon(do_one);
}
load_done();
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.28 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.