| 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 pass = chrome.test.callbackPass; | 7 var pass = chrome.test.callbackPass; |
| 8 | 8 |
| 9 var NO_BOOKMARKS_PERMISSION = | 9 var NO_BOOKMARKS_PERMISSION = |
| 10 "You do not have permission to use 'bookmarks.getTree'."; | 10 "You do not have permission to use 'bookmarks.getTree'."; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 pass(function(granted) { | 41 pass(function(granted) { |
| 42 // They were not granted, and there should be no error. | 42 // They were not granted, and there should be no error. |
| 43 assertFalse(granted); | 43 assertFalse(granted); |
| 44 assertTrue(chrome.runtime.lastError === undefined); | 44 assertTrue(chrome.runtime.lastError === undefined); |
| 45 | 45 |
| 46 // Make sure they weren't granted... | 46 // Make sure they weren't granted... |
| 47 chrome.permissions.contains( | 47 chrome.permissions.contains( |
| 48 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, | 48 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, |
| 49 pass(function(result) { assertFalse(result); })); | 49 pass(function(result) { assertFalse(result); })); |
| 50 | 50 |
| 51 try { | 51 assertTrue(chrome.bookmarks === undefined); |
| 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) { | 52 doReq('http://b.c.com/', pass(function(result) { |
| 60 assertFalse(result); | 53 assertFalse(result); |
| 61 })); | 54 })); |
| 62 })); | 55 })); |
| 63 }, | 56 }, |
| 64 | 57 |
| 65 function noPromptForActivePermissions() { | 58 function noPromptForActivePermissions() { |
| 66 // We shouldn't prompt if the extension already has the permissions. | 59 // We shouldn't prompt if the extension already has the permissions. |
| 67 chrome.permissions.request( | 60 chrome.permissions.request( |
| 68 {permissions: ["management"]}, | 61 {permissions: ["management"]}, |
| 69 pass(function(granted) { | 62 pass(function(granted) { |
| 70 assertTrue(granted); | 63 assertTrue(granted); |
| 71 })); | 64 })); |
| 72 } | 65 } |
| 73 ]); | 66 ]); |
| 74 }); | 67 }); |
| OLD | NEW |