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

Side by Side Diff: chrome/test/data/extensions/api_test/active_tab/background.js

Issue 890083002: [Extensions] Propagate activeTab hosts to extension background pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var assertEq = chrome.test.assertEq; 5 var assertEq = chrome.test.assertEq;
6 var assertFalse = chrome.test.assertFalse; 6 var assertFalse = chrome.test.assertFalse;
7 var assertTrue = chrome.test.assertTrue; 7 var assertTrue = chrome.test.assertTrue;
8 var callbackFail = chrome.test.callbackFail; 8 var callbackFail = chrome.test.callbackFail;
9 var callbackPass = chrome.test.callbackPass; 9 var callbackPass = chrome.test.callbackPass;
10 10
11 var RoleType = chrome.automation.RoleType; 11 var RoleType = chrome.automation.RoleType;
12 12
13 function canXhr(url) {
not at google - send to devlin 2015/02/05 00:16:13 Would be good to test iframes in here somewhere as
Devlin 2015/02/05 19:54:50 Done.
14 assertFalse(url == null);
15 var xhr = new XMLHttpRequest();
16 xhr.open('GET', url, false);
17 var success = true;
18 try {
19 xhr.send();
20 } catch(e) {
21 success = false;
22 }
23 return success;
24 }
25
13 chrome.browserAction.onClicked.addListener(function() { 26 chrome.browserAction.onClicked.addListener(function() {
14 chrome.tabs.executeScript({ code: 'true' }, callbackPass()); 27 chrome.tabs.executeScript({ code: 'true' }, callbackPass());
15 chrome.automation.getTree(callbackPass(function(rootNode) { 28
16 assertFalse(rootNode == undefined); 29 chrome.tabs.query({active:true}, function(tabs) {
not at google - send to devlin 2015/02/05 00:16:13 no need for query, browserAction.onClicked takes t
Devlin 2015/02/05 19:54:50 Done.
17 assertEq(RoleType.rootWebArea, rootNode.role); 30 assertTrue(canXhr(tabs[0].url));
18 chrome.test.succeed(); 31
19 })); 32 chrome.automation.getTree(callbackPass(function(rootNode) {
33 assertFalse(rootNode == undefined);
34 assertEq(RoleType.rootWebArea, rootNode.role);
35 chrome.test.succeed();
36 }));
37 });
20 }); 38 });
21 39
22 chrome.webNavigation.onCompleted.addListener(function(details) { 40 chrome.webNavigation.onCompleted.addListener(function(details) {
23 chrome.tabs.executeScript({ code: 'true' }, callbackFail( 41 chrome.tabs.executeScript({ code: 'true' }, callbackFail(
24 'Cannot access contents of url "' + details.url + 42 'Cannot access contents of url "' + details.url +
25 '". Extension manifest must request permission to access this host.')); 43 '". Extension manifest must request permission to access this host.'));
26 44
27 chrome.automation.getTree(callbackFail( 45 chrome.automation.getTree(callbackFail(
28 'Cannot request automation tree on url "' + details.url + 46 'Cannot request automation tree on url "' + details.url +
29 '". Extension manifest must request permission to access this host.')); 47 '". Extension manifest must request permission to access this host.'));
48
49 assertFalse(canXhr(details.url));
30 }); 50 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698