Skip to content

Commit

Permalink
[LayoutNG] Simplify a failing continuations-with-move-caret-to-bounda…
Browse files Browse the repository at this point in the history
…ry.html.

This patch simplifies the tests that confirms text selection upon drag
selects differently on mac.
I will move the test to selection/mouse.

Bug: 811502, 866120
Change-Id: Id9bb292236b709b65a98be1eff3fc778da02264b
Reviewed-on: https://chromium-review.googlesource.com/1163348
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581139}
  • Loading branch information
Yoichi Osato authored and Commit Bot committed Aug 7, 2018
1 parent 4f08052 commit 3be6290
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 204 deletions.
Original file line number Diff line number Diff line change
@@ -1,105 +1,46 @@
<!DOCTYPE HTML>
<script src="../../resources/ahem.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Mac supports the 'moveCaretToBoundary' editing behavior.
if (window.internals)
internals.settings.setEditingBehavior('mac');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<div>BLOCK</div><p>BBBBB</p><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop + 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<div>BLOCK</div><p>BBBBB</p><p id="secondP">CC|CCC</p></font>'),
'Continuations across a block when not hitting the margin');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<p>BBBBB</p><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop - 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<p>BBBBB</p><p id="secondP">|CCCCC</p></font>'),
'Continuation margin');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<div>BLOCK</div><p>BBBBB</p><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop - 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<div>BLOCK</div><p>BBBBB</p><p id="secondP">|CCCCC</p></font>'),
'Continuation margin across a block 1');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<p>BBBBB</p><div>BLOCK</div><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop - 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<p>BBBBB</p><div>BLOCK</div><p id="secondP">|CCCCC</p></font>'),
'Continuation margin across a block 2');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<div style="position: relative; margin-top: 50px;">BLOCK</div><p>BBBBB</p><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop - 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<div style="position: relative; margin-top: 50px;">BLOCK</div><p>BBBBB</p><p id="secondP">|CCCCC</p></font>'),
'Continuation margin across a relative block 1');

test(() =>
assert_selection(
'<font color="blue" id="font">|AAAAA<p>BBBBB</p><div style="position: relative; margin-top: 50px;">BLOCK</div><p id="secondP">CCCCC</p></font>',
selection => {
var document = selection.document;
var font = document.getElementById('font');
var secondP = document.getElementById('secondP');

eventSender.mouseMoveTo(document.offsetLeft + font.offsetLeft, document.offsetTop + font.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + secondP.offsetLeft + 20, document.offsetTop + secondP.offsetTop - 5);
eventSender.mouseUp();
},
'<font color="blue" id="font">^AAAAA<p>BBBBB</p><div style="position: relative; margin-top: 50px;">BLOCK</div><p id="secondP">|CCCCC</p></font>'),
'Continuation margin across a relative block 2');
const isMac = navigator.platform.indexOf('Mac') === 0;

function dragOverBlocks(selection, offsetTopToDestination) {
const document = selection.document;
const divlist = document.querySelectorAll('p');
const div0 = divlist[0];
const div1 = divlist[1];
eventSender.mouseMoveTo(document.offsetLeft + div0.offsetLeft,
document.offsetTop + div0.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseMoveTo(document.offsetLeft + div1.offsetLeft + 40,
document.offsetTop + div1.offsetTop
+ offsetTopToDestination);
eventSender.mouseUp();
}

const kStyle = '<style>* { font: 20px Ahem; }</style>';

selection_test(
[kStyle, '<p>AAAAA</p><p>BBBBB</p>'],
selection => dragOverBlocks(selection, -20),
[kStyle, '<p>^AA|AAA</p><p>BBBBB</p>'],
'Continuations across a block -20');

selection_test(
[kStyle, '<p>AAAAA</p><p>BBBBB</p>'],
selection => dragOverBlocks(selection, -15),
[kStyle,
isMac
? '<p>^AAAAA</p><p>|BBBBB</p>'
: '<p>^AAAAA</p><p>BB|BBB</p>'
],
'Continuations across a block -15');

selection_test(
[kStyle, '<p>AAAAA</p><p>BBBBB</p>'],
selection => dragOverBlocks(selection, 5),
[kStyle,'<p>^AAAAA</p><p>BB|BBB</p>'],
'Continuations across a block 5');
</script>

This file was deleted.

0 comments on commit 3be6290

Please sign in to comment.