OLD | NEW |
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 assertFalse = chrome.test.assertFalse; | 5 var assertFalse = chrome.test.assertFalse; |
6 var assertTrue = chrome.test.assertTrue; | 6 var assertTrue = chrome.test.assertTrue; |
| 7 var assertEq = chrome.test.assertEq; |
7 var pass = chrome.test.callbackPass; | 8 var pass = chrome.test.callbackPass; |
8 | 9 |
9 var NO_BOOKMARKS_PERMISSION = | 10 var NO_BOOKMARKS_PERMISSION = |
10 "You do not have permission to use 'bookmarks.getTree'."; | 11 "You do not have permission to use 'bookmarks.getTree'."; |
11 | 12 |
12 chrome.test.getConfig(function(config) { | 13 chrome.test.getConfig(function(config) { |
13 | 14 |
14 function doReq(domain, callback) { | 15 function doReq(domain, callback) { |
15 var req = new XMLHttpRequest(); | 16 var req = new XMLHttpRequest(); |
16 var url = domain + ":PORT/files/extensions/test_file.txt"; | 17 var url = domain + ":PORT/files/extensions/test_file.txt"; |
(...skipping 24 matching lines...) Expand all Loading... |
41 pass(function(granted) { | 42 pass(function(granted) { |
42 // They were not granted, and there should be no error. | 43 // They were not granted, and there should be no error. |
43 assertFalse(granted); | 44 assertFalse(granted); |
44 assertTrue(chrome.runtime.lastError === undefined); | 45 assertTrue(chrome.runtime.lastError === undefined); |
45 | 46 |
46 // Make sure they weren't granted... | 47 // Make sure they weren't granted... |
47 chrome.permissions.contains( | 48 chrome.permissions.contains( |
48 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, | 49 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, |
49 pass(function(result) { assertFalse(result); })); | 50 pass(function(result) { assertFalse(result); })); |
50 | 51 |
51 try { | 52 assertEq(undefined, chrome.bookmarks); |
52 chrome.bookmarks.getTree(function() { | |
53 chrome.test.fail("Should not have bookmarks API permission."); | |
54 }); | |
55 } catch (e) { | |
56 assertTrue(e.message.indexOf(NO_BOOKMARKS_PERMISSION) == 0); | |
57 } | |
58 | |
59 doReq('http://b.c.com/', pass(function(result) { | 53 doReq('http://b.c.com/', pass(function(result) { |
60 assertFalse(result); | 54 assertFalse(result); |
61 })); | 55 })); |
62 })); | 56 })); |
63 }, | 57 }, |
64 | 58 |
65 function noPromptForActivePermissions() { | 59 function noPromptForActivePermissions() { |
66 // We shouldn't prompt if the extension already has the permissions. | 60 // We shouldn't prompt if the extension already has the permissions. |
67 chrome.permissions.request( | 61 chrome.permissions.request( |
68 {permissions: ["management"]}, | 62 {permissions: ["management"]}, |
69 pass(function(granted) { | 63 pass(function(granted) { |
70 assertTrue(granted); | 64 assertTrue(granted); |
71 })); | 65 })); |
72 } | 66 } |
73 ]); | 67 ]); |
74 }); | 68 }); |
OLD | NEW |