OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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() { |
| 11 callback(tab); |
| 12 }); |
| 13 }) |
| 14 }); |
| 15 } |
| 16 |
| 17 var allTests = [ |
| 18 function testGetTabById() { |
| 19 getUrlFromConfig(function(url) { |
| 20 // Keep the NTP as the active tab so that we know we're requesting the |
| 21 // tab by ID rather than just getting the active tab still. |
| 22 createBackgroundTab(url, function(tab) { |
| 23 chrome.automation.getTree(tab.id, function(tree) { |
| 24 tree.addEventListener('loadComplete', function() { |
| 25 var title = tree.root.attributes['docTitle']; |
| 26 chrome.test.assertEq('Automation Tests', title); |
| 27 chrome.test.succeed(); |
| 28 }); |
| 29 }) |
| 30 }); |
| 31 }); |
| 32 } |
| 33 ]; |
| 34 |
| 35 chrome.test.runTests(allTests); |
OLD | NEW |