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

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

Issue 655273005: Implement AutomationNode.querySelector(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix heap-use-after-free issue by not keeping a scoped_ptr to automation_api_helper in extension_hel… Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1
1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // 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 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 4 // found in the LICENSE file.
4 5
5 function createBackgroundTab(url, callback) { 6 function createBackgroundTab(url, callback) {
6 chrome.tabs.query({ active: true }, function(tabs) { 7 chrome.tabs.query({ active: true }, function(tabs) {
7 chrome.test.assertEq(1, tabs.length); 8 chrome.test.assertEq(1, tabs.length);
8 var originalActiveTab = tabs[0]; 9 var originalActiveTab = tabs[0];
9 createTab(url, function(tab) { 10 createTab(url, function(tab) {
10 chrome.tabs.update(originalActiveTab.id, { active: true }, function() { 11 chrome.tabs.update(originalActiveTab.id, { active: true }, function() {
11 callback(tab); 12 callback(tab);
12 }); 13 });
13 }) 14 })
14 }); 15 });
15 } 16 }
16 17
17 function assertCorrectTab(rootNode) { 18 function assertCorrectTab(rootNode) {
18 var title = rootNode.attributes.docTitle; 19 var title = rootNode.attributes.docTitle;
19 chrome.test.assertEq('Automation Tests', title); 20 chrome.test.assertEq('Automation Tests', title);
20 chrome.test.succeed(); 21 chrome.test.succeed();
21 } 22 }
22 23
23 var allTests = [ 24 var allTests = [
24 function testGetTabById() { 25 function testGetTabById() {
25 getUrlFromConfig(function(url) { 26 getUrlFromConfig('index.html', function(url) {
26 // Keep the NTP as the active tab so that we know we're requesting the 27 // 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 // tab by ID rather than just getting the active tab still.
28 createBackgroundTab(url, function(tab) { 29 createBackgroundTab(url, function(tab) {
29 chrome.automation.getTree(tab.id, function(rootNode) { 30 chrome.automation.getTree(tab.id, function(rootNode) {
30 if (rootNode.attributes.docLoaded) { 31 if (rootNode.attributes.docLoaded) {
31 assertCorrectTab(rootNode); 32 assertCorrectTab(rootNode);
32 return; 33 return;
33 } 34 }
34 35
35 rootNode.addEventListener('loadComplete', function() { 36 rootNode.addEventListener('loadComplete', function() {
36 assertCorrectTab(rootNode); 37 assertCorrectTab(rootNode);
37 }); 38 });
38 }) 39 })
39 }); 40 });
40 }); 41 });
41 } 42 }
42 ]; 43 ];
43 44
44 chrome.test.runTests(allTests); 45 chrome.test.runTests(allTests);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698