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

Unified Diff: chrome/renderer/resources/extensions/automation_custom_bindings.js

Issue 1365433002: Add setSelection function to automation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nobrailleautostartintests
Patch Set: Change setDocumentSelection to take named arguments. Created 5 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
Index: chrome/renderer/resources/extensions/automation_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/automation_custom_bindings.js b/chrome/renderer/resources/extensions/automation_custom_bindings.js
index ae84e27949fd3baaca5a8ab0f0819b402a5ebc7e..508951610a5afbca8f1b6457f60e599dd9fc3038 100644
--- a/chrome/renderer/resources/extensions/automation_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/automation_custom_bindings.js
@@ -127,6 +127,23 @@ automation.registerCustomHook(function(bindingsAPI) {
addTreeChangeObserver(observer);
});
+ apiFunctions.setHandleRequest('setDocumentSelection', function(params) {
+ var anchorNodeImpl = privates(params.anchorObject).impl;
+ var focusNodeImpl = privates(params.focusObject).impl;
+ if (anchorNodeImpl.treeID !== focusNodeImpl.treeID)
+ throw new Error('Selection anchor and focus must be in the same tree.');
+ if (anchorNodeImpl.treeID === DESKTOP_TREE_ID) {
+ throw new Error('Use AutomationNode.setSelection to set the selection ' +
+ 'in the desktop tree.');
+ }
+ automationInternal.performAction({ treeID: anchorNodeImpl.treeID,
+ automationNodeID: anchorNodeImpl.id,
+ actionType: 'setSelection'},
+ { focusNodeID: focusNodeImpl.id,
+ anchorOffset: params.anchorOffset,
+ focusOffset: params.focusOffset });
+ });
+
});
automationInternal.onTreeChange.addListener(function(treeID,

Powered by Google App Engine
This is Rietveld 408576698