Text padded using editor-generated pattern.
- Consecutive non-breaking spaces: " "
</div>
<!-- In non-editable HTML nodes, like this paragraph, copying to clipboard should preserve non-breaking spaces.
However, HTML editors programmatically insert a alternating pattern of space / NBSP when padding text with spaces
(otherwises spaces would be collapsed).
These programmatically-generated NBSPs should be replaced by plain spaces when copying to plain-text.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1769534
<!-- In non-editable HTML nodes, like this paragraph, copying to clipboard should preserve non-breaking
spaces.
However, for compatibility with what other browsers currently do, the behavior of replacing non-breaking spaces by spaces is preserved for now.
See https://bugzilla.mozilla.org/show_bug.cgi?id=359303#c145
-->
<pid="paragraph-with-non-breaking-spaces">
Paragraph content:
- This town is 100 km away.
- « Est-ce Paris ? »
- Consecutive non-breaking spaces: ' '
Text padded using editor-generated pattern.
- Consecutive non-breaking spaces: " "
</p>
</div>
@ -93,40 +84,28 @@ async function clipboardTextForElementId(aDomId, aExpectedString) {
return copiedText;
}
function assertUserNbspPreserved(aCopiedText) {
ok(aCopiedText.includes("100km"), "NBSP between two characters should be preserved");
ok(aCopiedText.includes("« "), "A single NBSP near a punctuation mark should be preserved");
ok(aCopiedText.includes(" »"), "A single NBSP near a punctuation mark should be preserved");
ok(aCopiedText.includes("?"), "NBSPs before *and* after a character should be preserved");
ok(aCopiedText.includes("''"), "Consecutive NBSPs should be preserved");
}
function assertEditorGeneratedNbspPreserved(aCopiedText) {
ok(aCopiedText.includes(" Text padded"), "When copying from a plain-text control, editor-generated NBSP (if any) should be preserved");
}
function assertEditorGeneratedNbspReplaced(aCopiedText) {
ok(aCopiedText.includes(" Text padded"), "When copying plain-text from a non plain-text control, editor-generated NBSP should be replaced by standard spaces");
}
/** Test for Bug 359303 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
let textCopiedFromInput = await clipboardTextForElementId("input-with-non-breaking-spaces", "Input");