Bug 1892440 - Expose RequestObserversCalled attribute in nsIHttpChannel r=valentin,necko-reviewers

For WebDriver BiDi network interception we need to be able to modify the request as late as possible.
This changeset exposes RequestObserversCalled to JS so that we can update it from the webdriver bidi codebase.

Differential Revision: https://phabricator.services.mozilla.com/D208011
This commit is contained in:
Julian Descottes 2024-04-19 18:50:18 +00:00
parent b8fdc6491d
commit 453b6d319c
6 changed files with 55 additions and 0 deletions

View File

@ -2297,6 +2297,19 @@ HttpBaseChannel::UpgradeToSecure() {
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetRequestObserversCalled(bool* aCalled) {
NS_ENSURE_ARG_POINTER(aCalled);
*aCalled = LoadRequestObserversCalled();
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::SetRequestObserversCalled(bool aCalled) {
StoreRequestObserversCalled(aCalled);
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetRequestContextID(uint64_t* aRCID) {
NS_ENSURE_ARG_POINTER(aRCID);

View File

@ -228,6 +228,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
NS_IMETHOD GetRequestSucceeded(bool* aValue) override;
NS_IMETHOD RedirectTo(nsIURI* newURI) override;
NS_IMETHOD UpgradeToSecure() override;
NS_IMETHOD GetRequestObserversCalled(bool* aCalled) override;
NS_IMETHOD SetRequestObserversCalled(bool aCalled) override;
NS_IMETHOD GetRequestContextID(uint64_t* aRCID) override;
NS_IMETHOD GetTransferSize(uint64_t* aTransferSize) override;
NS_IMETHOD GetRequestSize(uint64_t* aRequestSize) override;

View File

@ -246,6 +246,16 @@ NullHttpChannel::RedirectTo(nsIURI* aNewURI) {
NS_IMETHODIMP
NullHttpChannel::UpgradeToSecure() { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
NullHttpChannel::GetRequestObserversCalled(bool* aCalled) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
NullHttpChannel::SetRequestObserversCalled(bool aCalled) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
NullHttpChannel::GetRequestContextID(uint64_t* _retval) {
return NS_ERROR_NOT_IMPLEMENTED;

View File

@ -350,6 +350,16 @@ ObliviousHttpChannel::UpgradeToSecure() {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
ObliviousHttpChannel::GetRequestObserversCalled(bool* aCalled) {
return mInnerChannel->GetRequestObserversCalled(aCalled);
}
NS_IMETHODIMP
ObliviousHttpChannel::SetRequestObserversCalled(bool aCalled) {
return mInnerChannel->SetRequestObserversCalled(aCalled);
}
NS_IMETHODIMP
ObliviousHttpChannel::GetRequestContextID(uint64_t* _retval) {
return mInnerChannel->GetRequestContextID(_retval);

View File

@ -494,4 +494,12 @@ interface nsIHttpChannel : nsIIdentChannel
[must_use] attribute AString classicScriptHintCharset;
[must_use] attribute AString documentCharacterSet;
/**
* Update the requestObserversCalled boolean flag.
*
* Used by WebDriver BiDi network interception to modify properties of the
* request such as `method` or `body` as late as possible.
*/
[must_use] attribute boolean requestObserversCalled;
};

View File

@ -994,6 +994,18 @@ nsViewSourceChannel::UpgradeToSecure() {
: mHttpChannel->UpgradeToSecure();
}
NS_IMETHODIMP
nsViewSourceChannel::GetRequestObserversCalled(bool* aCalled) {
return !mHttpChannel ? NS_ERROR_NULL_POINTER
: mHttpChannel->GetRequestObserversCalled(aCalled);
}
NS_IMETHODIMP
nsViewSourceChannel::SetRequestObserversCalled(bool aCalled) {
return !mHttpChannel ? NS_ERROR_NULL_POINTER
: mHttpChannel->SetRequestObserversCalled(aCalled);
}
NS_IMETHODIMP
nsViewSourceChannel::GetRequestContextID(uint64_t* _retval) {
return !mHttpChannel ? NS_ERROR_NULL_POINTER