Chromium Code Reviews| Index: src/js/caterpillar.js |
| diff --git a/src/js/caterpillar.js b/src/js/caterpillar.js |
| index 1be41a5b466d995c619c82343cc035b3b321fc75..e6fc142173c1aea633a2151e32f6c027d72aa430 100644 |
| --- a/src/js/caterpillar.js |
| +++ b/src/js/caterpillar.js |
| @@ -27,22 +27,31 @@ if (!('chrome' in self)) |
| if (!chrome.caterpillar) |
| chrome.caterpillar = {}; |
| +// We need the chrome.runtime namespace to store errors in. |
| +if (!chrome.runtime) |
| + chrome.runtime = { lastError: null }; |
| + |
| +// Stub out chrome.app.runtime.onLaunched.addListener. |
| +// All Chrome Apps call this method to launch the main window. Stubbing it means |
|
raymes
2016/02/01 01:51:10
nit: fill 80 chars on the previous line
Matthew Alger
2016/02/02 22:18:25
Done.
|
| +// that background scripts that launch the main window can be re-used elsewhere |
| +// without causing script errors. |
| +chrome.app = { |
| + runtime: { |
| + onLaunched: { |
| + addListener: function() {}, |
| + } |
| + } |
| +}; |
| + |
| (function() { |
| /** |
| - * Sets an error message in lastError if chrome.runtime is loaded. |
| + * Sets an error message in chrome.runtime.lastError. |
| * |
| * @param {string} message The error message to set. |
| - * |
| - * @throws Error with given message if runtime is not loaded, and a warning that |
| - * runtime isn't loaded. |
| */ |
| chrome.caterpillar.setError = function(message) { |
| - if (!chrome.runtime) { |
| - console.warn('chrome.runtime not found; runtime errors may not be caught.'); |
| - throw new Error(message); |
| - } |
| chrome.runtime.lastError = { 'message': message }; |
| }; |
| -}).call(this); |
| +}).call(this); |