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

Unified Diff: third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js

Issue 2709983005: Selection API: Do not change focus by Selection functions. (Closed)
Patch Set: . Created 3 years, 10 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
Index: third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
diff --git a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
index 67bb9c670145c080b9f113a3f0459ce422f7d6dd..197c23647238fc1814a2a4b452d59c97d20f41b4 100644
--- a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
+++ b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
@@ -322,6 +322,16 @@ function verifyMarkers(
}
}
+function focusNearestAncestorOfAnchor(selection) {
+ for (var anchor = selection.anchorNode; anchor; anchor = anchor.parentNode) {
+ if (anchor.nodeType != Node.ELEMENT_NODE)
+ continue;
+ anchor.focus();
+ if (anchor.ownerDocument.activeElement == anchor)
+ return;
+ }
+}
+
// Spellchecker gets triggered not only by text and selection change, but also
// by focus change. For example, misspelling markers in <INPUT> disappear when
// the window loses focus, even though the selection does not change.
@@ -349,6 +359,7 @@ function invokeSpellcheckTest(testObject, input, tester, expectedText) {
/** @type {!Sample} */
const sample = typeof(input) === 'string' ? new Sample(input) : input;
testObject.sample = sample;
+ focusNearestAncestorOfAnchor(sample.selection);
if (typeof(tester) === 'function') {
tester.call(window, sample.document);

Powered by Google App Engine
This is Rietveld 408576698