blob: a7f9ba5393fb2736a0e6ace7965f2ab1fb542654 [file] [log] [blame]
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<p>This tests caret movement across an iframe. The caret shouldn't enter the
iframe as the user arrows across it (unless we decide later that we want it to).
</p>
<div id="sample" contenteditable>
before
<iframe style="background-color: orange" width="100px" height="40px" srcdoc="foo"></iframe>
after
</div>
<div id="log"></div>
<script>
test(function() {
var selection = window.getSelection();
var sample = document.getElementById('sample');
selection.collapse(sample, 1);
selection.modify('move', 'forward', 'character');
var anchor = sample;
assert_equals(selection.anchorNode, anchor, 'anchorNode');
assert_equals(selection.anchorOffset, 2, 'anchorOffset');
assert_equals(selection.focusNode, anchor, 'focusNode');
assert_equals(selection.focusOffset, 2, 'focusOffset');
}, 'move forward character');
test(function() {
var selection = window.getSelection();
var sample = document.getElementById('sample');
selection.collapse(sample, 2);
selection.modify('move', 'backward', 'character');
var anchor = sample.firstChild;
assert_equals(selection.anchorNode, anchor, 'anchorNode');
assert_equals(selection.anchorOffset, 8, 'anchorOffset');
assert_equals(selection.focusNode, anchor, 'focusNode');
assert_equals(selection.focusOffset, 8, 'focusOffset');
}, 'move backward character');
</script>