| 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 // Simple success test: we want content-script APIs to be available (like | 5 // Simple success test: we want content-script APIs to be available (like |
| 6 // sendRequest), but other APIs to be undefined or throw exceptions on access. | 6 // sendRequest), but other APIs to be undefined or throw exceptions on access. |
| 7 | 7 |
| 8 function runsWithException(f) { | 8 function runsWithException(f) { |
| 9 try { | 9 try { |
| 10 var foo = f(); | 10 var foo = f(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 var success = true; | 23 var success = true; |
| 24 | 24 |
| 25 // The whole of chrome.storage (arbitrary unprivileged) is unavailable. | 25 // The whole of chrome.storage (arbitrary unprivileged) is unavailable. |
| 26 if (chrome.storage) { | 26 if (chrome.storage) { |
| 27 console.log('Error: chrome.storage exists, it shouldn\'t.'); | 27 console.log('Error: chrome.storage exists, it shouldn\'t.'); |
| 28 success = false; | 28 success = false; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // Parts of chrome.extension and chrome.tabs (which get included because it's | 31 // Ditto chrome.tabs, though it's special because it's a dependency of the |
| 32 // a dependency of chrome.extension) are unavailable. | 32 // partially unprivileged chrome.extension. |
| 33 if (chrome.tabs) { |
| 34 console.log('Error: chrome.tabs exists, it shouldn\'t.'); |
| 35 success = false; |
| 36 } |
| 37 |
| 38 // Parts of chrome.extension are unavailable. |
| 33 if (!runsWithException(function() { return chrome.extension.getViews; })) | 39 if (!runsWithException(function() { return chrome.extension.getViews; })) |
| 34 success = false; | 40 success = false; |
| 35 if (!runsWithException(function() { return chrome.tabs.create; })) | |
| 36 success = false; | |
| 37 | 41 |
| 38 chrome.extension.sendRequest({success: success}); | 42 chrome.extension.sendRequest({success: success}); |
| OLD | NEW |