Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: src/js/caterpillar.js

Issue 1642833002: Stubbed runtime and app.runtime in caterpillar.js. Resolves #8. (Closed) Base URL: git@github.com:chromium/caterpillar.git@master
Patch Set: Merge from master Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/caterpillar.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/caterpillar.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698