Chromium Code Reviews| 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)); |
| }); |