Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 6 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /editing/whitespaces/chrome-compat/delete-to-join-blocks.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="flags" content="may">
<title>Testing normalizing white-space sequence after joining blocks</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../include/editor-test-utils.js"></script>
<script>
"use strict";
addEventListener("DOMContentLoaded", () => {
// README:
// These tests based on the behavior of Chrome 134. This test does NOT define
// nor suggest any standard behavior (actually, some expected results might
// look odd), but this test must help you to understand how other browsers
// use different logic to normalize white-space sequence.
const editingHost = document.querySelector("div[contenteditable]");
const utils = new EditorTestUtils(editingHost);
async function addPromiseTest(aInitHTML, aExpectedHTML) {
promise_test(async () => {
utils.setupEditingHost(aInitHTML);
document.execCommand("delete");
assert_equals(editingHost.innerHTML, aExpectedHTML);
}, `document.execCommand("delete") when "${aInitHTML}"`);
}
// Join sibling blocks.
addPromiseTest(
`<div> </div><div>{}<br></div>`,
`<div> </div>`
);
addPromiseTest(
`<div>a </div><div>{}<br></div>`,
`<div>a </div>`
);
addPromiseTest(
`<div><br></div><div>[] </div>`,
`<div> </div>`
);
addPromiseTest(
`<div><br></div><div>[] b</div>`,
`<div> b</div>`
);
addPromiseTest(
`<div>a</div><div>[] b</div>`,
`<div>a b</div>`
);
addPromiseTest(
`<div>a </div><div>[] b</div>`,
`<div>a b</div>`
);
// Join child block with its parent block.
addPromiseTest(
`<div> <div>{}<br></div></div>`,
`<div> </div>`
);
addPromiseTest(
`<div>a <div>{}<br></div></div>`,
`<div>a </div>`
);
addPromiseTest(
`<div><br><div>[] </div></div>`,
`<div><div> </div></div>`
);
addPromiseTest(
`<div><br><div>[] b</div></div>`,
`<div><div> b</div></div>`
);
addPromiseTest(
`<div>a<div>[] b</div></div>`,
`a b`
);
addPromiseTest(
`<div>a <div>[] b</div></div>`,
`a b`
);
// Join parent block with a child block.
addPromiseTest(
`<div><div> </div>{}<br></div>`,
`<div><div> </div></div>`
);
addPromiseTest(
`<div><div>a </div>{}<br></div>`,
`<div><div>a </div></div>`
);
addPromiseTest(
`<div><div><br></div>[] </div>`,
`<div> </div>`
);
addPromiseTest(
`<div><div><br></div>[] b</div>`,
`<div> b</div>`
);
addPromiseTest(
`<div><div>a</div>[] b</div>`,
`<div>a b</div>`
);
addPromiseTest(
`<div><div>a </div>[] b</div>`,
`<div>a b</div>`
);
}, {once: true});
</script>
</head>
<body>
<div contenteditable></div>
</body>
</html>