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

Unified Diff: chrome/test/data/extensions/api_test/automation/tests/tabs/tab_id.js

Issue 308003003: Allow requesting Automation tree by tabId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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/tabs/tab_id.js
diff --git a/chrome/test/data/extensions/api_test/automation/tests/tabs/tab_id.js b/chrome/test/data/extensions/api_test/automation/tests/tabs/tab_id.js
new file mode 100644
index 0000000000000000000000000000000000000000..e1ae825806b63615e27232c24d80e814f80913b8
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/automation/tests/tabs/tab_id.js
@@ -0,0 +1,35 @@
+// Copyright 2014 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.
+
+function createBackgroundTab(url, callback) {
+ chrome.tabs.query({ active: true }, function(tabs) {
+ chrome.test.assertEq(1, tabs.length);
+ var originalActiveTab = tabs[0];
+ createTab(url, function(tab) {
+ chrome.tabs.update(originalActiveTab.id, { active: true }, function() {
+ callback(tab);
+ });
+ })
+ });
+}
+
+var allTests = [
+ function testGetTabById() {
+ getUrlFromConfig(function(url) {
+ // Keep the NTP as the active tab so that we know we're requesting the
+ // tab by ID rather than just getting the active tab still.
+ createBackgroundTab(url, function(tab) {
+ chrome.automation.getTree(tab.id, function(tree) {
+ tree.addEventListener('loadComplete', function() {
+ var title = tree.root.attributes['docTitle'];
+ chrome.test.assertEq('Automation Tests', title);
+ chrome.test.succeed();
+ });
+ })
+ });
+ });
+ }
+];
+
+chrome.test.runTests(allTests);

Powered by Google App Engine
This is Rietveld 408576698