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

Side by Side Diff: chrome/test/data/extensions/api_test/permissions/optional_deny/background.html

Issue 7508029: Add origin permissions to the extension permissions API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix dcheck Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 <script> 1 <script>
2 2
3 var assertFalse = chrome.test.assertFalse; 3 var assertFalse = chrome.test.assertFalse;
4 var assertTrue = chrome.test.assertTrue; 4 var assertTrue = chrome.test.assertTrue;
5 var pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 6
7 var NO_TABS_PERMISSION = 7 var NO_TABS_PERMISSION =
8 "You do not have permission to use 'windows.getAll'."; 8 "You do not have permission to use 'windows.getAll'.";
9 9
10 chrome.test.runTests([ 10 chrome.test.getConfig(function(config) {
11 function denyRequest() {
12 chrome.experimental.permissions.request(
13 {permissions: ['tabs']},
14 pass(function(granted) {
15 // They were not granted, and there should be no error.
16 assertFalse(granted);
17 assertTrue(chrome.extension.lastError === undefined);
18 11
19 // Make sure they weren't granted... 12 function doReq(domain, callback) {
20 chrome.experimental.permissions.contains( 13 var req = new XMLHttpRequest();
21 {permissions: ['tabs']}, 14 var url = domain + ":PORT/files/extensions/test_file.txt";
22 pass(function(result) { 15 url = url.replace(/PORT/, config.testServer.port);
23 assertFalse(result);
24 }));
25 16
26 try { 17 chrome.test.log("Requesting url: " + url);
27 chrome.windows.getAll({populate: true}, function() { 18 req.open("GET", url, true);
28 chrome.test.fail("Should not have tabs API permission."); 19
29 }); 20 req.onload = function() {
30 } catch (e) { 21 assertEq(200, req.status);
31 assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0); 22 assertEq("Hello!", req.responseText);
32 } 23 callback(true);
33 })); 24 };
25
26 req.onerror = function() {
27 chrome.test.log("status: " + req.status);
28 chrome.test.log("text: " + req.responseText);
29 callback(false);
30 };
31
32 req.send(null);
34 } 33 }
35 ]); 34
35 chrome.test.runTests([
36 function denyRequest() {
37 chrome.experimental.permissions.request(
38 {permissions: ['tabs'], origins: ['http://*.c.com/*']},
39 pass(function(granted) {
40 // They were not granted, and there should be no error.
41 assertFalse(granted);
42 assertTrue(chrome.extension.lastError === undefined);
43
44 // Make sure they weren't granted...
45 chrome.experimental.permissions.contains(
46 {permissions: ['tabs'], origins:['http://*.c.com/*']},
47 pass(function(result) { assertFalse(result); }));
48
49 try {
50 chrome.windows.getAll({populate: true}, function() {
51 chrome.test.fail("Should not have tabs API permission.");
52 });
53 } catch (e) {
54 assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0);
55 }
56
57 doReq('http://b.c.com/', pass(function(result) {
58 assertFalse(result);
59 }));
60 }));
61 }
62 ]);
63 });
36 </script> 64 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698