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

Unified Diff: go-back-with-backspace/content_script.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/background.js ('k') | go-back-with-backspace/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go-back-with-backspace/content_script.js
diff --git a/go-back-with-backspace/content_script.js b/go-back-with-backspace/content_script.js
index cc7fca6218a17ebc7f28b84725daee28d3925a22..c462d5b72188c17320e904d9b4afb98dad8f4bfb 100644
--- a/go-back-with-backspace/content_script.js
+++ b/go-back-with-backspace/content_script.js
@@ -44,14 +44,16 @@ function handleBackspace(e) {
return;
// The whitelist overrides applet focus.
- // Listening on the Window means the event has no path (see
- // http://crbug.com/645527), so we'll have to look at the focused (active)
- // element. This means it will not work properly with shadow DOM.
- // TODO: Fix behavior with shadow DOM when the above bug is resolved.
- if (!options.whitelist.includes(url) &&
- disabledInApplet(document.activeElement))
+ // Before Chrome 55, listening on the Window means the event has no path,
+ // instead pointing to the Window (see http://crbug.com/645527). In that
+ // case, we have to look at the focused (active) element.
+ // TODO: Switch entirely to e.path once Chrome 55 is launched.
+ var target = e.path[0];
+ if (target === window)
+ target = document.activeElement;
+ if (disabledInApplet(url, target))
return;
- if (isEditable(document.activeElement))
+ if (isEditable(target))
return;
// Make sure this extension is still active.
@@ -78,9 +80,10 @@ function handleBackspace(e) {
}
// Return true if the option to disable the extension in applets is enabled,
-// and focus is in an embedded Flash or Java applet.
-function disabledInApplet(target) {
- if (!options.disableInApplets)
+// focus is in an embedded Flash or Java applet, and the current page is not
+// in the whitelist of pages for which that should not apply.
+function disabledInApplet(url, target) {
+ if (!options.disableInApplets || options.whitelist.includes(url))
return false;
var nodeName = target.nodeName.toUpperCase();
« no previous file with comments | « go-back-with-backspace/background.js ('k') | go-back-with-backspace/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698