2014-12-01 14:38:11 +03:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=116083
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 116083</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" 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>
|
2014-12-19 20:45:50 +03:00
|
|
|
<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>
|
2015-01-18 01:31:59 +03:00
|
|
|
<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>
|
2015-05-11 20:36:56 +03:00
|
|
|
<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>
|
2014-12-01 14:38:11 +03:00
|
|
|
<div data-result=" foo bar ">foo bar</div>
|
|
|
|
</div>
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
2015-04-09 16:55:48 +03:00
|
|
|
const Cc = SpecialPowers.Cc;
|
|
|
|
const Ci = SpecialPowers.Ci;
|
|
|
|
|
|
|
|
function hasExpectedFlavors() {
|
|
|
|
var cb = Cc["@mozilla.org/widget/clipboard;1"].
|
|
|
|
getService(Ci.nsIClipboard);
|
2016-05-11 17:04:19 +03:00
|
|
|
|
|
|
|
ok(cb.hasDataMatchingFlavors(["text/unicode"], 1, cb.kGlobalClipboard),
|
|
|
|
"The clipboard has text/unicode");
|
|
|
|
|
|
|
|
// Android only supports plain text
|
2018-02-01 22:45:22 +03:00
|
|
|
if (!navigator.appVersion.includes("Android")) {
|
2016-05-11 17:04:19 +03:00
|
|
|
ok(cb.hasDataMatchingFlavors(["text/html"], 1, cb.kGlobalClipboard),
|
|
|
|
"The clipboard has text/html");
|
|
|
|
}
|
|
|
|
|
2018-02-01 22:45:22 +03:00
|
|
|
if (navigator.appVersion.includes("Win")) {
|
2016-05-11 17:04:19 +03:00
|
|
|
ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], 1, cb.kGlobalClipboard),
|
|
|
|
"The clipboard has application/x-moz-nativehtml");
|
|
|
|
}
|
2015-04-09 16:55:48 +03:00
|
|
|
}
|
|
|
|
|
2015-10-02 01:26:00 +03:00
|
|
|
function nextTest() {
|
2014-12-01 14:38:11 +03:00
|
|
|
var div = document.querySelector("#content>div");
|
|
|
|
if (!div) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
getSelection().selectAllChildren(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");
|
2016-05-11 17:04:19 +03:00
|
|
|
hasExpectedFlavors();
|
2017-01-30 10:10:22 +03:00
|
|
|
div.remove();
|
2014-12-01 14:38:11 +03:00
|
|
|
nextTest();
|
|
|
|
}, function() {
|
|
|
|
ok(false, "failed to copy the expected content to the clipboard");
|
|
|
|
SimpleTest.finish();
|
|
|
|
});
|
2015-10-02 01:26:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SimpleTest.waitForFocus(function() {
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["clipboard.plainTextOnly", false]]}, nextTest);
|
2014-12-01 14:38:11 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|