blob: 75843ababcb3441701a2a66a5292fbba43ffe0ac [file] [log] [blame]
<body>
<div id="test" style="font-size:16px;zoom:200%;">Copy this 16px text.</div>
<div id="target" contentEditable style="zoom:200%; border:1px solid">Paste it here.</div>
<div>The pasted text should have a font size of 16px.</div>
<br /><br />
<div id="test2" style="font-size:x-small;zoom:200%;">Copy this x-small text.</div>
<div id="target2" contentEditable style="zoom:150%; border:1px solid">Paste it here.</div>
<div>The pasted text should have a font size of x-small.</div>
<br /><br />
<div id="results">FAIL (this test requires DRT)<div>
</body>
<script src="../editing.js"></script>
<script>
function editingTest()
{
for (var i = 0; i < 4; ++i)
execExtendSelectionForwardByWordCommand();
execCopyCommand();
var elem = document.getElementById("target");
var selection = window.getSelection();
selection.collapse(elem, 0);
execMoveSelectionForwardByWordCommand();
execPasteCommand();
if (document.getElementById("target").innerHTML.toString().indexOf("font-size: 16px") == -1)
throw "absolute font size is wrong";
// Make sure relative font sizes are not adjusted.
var elem = document.getElementById("test2");
var selection = window.getSelection();
selection.collapse(elem, 0);
for (var i = 0; i < 5; ++i) // One additional extend needed to account for punctuation
execExtendSelectionForwardByWordCommand();
execCopyCommand();
var elem = document.getElementById("target2");
var selection = window.getSelection();
selection.collapse(elem, 0);
execMoveSelectionForwardByWordCommand();
execPasteCommand();
if (document.getElementById("target2").innerHTML.toString().indexOf("font-size: x-small") == -1)
throw "relative font size not preserved";
document.getElementById("results").innerText = "PASS";
}
runDumpAsTextEditingTest(false);
</script>