mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 1637159 provide XMLHttpRequest owner via DOMEventTargetHelper constructor r=smaug
Depends on D75039 Differential Revision: https://phabricator.services.mozilla.com/D75041
This commit is contained in:
parent
d07bf2b285
commit
bba064955e
@ -42,8 +42,8 @@ already_AddRefed<XMLHttpRequest> XMLHttpRequest::Constructor(
|
||||
cookieJarSettings = net::CookieJarSettings::Create();
|
||||
}
|
||||
|
||||
RefPtr<XMLHttpRequestMainThread> req = new XMLHttpRequestMainThread();
|
||||
req->Construct(principal->GetPrincipal(), global, cookieJarSettings, false);
|
||||
RefPtr<XMLHttpRequestMainThread> req = new XMLHttpRequestMainThread(global);
|
||||
req->Construct(principal->GetPrincipal(), cookieJarSettings, false);
|
||||
req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
|
||||
return req.forget();
|
||||
}
|
||||
|
@ -127,6 +127,10 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget {
|
||||
JS::Handle<JSObject*> aGivenProto) override {
|
||||
return mozilla::dom::XMLHttpRequest_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit XMLHttpRequest(nsIGlobalObject* aGlobalObject)
|
||||
: XMLHttpRequestEventTarget(aGlobalObject) {}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -17,7 +17,8 @@ class XMLHttpRequestEventTarget : public DOMEventTargetHelper {
|
||||
explicit XMLHttpRequestEventTarget(DOMEventTargetHelper* aOwner)
|
||||
: DOMEventTargetHelper(aOwner) {}
|
||||
|
||||
XMLHttpRequestEventTarget() = default;
|
||||
explicit XMLHttpRequestEventTarget(nsIGlobalObject* aGlobalObject)
|
||||
: DOMEventTargetHelper(aGlobalObject) {}
|
||||
|
||||
virtual ~XMLHttpRequestEventTarget() = default;
|
||||
|
||||
|
@ -186,8 +186,10 @@ static void AddLoadFlags(nsIRequest* request, nsLoadFlags newFlags) {
|
||||
|
||||
bool XMLHttpRequestMainThread::sDontWarnAboutSyncXHR = false;
|
||||
|
||||
XMLHttpRequestMainThread::XMLHttpRequestMainThread()
|
||||
: mResponseBodyDecodedPos(0),
|
||||
XMLHttpRequestMainThread::XMLHttpRequestMainThread(
|
||||
nsIGlobalObject* aGlobalObject)
|
||||
: XMLHttpRequest(aGlobalObject),
|
||||
mResponseBodyDecodedPos(0),
|
||||
mResponseType(XMLHttpRequestResponseType::_empty),
|
||||
mRequestObserver(nullptr),
|
||||
mState(XMLHttpRequest_Binding::UNSENT),
|
||||
|
@ -210,16 +210,15 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
|
||||
ENUM_MAX
|
||||
};
|
||||
|
||||
XMLHttpRequestMainThread();
|
||||
explicit XMLHttpRequestMainThread(nsIGlobalObject* aGlobalObject);
|
||||
|
||||
void Construct(nsIPrincipal* aPrincipal, nsIGlobalObject* aGlobalObject,
|
||||
void Construct(nsIPrincipal* aPrincipal,
|
||||
nsICookieJarSettings* aCookieJarSettings, bool aForWorker,
|
||||
nsIURI* aBaseURI = nullptr, nsILoadGroup* aLoadGroup = nullptr,
|
||||
PerformanceStorage* aPerformanceStorage = nullptr,
|
||||
nsICSPEventListener* aCSPEventListener = nullptr) {
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
mPrincipal = aPrincipal;
|
||||
BindToOwner(aGlobalObject);
|
||||
mBaseURI = aBaseURI;
|
||||
mLoadGroup = aLoadGroup;
|
||||
mCookieJarSettings = aCookieJarSettings;
|
||||
|
@ -765,9 +765,9 @@ bool Proxy::Init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
mXHR = new XMLHttpRequestMainThread();
|
||||
mXHR = new XMLHttpRequestMainThread(ownerWindow ? ownerWindow->AsGlobal()
|
||||
: nullptr);
|
||||
mXHR->Construct(mWorkerPrivate->GetPrincipal(),
|
||||
ownerWindow ? ownerWindow->AsGlobal() : nullptr,
|
||||
mWorkerPrivate->CookieJarSettings(), true,
|
||||
mWorkerPrivate->GetBaseURI(), mWorkerPrivate->GetLoadGroup(),
|
||||
mWorkerPrivate->GetPerformanceStorage(),
|
||||
@ -1355,8 +1355,10 @@ void SendRunnable::RunOnMainThread(ErrorResult& aRv) {
|
||||
}
|
||||
}
|
||||
|
||||
XMLHttpRequestWorker::XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate)
|
||||
: mWorkerPrivate(aWorkerPrivate),
|
||||
XMLHttpRequestWorker::XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate,
|
||||
nsIGlobalObject* aGlobalObject)
|
||||
: XMLHttpRequest(aGlobalObject),
|
||||
mWorkerPrivate(aWorkerPrivate),
|
||||
mResponseType(XMLHttpRequestResponseType::_empty),
|
||||
mStateData(new StateData()),
|
||||
mResponseData(new ResponseData()),
|
||||
@ -1428,8 +1430,8 @@ already_AddRefed<XMLHttpRequest> XMLHttpRequestWorker::Construct(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<XMLHttpRequestWorker> xhr = new XMLHttpRequestWorker(workerPrivate);
|
||||
xhr->BindToOwner(global);
|
||||
RefPtr<XMLHttpRequestWorker> xhr =
|
||||
new XMLHttpRequestWorker(workerPrivate, global);
|
||||
|
||||
if (workerPrivate->XHRParamsAllowed()) {
|
||||
if (aParams.mMozSystem)
|
||||
|
@ -223,7 +223,8 @@ class XMLHttpRequestWorker final : public XMLHttpRequest {
|
||||
bool SendInProgress() const { return !!mWorkerRef; }
|
||||
|
||||
private:
|
||||
explicit XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate);
|
||||
XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate,
|
||||
nsIGlobalObject* aGlobalObject);
|
||||
~XMLHttpRequestWorker();
|
||||
|
||||
enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
|
||||
|
Loading…
Reference in New Issue
Block a user