/* This testcase ensures that we honor the "order" property when ordering
* flex items within a flex container.
*
* Note: The items in this testcase don't overlap, so this testcase does _not_
* test paint ordering. It only tests horizontal ordering in a flex container.
*/
// DATA
// ----
// This will store snapshots of our reference divs
let gRefSnapshots = {};
// These are the sets of 'order' values that we'll test.
// * The first three values in each array are the 'order' values that we'll
// assign to elements a, b, and c (respectively).
// * The next value is a string containing the concatenated IDs of any
// elements that should be absolutely positioned.
// * The final value in each array is the ID of the expected reference
// rendering. (By convention, in those IDs, capital = abspos) var gOrderTestcases = [
// Just one child is abspos:
[ 1, 2, 3, "a", "Abc"],
[ 1, 2, 3, "b", "Bac"],
[ 1, 2, 3, "c", "Cab"],
[ 2, 3, 1, "b", "Bca"],
[ 3, 1, 1, "b", "Bca"],
// Two children are abspos:
// (Note: "order" doesn't influence position or paint order for abspos
// children - only for (in-flow) flex items.)
[ 1, 2, 3, "ab", "ABc"],
[ 2, 1, 3, "ab", "ABc"],
[ 1, 2, 3, "ac", "ACb"],
[ 3, 2, 1, "ac", "ACb"],
[ 3, 2, 1, "bc", "BCa"],
// All three children are abspos:
// (Rendering always the same regardless of "order" values)
[ 1, 2, 3, "abc", "ABC"],
[ 3, 1, 2, "abc", "ABC"],
[ 3, 2, 1, "abc", "ABC"],
];
// FUNCTIONS
// ---------
function initRefSnapshots() {
let refIds = ["abc", "Abc", "Bac", "Bca", "Cab", "ABc", "ACb", "BCa", "ABC"];
for (let id of refIds) {
let elem = document.getElementById(id);
elem.style.display = "block";
gRefSnapshots[id] = snapshotWindow(window, false);
elem.style.display = "";
}
}
function complainIfSnapshotsDiffer(aSnap1, aSnap2, aMsg) {
let compareResult = compareSnapshots(aSnap1, aSnap2, true);
ok(compareResult[0], "flex container rendering should match expected (" + aMsg +")");
if (!compareResult[0]) {
todo(false, "TESTCASE: " + compareResult[1]);
todo(false, "REFERENCE: "+ compareResult[2]);
}
}
function runOrderTestcase(aOrderTestcase) {
// Sanity-check
ok(Array.isArray(aOrderTestcase), "expecting testcase to be an array");
is(aOrderTestcase.length, 5, "expecting testcase to have 5 elements");
let idsToMakeAbspos = aOrderTestcase[3].split("");
for (let absPosId of idsToMakeAbspos) {
document.getElementById(absPosId).classList.add("abs");
}
let snapshot = snapshotWindow(window, false);
complainIfSnapshotsDiffer(snapshot, gRefSnapshots[aOrderTestcase[4]],
aOrderTestcase);
// Clean up
for (let id of ["a", "b", "c"]) {
document.getElementById(id).style.order = "";
document.getElementById(id).classList.remove("abs");
}
}
// Main Function
function main() {
initRefSnapshots();
// un-hide the flex container's parent
let flexContainerParent = document.getElementById("flexContainerParent");
flexContainerParent.style.display = "block";
// Initial sanity-check: should be in expected document order
let initialSnapshot = snapshotWindow(window, false);
complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots.abc, "initial flex container rendering, " + "no 'order' value yet");
// OK, now we run our tests
gOrderTestcases.forEach(runOrderTestcase);
// Re-hide the flex container at the end
flexContainerParent.style.display = "";
}
main();
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.27 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.