<!doctypehtml>
<meta charset="utf-8">
<title>
Test for bug 1850834: Replacing the contents of a table should reframe the same amount, regardless of whether it's in an IB split.
</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<div id="content"> <!-- Reference case: Table as child of block-level element -->
<div>
<table id="tableInBlock"></table>
</div> <!-- Test case: Table as child of inline-level element (forming IB split) -->
<span>
aaa
<table id="tableInIBSplit"></table>
bbb
</span>
</div>
<script>
const utils = SpecialPowers.getDOMWindowUtils(window);
/*
* This utility function invokes callbackFunc(callbackArg) and returns the
* number of frames that are reconstructed in the process.
*/
function countReframesForTweak(callbackFunc, callbackArg) {
document.documentElement.offsetTop;
const previousConstructCount = utils.framesConstructed;
/*
* Helper for expectSameReframesForTweak, to reduce boilerplate.
* Sets the provided innerHTML in both tables, and then performs the
* dynamic-modification-callback on both tables, and asserts that the
* frame construction counts match.
*/
function testWithInitialTableContent(callbackFunc, startingInnerHTML, message) {
tableInBlock.innerHTML = tableInIBSplit.innerHTML = startingInnerHTML;
let actual = countReframesForTweak(callbackFunc, tableInIBSplit);
let expected = countReframesForTweak(callbackFunc, tableInBlock);
is(actual, expected, message);
}
/*
* This utility function runs the provided callback function for both of the
* tables, from various starting-conditions. In each case, we check that
* the number of frames that are reconstructed is the same, between the
* two tables.
*/
function expectSameReframesForTweak(callbackFunc, message) {
testWithInitialTableContent(callbackFunc, "", /* <-- empty string */
`${message} (starting with empty table)`);
testWithInitialTableContent(callbackFunc, " ", /* <-- two space chars */
`${message} (starting with ` +
`empty-aside-from-whitespace table)`);
testWithInitialTableContent(callbackFunc, "Some text",
`${message} (starting with text node child)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with empty caption)`);
testWithInitialTableContent(callbackFunc, "",
`${message} (starting with empty tbody)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with empty tr)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with empty td)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with an empty col)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with an empty colgroup)`);
testWithInitialTableContent(callbackFunc, "
",
`${message} (starting with a colgroup/col)`);
testWithInitialTableContent(callbackFunc, "
Contents
",
`${message} (starting with full subtree)`);
}
// The actual test logic begins here!
// We invoke expectSameReframesForTweak to compare reframe counts between our
// two tables, for various types of dynamic modifications:
expectSameReframesForTweak((elem)=> { elem.textContent = ""; }, "Reframe count should be the same when clearing table.textContent"
);
expectSameReframesForTweak((elem)=> { elem.textContent = " "; }, "Reframe count should be the same when setting table.textContent to a space"
);
expectSameReframesForTweak((elem)=> { elem.textContent = "modified"; }, "Reframe count should be the same when setting table.textContent");
"; }, "Reframe count should be the same when setting table.innerHTML to " + "table subtree with full hierarchy specified, including a caption");
expectSameReframesForTweak(
(elem) => { elem.innerHTML = "just a tbody"; }, "Reframe count should be the same when setting table.innerHTML to " + "just a tbody");
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.