/** Test for Bug 696253 **/
/* (Testing the 'flex' CSS shorthand property) */
// The CSS property name for the shorthand we're testing:
const gFlexPropName = "flex";
// Info from property_database.js on this property:
const gFlexPropInfo = gCSSProperties[gFlexPropName];
// The name of the property in the DOM (i.e. in elem.style):
// (NOTE: In this case it's actually the same as the CSS property name --
// "flex" -- but that's not guaranteed in general.)
const gFlexDOMName = gFlexPropInfo.domProp;
// Default values for shorthand subproperties, when they're not specified
// explicitly in a testcase. This lets the testcases be more concise.
//
// The values here are from the flexbox spec on the 'flex' shorthand:
// "When omitted, [flex-grow and flex-shrink are] set to '1'."
// "When omitted [..., flex-basis's] specified value is '0%'."
let gFlexShorthandDefaults = { "flex-grow": "1", "flex-shrink": "1", "flex-basis": "0%"
};
let gFlexShorthandTestcases = [
/*
{ "flex": "SPECIFIED value for flex shorthand",
// Expected Computed Values of Subproperties
// Semi-optional -- if unspecified, the expected value is taken
// from gFlexShorthandDefaults. "flex-grow": "EXPECTED computed value for flex-grow property", "flex-shrink": "EXPECTED computed value for flex-shrink property", "flex-basis": "EXPECTED computed value for flex-basis property",
},
*/
// Initial values of subproperties:
// --------------------------------
// (checked by another test that uses property_database.js, too, but
// might as well check here, too, for thoroughness).
{ "flex": "", "flex-grow": "0", "flex-shrink": "1", "flex-basis": "auto",
},
{ "flex": "initial", "flex-grow": "0", "flex-shrink": "1", "flex-basis": "auto",
},
gFlexPropInfo.subproperties.forEach(function(aSubPropName) { var expectedVal = aSubPropName in aFlexShorthandTestcase ?
aFlexShorthandTestcase[aSubPropName] :
gFlexShorthandDefaults[aSubPropName];
// Compare computed value against expected computed value (from testcase)
is(window.getComputedStyle(elem).getPropertyValue(aSubPropName),
expectedVal, "Computed value of subproperty \"" + aSubPropName + "\" when we set \"" +
gFlexPropName + ": " + aFlexShorthandTestcase[gFlexPropName] + "\"");
});
// Clean up
content.removeChild(elem);
}
function main() {
gFlexShorthandTestcases.forEach(runFlexShorthandTest);
}
main();
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.25 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.