Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/WebKit/LayoutTests/editing/spelling/context_click_select_misspelling.html

Issue 2456473002: Convert input-type-text.html with spellcheck_test (Closed)
Patch Set: Thu Oct 27 11:36:46 JST 2016 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/input-type-text.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/spelling/context_click_select_misspelling.html
diff --git a/third_party/WebKit/LayoutTests/editing/spelling/context_click_select_misspelling.html b/third_party/WebKit/LayoutTests/editing/spelling/context_click_select_misspelling.html
new file mode 100644
index 0000000000000000000000000000000000000000..3be66c833fe0254696b04bfae4f352ce249062cd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/editing/spelling/context_click_select_misspelling.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
+<script src="spellcheck_test.js"></script>
+
+<script>
+test(() => assert_not_equals(window.internals, undefined),
+ 'This test requires internals to set editing behavior.');
+
+test(() => assert_not_equals(window.eventSender, undefined),
+ 'This test requires event sender to simulate keyboard and mouse actions.');
+
+function assertContextClickSelection(input, offsetX, expected) {
+ const document = input.ownerDocument;
+ const x = document.offsetLeft + input.offsetLeft + offsetX;
+ const y = document.offsetTop + input.offsetTop + input.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ eventSender.contextClick();
+
+ // Esc key to hide the context menu.
+ eventSender.keyDown('Escape', null);
+
+ assert_equals(document.getSelection().toString(), expected);
+}
+
+function getTextWidth(input) {
+ const shadowRoot = internals.shadowRoot(input);
+ const innerEditor = shadowRoot.firstChild;
+ const text = innerEditor.firstChild;
+ const range = input.ownerDocument.createRange();
+ range.selectNode(text);
+ return range.getClientRects()[0].width;
+}
+
+function contextClickSelectionTests(input) {
+ const textWidth = getTextWidth(input);
+
+ // There seems to be some bug with testharness.js that, if the first test
+ // completes before the next two tests start, the whole testharness is
+ // considered as ran to complete and the subsequent tests are not evaluated.
+ // Hence, we use async_test and defer the completion as a workaround.
+ const heldTest = async_test(
+ () => assertContextClickSelection(input, textWidth / 4, 'wellcome'),
+ 'Context clicking "wellcome" selects the misspelled word');
+
+ ['Win', 'Unix', 'Android', 'Mac'].forEach(platform => {
+ internals.settings.setEditingBehavior(platform);
+ const shouldSelect = platform === 'Mac';
+ test(() => assertContextClickSelection(input, textWidth * 3 / 4,
+ shouldSelect ? 'home' : ''),
+ 'Context clicking "home" ' +
+ `${shouldSelect ? 'selects' : 'does not select'} ` +
+ `the correctly spelled word on ${platform}`);
+ })
+
+ heldTest.done();
+}
+
+spellcheck_test(
+ '<input type="text" value="wellcome home.">',
+ document => document.querySelector('input').focus(),
+ '<input type="text" value="_wellcome_ home.">',
+ {
+ title: 'Mark misspelling in the initial text of an input field.',
+ callback: sample => contextClickSelectionTests(
+ sample.document.querySelector('input'))
+ });
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/input-type-text.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698