Bug 1933331 - [bidi] Update initiatorType and destination for top level document loads r=webdriver-reviewers,Sasha

The platform API currently returns values for initiatorType and destination
for top level document loads, but according to the HTML spec they should be null / empty.

The implementation in WebDriver BiDi NetworkRequest wrapper is updated to handle this
edge case.

Differential Revision: https://phabricator.services.mozilla.com/D230174
This commit is contained in:
Julian Descottes 2024-11-27 11:08:14 +00:00
parent fd1ef692be
commit 937e593aec

View File

@ -102,6 +102,10 @@ export class NetworkRequest {
}
get destination() {
if (this.#isTopLevelDocumentLoad()) {
return "";
}
return this.#channel.loadInfo?.fetchDestination;
}
@ -127,6 +131,10 @@ export class NetworkRequest {
return null;
}
if (this.#isTopLevelDocumentLoad()) {
return null;
}
return initiatorType;
}
@ -501,4 +509,15 @@ export class NetworkRequest {
return navigation ? navigation.navigationId : null;
}
#isTopLevelDocumentLoad() {
if (!this.#channel.isDocument) {
return false;
}
const browsingContext = lazy.TabManager.getBrowsingContextById(
this.#contextId
);
return !browsingContext.parent;
}
}