Look at e.path where available (M55+)

With the fix to e.path for events on Window (issue 645527), coming in M55,
look there instead of document.activeElement when possible.

This fix is based on the currently released v1.5.1 of the extension, since the
options and popup pages are still waiting for final UI.

BUG=653993, 645527
R=ojan@chromium.org

Review URL: https://codereview.chromium.org//2407473002 .
diff --git a/go-back-with-backspace/content_script.js b/go-back-with-backspace/content_script.js
index ea6cecb..1e41c87 100644
--- a/go-back-with-backspace/content_script.js
+++ b/go-back-with-backspace/content_script.js
@@ -2,17 +2,21 @@
 // an editable field. We capture the event at the Window to let any handlers
 // or listeners registered on the Document have a chance to handle it first.
 window.addEventListener('keydown', function(e) {
-  // 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.
+  // 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.
   if (e.key === 'Backspace' &&
       !e.defaultPrevented &&
       !e.altKey &&
       !e.ctrlKey &&
-      !e.metaKey &&
-      !isEditable(document.activeElement)) {
-    e.shiftKey ? window.history.forward(): window.history.back();
-    e.preventDefault();
+      !e.metaKey) {
+    var target = e.path[0];
+    if (target === window)
+      target = document.activeElement;
+    if (!isEditable(target)) {
+      e.shiftKey ? window.history.forward(): window.history.back();
+      e.preventDefault();
+    }
   }
 });
diff --git a/go-back-with-backspace/manifest.json b/go-back-with-backspace/manifest.json
index 3019647..d94193f 100644
--- a/go-back-with-backspace/manifest.json
+++ b/go-back-with-backspace/manifest.json
@@ -2,7 +2,7 @@
   "name": "__MSG_extensionName__",
   "description": "__MSG_extensionDescription__",
   "default_locale": "en",
-  "version": "1.5.1",
+  "version": "1.5.2",
   "manifest_version": 2,
   "minimum_chrome_version": "52",
   "icons": {