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

[errorReport][hook-callback.js] errorReportBaseUrl is not based on hook.parameters.baseURI #416

Closed
t2ym opened this issue Feb 1, 2022 · 0 comments

Comments

@t2ym
Copy link
Owner

t2ym commented Feb 1, 2022

[errorReport][hook-callback.js] errorReportBaseUrl is not based on hook.parameters.baseURI

Root Cause

  • The initial code assuming location is at the same directory as the entry page is inapplicable to these cases
    • IFrame pages that are not in the same directory as the entry page
    • Web worker scripts that are not in the same directory as the entry page
    • [For potential support in the future] Dynamic top pages that are not in the same directory as the entry page

Fix

diff --git a/plugins/policy/errorReport.js b/plugins/policy/errorReport.js
index 9eb33bc9..4efb4d5f 100644
--- a/plugins/policy/errorReport.js
+++ b/plugins/policy/errorReport.js
@@ -5,7 +5,7 @@ Copyright (c) 2017, 2018, 2019, 2020 Tetsuya Mori <t2y3141592@gmail.com>. All ri
 */
 /* @endexclude */
   // Handle exceptions
-  const errorReportBaseUrl = (new URL('errorReport.json', typeof window === 'object' ? top.location : location)).pathname;
+  const errorReportBaseUrl = (new URL('errorReport.json', hook.parameters.baseURI)).href;
   const criticalErrorPageUrl = 'about:blank';
   let hookCallbackCompatibilityTestDone = false;
   const _caches = caches; // Take a backup just in case (still not robust)
@t2ym t2ym closed this as completed in 0b0aef0 Feb 1, 2022
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