| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ERROR = 'Optional permissions must be listed in extension manifest.'; | 5 var ERROR = 'Optional permissions must be listed in extension manifest.'; |
| 6 var test = chrome.test; | 6 var test = chrome.test; |
| 7 | 7 |
| 8 // The URL patterns that we've supposedly been granted access to so far. Use | 8 // The URL patterns that we've supposedly been granted access to so far. Use |
| 9 // this to verify queried hosts for each test. | 9 // this to verify queried hosts for each test. |
| 10 var grantedHosts = []; | 10 var grantedHosts = []; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 chrome.permissions.request({origins: [host]}, | 58 chrome.permissions.request({origins: [host]}, |
| 59 test.callback(function(granted) { | 59 test.callback(function(granted) { |
| 60 if (granted) | 60 if (granted) |
| 61 pushUniqueValue(grantedHosts, host); | 61 pushUniqueValue(grantedHosts, host); |
| 62 if (expectedGranted) { | 62 if (expectedGranted) { |
| 63 test.assertTrue( | 63 test.assertTrue( |
| 64 granted, | 64 granted, |
| 65 "Access to " + host + " was not granted, but should have been"); | 65 "Access to " + host + " was not granted, but should have been"); |
| 66 } else { | 66 } else { |
| 67 test.assertFalse( | 67 test.assertFalse( |
| 68 granted, | 68 !!granted, |
| 69 "Access to " + host + " was granted, but should not have been"); | 69 "Access to " + host + " was granted, but should not have been"); |
| 70 } | 70 } |
| 71 checkGrantedHosts(callback); | 71 checkGrantedHosts(callback); |
| 72 }, expectedError)); | 72 }, expectedError)); |
| 73 }; | 73 }; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Returns a function which removes access to a host, and afterwards checks | 76 // Returns a function which removes access to a host, and afterwards checks |
| 77 // that our expected host permissions agree with Chrome's. | 77 // that our expected host permissions agree with Chrome's. |
| 78 function removeHost(host, expectedRemoved) { | 78 function removeHost(host, expectedRemoved) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 requestHost('ftp://ftp.example.com/*', true), | 184 requestHost('ftp://ftp.example.com/*', true), |
| 185 contains('ftp://ftp.example.com/*', true), | 185 contains('ftp://ftp.example.com/*', true), |
| 186 removeHost('ftp://ftp.example.com/*', true), | 186 removeHost('ftp://ftp.example.com/*', true), |
| 187 contains('ftp://ftp.example.com/*', false), | 187 contains('ftp://ftp.example.com/*', false), |
| 188 | 188 |
| 189 // And finally... | 189 // And finally... |
| 190 test.succeed]); | 190 test.succeed]); |
| 191 } | 191 } |
| 192 | 192 |
| 193 test.runTests([main]); | 193 test.runTests([main]); |
| OLD | NEW |