blob: 896f43f70375e7ddc634d55e124afcfac98f1fb1 [file] [log] [blame]
<script>
if (window.testRunner) {
window.testRunner.dumpAsText();
window.testRunner.waitUntilDone();
}
function verifyResults(inputElement, selectedText) {
if (document.activeElement != inputElement) {
document.body.innerHTML = "FAIL (text field was not selected)";
return;
}
if (frames[0].getSelection().toString() != selectedText) {
document.body.innerHTML = "FAIL (unexpected selection)";
return;
}
document.body.innerHTML = "PASS";
}
function runTest() {
var textToSelect = "This text should be selected, but this frame shouldn't be focused.";
frame = frames[0];
frame.focus();
s = frame.getSelection();
s.setPosition(frame.document.body, 0);
frame.document.execCommand("InsertText", false, textToSelect);
frame.document.execCommand("SelectAll");
var inputElement = document.getElementById("input");
inputElement.focus();
verifyResults(inputElement, textToSelect);
if (window.testRunner)
window.testRunner.notifyDone();
}
</script>
<p>This tests to make sure that a selection in one frame isn't cleared when focusing a node in a different frame.</p>
<iframe border="1" src="../resources/contenteditable-iframe-src.html" onload="runTest();"></iframe><br>
<input type="text" id="input" value="This text field should be focused." size="30">