Chromium Code Reviews| 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 = | |
| 10 "You do not have permission to use 'bookmarks.getTree'."; | |
| 11 | |
| 12 chrome.test.getConfig(function(config) { | 9 chrome.test.getConfig(function(config) { |
| 13 | 10 |
| 14 function doReq(domain, callback) { | 11 function doReq(domain, callback) { |
| 15 var req = new XMLHttpRequest(); | 12 var req = new XMLHttpRequest(); |
| 16 var url = domain + ":PORT/files/extensions/test_file.txt"; | 13 var url = domain + ":PORT/files/extensions/test_file.txt"; |
| 17 url = url.replace(/PORT/, config.testServer.port); | 14 url = url.replace(/PORT/, config.testServer.port); |
| 18 | 15 |
| 19 chrome.test.log("Requesting url: " + url); | 16 chrome.test.log("Requesting url: " + url); |
| 20 req.open("GET", url, true); | 17 req.open("GET", url, true); |
| 21 | 18 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 41 pass(function(granted) { | 38 pass(function(granted) { |
| 42 // They were not granted, and there should be no error. | 39 // They were not granted, and there should be no error. |
| 43 assertFalse(granted); | 40 assertFalse(granted); |
| 44 assertTrue(chrome.runtime.lastError === undefined); | 41 assertTrue(chrome.runtime.lastError === undefined); |
| 45 | 42 |
| 46 // Make sure they weren't granted... | 43 // Make sure they weren't granted... |
| 47 chrome.permissions.contains( | 44 chrome.permissions.contains( |
| 48 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, | 45 {permissions: ['bookmarks'], origins:['http://*.c.com/*']}, |
| 49 pass(function(result) { assertFalse(result); })); | 46 pass(function(result) { assertFalse(result); })); |
| 50 | 47 |
| 51 try { | 48 chrome.bookmarks.getTree(function(result) { |
| 52 chrome.bookmarks.getTree(function() { | 49 assertFalse(chrome.runtime.lastError === undefined); |
|
not at google - send to devlin
2013/05/30 16:38:52
same
| |
| 53 chrome.test.fail("Should not have bookmarks API permission."); | 50 }); |
| 54 }); | |
| 55 } catch (e) { | |
| 56 assertTrue(e.message.indexOf(NO_BOOKMARKS_PERMISSION) == 0); | |
| 57 } | |
| 58 | 51 |
| 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 |