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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/active_tab/background.js
diff --git a/chrome/test/data/extensions/api_test/active_tab/background.js b/chrome/test/data/extensions/api_test/active_tab/background.js
index cdafdc622bc5ba2015e813b6b9331c3c8b37cc0c..90e06c0e2c078ea813d0efcd2fd40f76e5b44f9e 100644
--- a/chrome/test/data/extensions/api_test/active_tab/background.js
+++ b/chrome/test/data/extensions/api_test/active_tab/background.js
@@ -10,13 +10,31 @@ var callbackPass = chrome.test.callbackPass;
var RoleType = chrome.automation.RoleType;
+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.
+ assertFalse(url == null);
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ var success = true;
+ try {
+ xhr.send();
+ } catch(e) {
+ success = false;
+ }
+ return success;
+}
+
chrome.browserAction.onClicked.addListener(function() {
chrome.tabs.executeScript({ code: 'true' }, callbackPass());
- chrome.automation.getTree(callbackPass(function(rootNode) {
- assertFalse(rootNode == undefined);
- assertEq(RoleType.rootWebArea, rootNode.role);
- chrome.test.succeed();
- }));
+
+ 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.
+ assertTrue(canXhr(tabs[0].url));
+
+ chrome.automation.getTree(callbackPass(function(rootNode) {
+ assertFalse(rootNode == undefined);
+ assertEq(RoleType.rootWebArea, rootNode.role);
+ chrome.test.succeed();
+ }));
+ });
});
chrome.webNavigation.onCompleted.addListener(function(details) {
@@ -27,4 +45,6 @@ chrome.webNavigation.onCompleted.addListener(function(details) {
chrome.automation.getTree(callbackFail(
'Cannot request automation tree on url "' + details.url +
'". Extension manifest must request permission to access this host.'));
+
+ assertFalse(canXhr(details.url));
});

Powered by Google App Engine
This is Rietveld 408576698