summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-03-11 12:44:46 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-04-28 20:52:48 +0800
commit80a323d747f33e9e918bfde381c97346c1052a97 (patch)
tree5e2d7030d7fd48792685e093a3aacfd660ddb1b0
parentba04f314c083a0c691820d8d5e49c3d65be4684f (diff)
downloaduxp-80a323d747f33e9e918bfde381c97346c1052a97.tar.gz
Bug 1432272 - Make Fetch API use the global's base URL instead of the entry document's base URL
-rw-r--r--dom/fetch/Request.cpp6
-rw-r--r--dom/fetch/Response.cpp3
2 files changed, 6 insertions, 3 deletions
diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp
index 7a93a81799..ab87a3215a 100644
--- a/dom/fetch/Request.cpp
+++ b/dom/fetch/Request.cpp
@@ -313,7 +313,8 @@ Request::Constructor(const GlobalObject& aGlobal,
nsAutoString requestURL;
nsCString fragment;
if (NS_IsMainThread()) {
- nsIDocument* doc = GetEntryDocument();
+ nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(global));
+ nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
if (doc) {
GetRequestURLFromDocument(doc, input, requestURL, fragment, aRv);
} else {
@@ -362,7 +363,8 @@ Request::Constructor(const GlobalObject& aGlobal,
} else {
nsAutoString referrerURL;
if (NS_IsMainThread()) {
- nsIDocument* doc = GetEntryDocument();
+ nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(global));
+ nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
nsCOMPtr<nsIURI> uri;
if (doc) {
uri = ParseURLFromDocument(doc, referrer, aRv);
diff --git a/dom/fetch/Response.cpp b/dom/fetch/Response.cpp
index 100a0204c3..42b25ae1d9 100644
--- a/dom/fetch/Response.cpp
+++ b/dom/fetch/Response.cpp
@@ -65,7 +65,8 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
if (NS_IsMainThread()) {
nsCOMPtr<nsIURI> baseURI;
- nsIDocument* doc = GetEntryDocument();
+ nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(aGlobal.GetAsSupports()));
+ nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
if (doc) {
baseURI = doc->GetBaseURI();
}