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

Unified Diff: chrome/test/data/extensions/api_test/automation/tests/desktop/common.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/test/data/extensions/api_test/automation/tests/desktop/common.js
diff --git a/chrome/test/data/extensions/api_test/automation/tests/desktop/common.js b/chrome/test/data/extensions/api_test/automation/tests/desktop/common.js
index a793d659dc5fb850a4c58f107dac8b69ce315e04..e8c607eb313c124fc15eef64e58143353f07381b 100644
--- a/chrome/test/data/extensions/api_test/automation/tests/desktop/common.js
+++ b/chrome/test/data/extensions/api_test/automation/tests/desktop/common.js
@@ -34,37 +34,23 @@ function runWithDocument(docString, callback) {
chrome.tabs.create(createParams, function(tab) {
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (tabId == tab.id && changeInfo.status == 'complete') {
- if (callback)
- callback();
+ chrome.automation.getTree(tab.id, callback);
}
});
});
}
-function setupAndRunTests(allTests, opt_docString) {
- function runTestInternal() {
- chrome.test.runTests(allTests);
- }
+function listenOnce(node, eventType, callback, capture) {
+ var innerCallback = function(evt) {
+ node.removeEventListener(eventType, innerCallback, capture);
+ callback(evt);
+ };
+ node.addEventListener(eventType, innerCallback, capture);
+}
+function setUpAndRunTests(allTests) {
chrome.automation.getDesktop(function(rootNodeArg) {
rootNode = rootNodeArg;
-
- // Only run the test when the window containing the new tab loads.
- rootNodeArg.addEventListener(
- chrome.automation.EventType.childrenChanged,
- function(evt) {
- var subroot = evt.target.firstChild;
- if (!opt_docString || !subroot)
- return;
-
- if (subroot.role == 'rootWebArea' &&
- subroot.docUrl.indexOf(opt_docString) != -1)
- runTestInternal();
- },
- true);
- if (opt_docString)
- runWithDocument(opt_docString, null);
- else
- runTestInternal();
+ chrome.test.runTests(allTests);
});
}

Powered by Google App Engine
This is Rietveld 408576698