Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bootstrap.js] Handle SVG top as 'about:blank' #316

Closed
t2ym opened this issue Aug 28, 2019 · 1 comment
Closed

[bootstrap.js] Handle SVG top as 'about:blank' #316

t2ym opened this issue Aug 28, 2019 · 1 comment

Comments

@t2ym
Copy link
Owner

t2ym commented Aug 28, 2019

[bootstrap.js] Handle SVG top document properly

Root Cause

  • Scripts of a top SVG document do not have src attribute but *:href to specify the script URL

Fix

diff --git a/demo/bootstrap.js b/demo/bootstrap.js
index 61d9171a..bdd87a9e 100644
--- a/demo/bootstrap.js
+++ b/demo/bootstrap.js
@@ -14,7 +14,16 @@ else {
       baseURI = top.hook.parameters.baseURI;
     }
     hook.parameters.baseURI = baseURI;
-    noHookAuthorization = new URL(top.document.querySelector('script').src).searchParams.get('no-hook-authorization');
+    let script = top.document.querySelector('script');
+    let src = script.src;
+    if (!src) {
+      let attr = Array.prototype.filter.call(script.attributes, (a) => a.name.endsWith(':href'))[0];
+      if (attr) {
+        src = attr.value;
+      }
+    }
+    noHookAuthorization = new URL(src, baseURI).searchParams.get('no-hook-authorization');
     break;
   case 'ServiceWorkerGlobalScope':
     baseURI = new URL(location.origin + new URL(location.href).searchParams.get('service-worker-initiator')).href;
@t2ym t2ym closed this as completed in 6e731fb Aug 28, 2019
@t2ym
Copy link
Owner Author

t2ym commented Aug 28, 2019

Top SVG must not be supported as DevTools is enabled

@t2ym t2ym reopened this Aug 28, 2019
@t2ym t2ym changed the title [bootstrap.js] Handle SVG top document properly [bootstrap.js] Handle SVG top as 'about:blank' Aug 28, 2019
@t2ym t2ym closed this as completed in e1bd969 Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant