Skip to content

Commit c3e3ac3

Browse files
committed
Bug 1432272 Make Fetch API use the global's base URL instead of the entry document's base URL. r=bz
The fetch spec used to use the entry settings as the base for parsing relative Request/Response URL's, but this is no longer the case. This was changed in: whatwg/fetch#367 Update our code to match this behavior. We basically convert GetEntryDocument() to QI the global to nsGlobalWindowInner and use its ExtantDoc instead. No changes are needed for workers since its not possible to perform cross-global javascript access in worker threads. UltraBlame original commit: b5432554c7bd39dd14adff8060a7f7757bb2c40e
1 parent 9fd9174 commit c3e3ac3

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

dom/fetch/Request.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ Request::Constructor(const GlobalObject& aGlobal,
319319
nsAutoString requestURL;
320320
nsCString fragment;
321321
if (NS_IsMainThread()) {
322-
nsIDocument* doc = GetEntryDocument();
322+
nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(global));
323+
nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
323324
if (doc) {
324325
GetRequestURLFromDocument(doc, input, requestURL, fragment, aRv);
325326
} else {
@@ -368,7 +369,8 @@ Request::Constructor(const GlobalObject& aGlobal,
368369
} else {
369370
nsAutoString referrerURL;
370371
if (NS_IsMainThread()) {
371-
nsIDocument* doc = GetEntryDocument();
372+
nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(global));
373+
nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
372374
nsCOMPtr<nsIURI> uri;
373375
if (doc) {
374376
uri = ParseURLFromDocument(doc, referrer, aRv);

dom/fetch/Response.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
100100

101101
if (NS_IsMainThread()) {
102102
nsCOMPtr<nsIURI> baseURI;
103-
nsIDocument* doc = GetEntryDocument();
103+
nsCOMPtr<nsPIDOMWindowInner> inner(do_QueryInterface(aGlobal.GetAsSupports()));
104+
nsIDocument* doc = inner ? inner->GetExtantDoc() : nullptr;
104105
if (doc) {
105106
baseURI = doc->GetBaseURI();
106107
}

testing/web-platform/meta/fetch/api/request/multi-globals/url-parsing.html.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

testing/web-platform/meta/fetch/api/response/multi-globals/url-parsing.html.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

testing/web-platform/meta/service-workers/service-worker/claim-fetch.https.html.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)