| Index: chrome/test/data/extensions/api_test/automation/tests/tabs/document_selection.js
|
| diff --git a/chrome/test/data/extensions/api_test/automation/tests/tabs/document_selection.js b/chrome/test/data/extensions/api_test/automation/tests/tabs/document_selection.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..76d9bf12d24052fea4d975acc35336ccb96e4797
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/automation/tests/tabs/document_selection.js
|
| @@ -0,0 +1,60 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var EventType = chrome.automation.EventType;
|
| +var RoleType = chrome.automation.RoleType;
|
| +var html = "<head><title>testdoc</title></head>" +
|
| + '<p>para1</p><input type="text" id="textField" value="hello world">';
|
| +
|
| +var allTests = [
|
| + function testInitialSelectionNotSet() {
|
| + assertEq(undefined, rootNode.anchorObject);
|
| + assertEq(undefined, rootNode.anchorOffset);
|
| + assertEq(undefined, rootNode.focusObject);
|
| + assertEq(undefined, rootNode.focusOffset);
|
| + chrome.test.succeed();
|
| + },
|
| +
|
| + function selectOutsideTextField() {
|
| + var textNode = rootNode.find({role: RoleType.paragraph}).firstChild;
|
| + assertTrue(!!textNode);
|
| + chrome.automation.setDocumentSelection(textNode, 0, textNode, 3);
|
| + listenOnce(rootNode, EventType.textSelectionChanged, function(evt) {
|
| + assertEq(textNode, rootNode.anchorObject);
|
| + assertEq(0, rootNode.anchorOffset);
|
| + assertEq(textNode, rootNode.focusObject);
|
| + assertEq(3, rootNode.focusOffset);
|
| + chrome.test.succeed();
|
| + });
|
| + },
|
| +
|
| + function selectInTextField() {
|
| + var textField = rootNode.find({role: RoleType.textField});
|
| + assertTrue(!!textField);
|
| + textField.focus();
|
| + listenOnce(rootNode, EventType.textSelectionChanged, function(evt) {
|
| + assertTrue(evt.target === rootNode || evt.target === textField);
|
| + assertEq(textField, rootNode.anchorObject);
|
| + assertEq(0, rootNode.anchorOffset);
|
| + assertEq(textField, rootNode.focusObject);
|
| + assertEq(0, rootNode.focusOffset);
|
| + // Wait for another text selection change event. There's one for
|
| + // the document root and one for the text field.
|
| + listenOnce(rootNode, EventType.textSelectionChanged, function() {
|
| + assertTrue(evt.target === rootNode || evt.target === textField);
|
| + assertTrue(evt.target === rootNode || evt.target === textField);
|
| + chrome.automation.setDocumentSelection(textField, 1, textField, 3);
|
| + listenOnce(rootNode, EventType.textSelectionChanged, function(evt) {
|
| + assertEq(textField, rootNode.anchorObject);
|
| + assertEq(1, rootNode.anchorOffset);
|
| + assertEq(textField, rootNode.focusObject);
|
| + assertEq(3, rootNode.focusOffset);
|
| + chrome.test.succeed();
|
| + });
|
| + });
|
| + });
|
| + },
|
| +];
|
| +
|
| +setUpAndRunTests(allTests, 'document_selection.html');
|
|
|