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

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: rebase Created 5 years, 3 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..31816022648b797909daa421667d5ede7b5094b8 100644
--- a/chrome/renderer/resources/extensions/automation_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/automation_custom_bindings.js
@@ -127,6 +127,27 @@ automation.registerCustomHook(function(bindingsAPI) {
addTreeChangeObserver(observer);
});
+ apiFunctions.setHandleRequest('setSelection', function(anchorNode,
+ anchorOffset,
+ focusNode,
+ focusOffset) {
+ var anchorNodeImpl = privates(anchorNode).impl;
+ var focusNodeImpl = privates(focusNode).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 &&
+ (anchorNodeImpl.id !== focusNodeImpl.id)) {
David Tseng 2015/09/23 19:10:42 Also, forgot to add that I think this API should j
+ throw new Error(
+ 'Selections in the desktop tree must be within the same node');
+ }
+ automationInternal.performAction({ treeID: anchorNodeImpl.treeID,
+ automationNodeID: anchorNodeImpl.id,
+ actionType: 'setSelection'},
+ { focusNodeID: focusNodeImpl.id,
+ anchorOffset: anchorOffset,
+ focusOffset: focusOffset });
+ });
+
});
automationInternal.onTreeChange.addListener(function(treeID,

Powered by Google App Engine
This is Rietveld 408576698