1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function createBackgroundTab(url, callback) {
6 chrome.tabs.query({ active: true }, function(tabs) {
7 chrome.test.assertEq(1, tabs.length);
8 var originalActiveTab = tabs[0];
9 createTab(url, function(tab) {
10 chrome.tabs.update(originalActiveTab.id, { active: true }, function() {
17 function assertCorrectTab(rootNode) {
18 var title = rootNode.attributes.docTitle;
19 chrome.test.assertEq('Automation Tests', title);
20 chrome.test.succeed();
24 function testGetTabById() {
25 getUrlFromConfig(function(url) {
26 // Keep the NTP as the active tab so that we know we're requesting the
27 // tab by ID rather than just getting the active tab still.
28 createBackgroundTab(url, function(tab) {
29 chrome.automation.getTree(tab.id, function(rootNode) {
30 if (rootNode.attributes.docLoaded) {
31 assertCorrectTab(rootNode);
35 rootNode.addEventListener('loadComplete', function() {
36 assertCorrectTab(rootNode);
44 chrome.test.runTests(allTests);