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: go-back-with-backspace/background.js

Issue 2400303003: Update UI and catch executeScript errors now shown in Canary (Closed)
Patch Set: Add TODO to validate URLs Created 4 years, 1 month 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 | « go-back-with-backspace/_locales/en/messages.json ('k') | go-back-with-backspace/content_script.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go-back-with-backspace/background.js
diff --git a/go-back-with-backspace/background.js b/go-back-with-backspace/background.js
index 269b0bdf0f4b35b53cf3b4ed4db9f9d04e10ecc2..9c715aa7782731a5dad8edc25980b8a9af3c3678 100644
--- a/go-back-with-backspace/background.js
+++ b/go-back-with-backspace/background.js
@@ -29,14 +29,27 @@ function injectContentScripts() {
chrome.tabs.query({}, function(tabs) {
tabs.forEach(function(tab) {
scripts.forEach(function(script) {
- // This will produce an error if extensions are prohibited on the
- // tab (e.g., chrome:// pages), but we can ignore it.
- chrome.tabs.executeScript(tab.id,
- {
- file: script,
- allFrames: true,
- runAt: 'document_start'
- });
+ chrome.tabs.executeScript(
+ tab.id,
+ {
+ file: script,
+ allFrames: true,
+ runAt: 'document_start'
+ },
+ function() {
+ if (chrome.runtime.lastError) {
+ // An error will occur if extensions are prohibited on the
+ // tab (e.g., chrome:// pages). We don't need to do anything
+ // about that, but we do need to catch it here to avoid an
+ // error message on the Extensions page.
+ var message = chrome.runtime.lastError.message;
+ if (message != 'Cannot access a chrome:// URL' &&
+ message != 'The extensions gallery cannot be scripted.' &&
+ !message.startsWith('Cannot access contents of the page.')) {
+ throw message;
+ }
+ }
+ });
});
});
});
« no previous file with comments | « go-back-with-backspace/_locales/en/messages.json ('k') | go-back-with-backspace/content_script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698