Commit 6269bf67 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize selection_test() in editing/execCommand/execCommand/forward-delete-no-scroll.html

This patch changes "execCommand/forward-delete-no-scroll.html" to utilize
|selection_test()| for ease of maintenance and help to implementing EditingNG.

Bug: 707656, 679977
Change-Id: Ia3f5aa974cffc9665b2074e812304b4ba9d428ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208845
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770508}
parent 93234594
Matching other execCommand identifiers, execCommand("ForwardDelete") should not scroll the page to make selection visible.
This test only works in WebKit, as other engines do not implement this command.
SUCCESS
<p>Matching other execCommand identifiers, execCommand("ForwardDelete") should not scroll the page to make selection visible.</p>
<p>This test only works in WebKit, as other engines do not implement this command.</p>
<div contenteditable>a</div>
<div style="height:10000"></div>
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
var text = document.getElementsByTagName('div')[0].firstChild;
window.getSelection().setBaseAndExtent(text, 0, text, 0);
window.scrollTo(0, 1000);
document.execCommand("ForwardDelete");
var result = (window.pageYOffset == 1000) ? "SUCCESS" : "FAILURE";
if (window.testRunner) {
testRunner.dumpAsText();
document.write(result);
} else
alert(result);
// Matching other execCommand identifiers, execCommand("ForwardDelete") should
// not scroll the page to make selection visible.
selection_test(
[
'<div contenteditable>a|x</div>',
'<div style="height:10000"></div>',
],
selection => {
if (!selection.document.queryCommandEnabled('ForwardDelete'))
throw 'This test requires "ForwardDelete" command.';
selection.window.scrollTo(0, 1000);
const pageYOffset = selection.window.pageYOffset;
selection.document.execCommand('ForwardDelete');
assert_equals(selection.window.pageYOffset, 1000, 'window.pageYOffset');
},
[
'<div contenteditable>a|</div>',
'<div style="height:10000"></div>',
]);
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment