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

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: Response to CR 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..e6406df6437d81363ad98cfab904158822b5724c 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 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