Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/permissions/optional_deny/background.html |
| diff --git a/chrome/test/data/extensions/api_test/permissions/optional_deny/background.html b/chrome/test/data/extensions/api_test/permissions/optional_deny/background.html |
| index ca023829a1999656566e2fe6bf2abdacb6005356..b420443907e4a6108542be42eb59c1bf10fa0625 100644 |
| --- a/chrome/test/data/extensions/api_test/permissions/optional_deny/background.html |
| +++ b/chrome/test/data/extensions/api_test/permissions/optional_deny/background.html |
| @@ -1,36 +1,72 @@ |
| -<script> |
| - |
| -var assertFalse = chrome.test.assertFalse; |
| -var assertTrue = chrome.test.assertTrue; |
| -var pass = chrome.test.callbackPass; |
| - |
| -var NO_TABS_PERMISSION = |
| - "You do not have permission to use 'windows.getAll'."; |
| - |
| -chrome.test.runTests([ |
| - function denyRequest() { |
| - chrome.experimental.permissions.request( |
| - {permissions: ['tabs']}, |
| - pass(function(granted) { |
| - // They were not granted, and there should be no error. |
| - assertFalse(granted); |
| - assertTrue(chrome.extension.lastError === undefined); |
| - |
| - // Make sure they weren't granted... |
| - chrome.experimental.permissions.contains( |
| - {permissions: ['tabs']}, |
| - pass(function(result) { |
| - assertFalse(result); |
| - })); |
| - |
| - try { |
| - chrome.windows.getAll({populate: true}, function() { |
| - chrome.test.fail("Should not have tabs API permission."); |
| - }); |
| - } catch (e) { |
| - assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0); |
| - } |
| - })); |
| - } |
| -]); |
| -</script> |
| +<script> |
| + |
| +var assertFalse = chrome.test.assertFalse; |
| +var assertTrue = chrome.test.assertTrue; |
| +var pass = chrome.test.callbackPass; |
| + |
| +var NO_TABS_PERMISSION = |
| + "You do not have permission to use 'windows.getAll'."; |
| + |
| +chrome.test.getConfig(function(config) { |
| + |
| + function doReq(domain, expectSuccess) { |
| + var req = new XMLHttpRequest(); |
| + var url = domain + ":PORT/files/extensions/test_file.txt"; |
| + url = url.replace(/PORT/, config.testServer.port); |
| + |
| + chrome.test.log("Requesting url: " + url); |
| + req.open("GET", url, true); |
| + |
| + |
| + if (expectSuccess) { |
| + req.onload = function() { |
| + chrome.test.assertEq(200, req.status); |
| + chrome.test.assertEq("Hello!", req.responseText); |
| + chrome.test.runNextTest(); |
| + } |
| + req.onerror = function() { |
| + chrome.test.log("status: " + req.status); |
| + chrome.test.log("text: " + req.responseText); |
| + chrome.test.fail("Unexpected error for domain: " + domain); |
| + } |
| + } else { |
| + req.onload = function() { |
| + chrome.test.fail("Unexpected success for domain: " + domain); |
| + } |
| + req.onerror = function() { |
| + chrome.test.assertEq(0, req.status); |
| + chrome.test.runNextTest(); |
| + } |
| + } |
| + |
| + req.send(null); |
| + } |
| + |
| + chrome.test.runTests([ |
| + function denyRequest() { |
| + chrome.experimental.permissions.request( |
| + {permissions: ['tabs'], origins: ['http://*.c.com/*']}, |
| + pass(function(granted) { |
| + // They were not granted, and there should be no error. |
| + assertFalse(granted); |
| + assertTrue(chrome.extension.lastError === undefined); |
| + |
| + // Make sure they weren't granted... |
| + chrome.experimental.permissions.contains( |
| + {permissions: ['tabs'], origins:['http://*.c.com/*']}, |
| + pass(function(result) { assertFalse(result); })); |
| + |
| + try { |
| + chrome.windows.getAll({populate: true}, function() { |
| + chrome.test.fail("Should not have tabs API permission."); |
| + }); |
| + } catch (e) { |
| + assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0); |
| + } |
| + |
| + doReq('http://b.c.com/', false); |
|
Matt Perry
2011/08/03 22:08:14
ditto comments from other test
jstritar
2011/08/04 16:35:15
Done.
|
| + })); |
| + } |
| + ]); |
| +}); |
| +</script> |