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

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: 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..7ae0f1940cfc08603ccb3ecde735b1dbc8b19886 100644
--- a/src/js/caterpillar.js
+++ b/src/js/caterpillar.js
@@ -27,6 +27,22 @@ 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, since this always appears
+// in Chrome Apps.
raymes 2016/01/31 23:44:37 I'm not sure what this comment means? Why is it st
Matthew Alger 2016/02/01 00:14:33 chrome.app.runtime.onLaunched.addListener is used
raymes 2016/02/01 00:18:44 Could you make the comment say something like this
Matthew Alger 2016/02/01 00:36:52 Done.
+if (!chrome.app)
Matthew Alger 2016/01/28 04:51:41 Note that Chrome exports chrome.app, so we can't j
raymes 2016/01/31 23:44:37 Could we just always override onLaunched? (do we r
Matthew Alger 2016/02/01 00:14:33 It's not obvious to me that Chrome doesn't/won't e
raymes 2016/02/01 00:18:44 Why not override it? :) I think we had a similar d
Matthew Alger 2016/02/01 00:36:52 Hmmm, okay. Done. (Though if a chrome.app.runtime
+ chrome.app = {};
+if (!chrome.app.runtime)
+ chrome.app.runtime = {};
+if (!chrome.app.runtime.onLaunched) {
+ chrome.app.runtime.onLaunched = {
+ addListener: function() {},
+ };
+}
raymes 2016/01/31 23:44:37 Why did this code need to be moved?
Matthew Alger 2016/02/01 00:14:33 - It's static, so I think it should go in a static
raymes 2016/02/01 00:18:44 Sounds good - this would be useful context to have
Matthew Alger 2016/02/01 00:36:52 Done.
+
(function() {
/**
@@ -38,11 +54,8 @@ if (!chrome.caterpillar)
* 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);
- }
+ console.warn('Error set in lastError:', message);
raymes 2016/01/31 23:44:37 Do we need to log warnings every time?
Matthew Alger 2016/02/01 00:14:33 Hmm, I'm not sure. I don't think it really matters
raymes 2016/02/01 00:18:44 I think removing it is ok.
Matthew Alger 2016/02/01 00:36:52 Done.
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