diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/base/test/test_bug116083.html | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_bug116083.html')
-rw-r--r-- | dom/base/test/test_bug116083.html | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/dom/base/test/test_bug116083.html b/dom/base/test/test_bug116083.html new file mode 100644 index 0000000000..cb7750bad3 --- /dev/null +++ b/dom/base/test/test_bug116083.html @@ -0,0 +1,126 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=116083 +--> +<head> + <title>Test for Bug 116083</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=116083">Mozilla Bug 116083</a> +<div id="content"> +<div style="white-space: pre">foo bar</div> +<div style="white-space: pre-wrap">foo bar</div> +<div style="white-space: pre-line">foo bar</div> +<div style="white-space: -moz-pre-space">foo bar</div> +<div style="white-space: pre" data-collapse-selection-to-child-and-extend>foo bar</div> +<div style="white-space: pre-wrap" data-collapse-selection-to-child-and-extend>foo bar</div> +<div style="white-space: pre-line" data-collapse-selection-to-child-and-extend>foo bar</div> +<div style="white-space: -moz-pre-space" data-collapse-selection-to-child-and-extend>foo bar</div> +<div data-result="bar baz"><span style="white-space: pre">bar </span>baz</div> +<div data-result="bar baz"><span style="white-space: pre-wrap">bar </span>baz</div> +<div data-result="bar baz"><span style="white-space: pre-line">bar </span>baz</div> +<div data-result="bar baz"><span style="white-space: -moz-pre-space">bar </span>baz</div> +<div data-result="foo bar ! baz" style="white-space: pre"><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: pre" contenteditable><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: pre-wrap"><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: pre-wrap" contenteditable><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: pre-line"><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: pre-line" contenteditable><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: -moz-pre-space"><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar ! baz" style="white-space: -moz-pre-space" contenteditable><div>foo </div><div> bar</div><div><br></div><div>!</div><div><br><br></div><div>baz</div></div> +<div data-result="foo bar baz qux"><div>foo<br></div><span>bar<br>baz<br>qux</span></div> +<div data-result="foo bar baz qux" contenteditable><div>foo<br></div><span>bar<br>baz<br>qux</span></div> +<div data-result="foo "><div>foo</div><span><br></span></div> +<div data-result="foo " contenteditable><div>foo</div><span><br></span></div> +<div data-result="foo bar"><div>foo</div><span><br></span><div>bar</div></div> +<div data-result="foo bar" contenteditable><div>foo</div><span><br></span><div>bar</div></div> +<div data-result="foo bar "><div>foo</div><span>bar<br></span></div> +<div data-result="foo bar" contenteditable><div>foo</div><span>bar<br></span></div> +<div data-result="foo bar baz"><div>foo</div><span>bar<br></span><div>baz</div></div> +<div data-result="foo bar baz" contenteditable><div>foo</div><span>bar<br></span><div>baz</div></div> +<div data-result=" foo"><div><br><br><div>foo</div></div></div> +<div data-result=" foo" contenteditable><div><br><br><div>foo</div></div></div> +<div data-result="foo bar"><div>foo<br>bar</div></div> +<div data-result="foo bar" contenteditable><div>foo<br>bar</div></div> +<div data-result="foo bar "><div>foo<br>bar<br></div></div> +<div data-result="foo bar" contenteditable><div>foo<br>bar<br></div></div> +<div data-result=" foo bar ">foo bar</div> +</div> +<script type="application/javascript"> + +const Cc = SpecialPowers.Cc; +const Ci = SpecialPowers.Ci; + +function hasExpectedFlavors() { + var cb = Cc["@mozilla.org/widget/clipboard;1"]. + getService(Ci.nsIClipboard); + + ok(cb.hasDataMatchingFlavors(["text/unicode"], cb.kGlobalClipboard), + "The clipboard has text/unicode"); + + // Android only supports plain text + if (!navigator.appVersion.includes("Android")) { + ok(cb.hasDataMatchingFlavors(["text/html"], cb.kGlobalClipboard), + "The clipboard has text/html"); + } + + if (navigator.appVersion.includes("Win")) { + ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], cb.kGlobalClipboard), + "The clipboard has application/x-moz-nativehtml"); + } +} + +function collapseSelectionToChildAndExtend(divElement) { + is(divElement.childNodes.length, 1, "Expected exactly one child node."); + var textChildNode = divElement.childNodes[0]; + getSelection().collapse(textChildNode); + getSelection().extend(textChildNode, divElement.textContent.length); +} + +function selectDependingOnAttributes(divElement) { + if (divElement.hasAttribute("data-collapse-selection-to-child-and-extend")) { + // Selecting text as follow comes closest to user behaviour. + collapseSelectionToChildAndExtend(divElement); + } else { + getSelection().selectAllChildren(divElement); + } +} + +function nextTest() { + var div = document.querySelector("#content>div"); + if (!div) { + SimpleTest.finish(); + return; + } + + selectDependingOnAttributes(div); + + var expected = div.hasAttribute("data-result") ? + div.getAttribute("data-result") : + div.textContent; + + SimpleTest.waitForClipboard(expected, function() { + synthesizeKey("C", {accelKey: true}); + }, function() { + ok(true, div.getAttribute("style") + " passed"); + hasExpectedFlavors(); + div.remove(); + nextTest(); + }, function() { + ok(false, "failed to copy the expected content to the clipboard"); + SimpleTest.finish(); + }); +} + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(function() { + SpecialPowers.pushPrefEnv({"set": [["clipboard.plainTextOnly", false]]}, nextTest); +}); + +</script> +</body> +</html> |