зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1378342 - AbortSignal/AbortController - part 6 - Implement Request.signal, r=bkelly
This commit is contained in:
Родитель
e670c2c16a
Коммит
f533937740
|
@ -255,7 +255,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
|
|||
{
|
||||
if (aIn.type() == ResponseType::Error) {
|
||||
RefPtr<InternalResponse> error = InternalResponse::NetworkError();
|
||||
RefPtr<Response> r = new Response(GetGlobalObject(), error);
|
||||
RefPtr<Response> r = new Response(GetGlobalObject(), error, nullptr);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ TypeUtils::ToResponse(const CacheResponse& aIn)
|
|||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(ir);
|
||||
|
||||
RefPtr<Response> ref = new Response(GetGlobalObject(), ir);
|
||||
RefPtr<Response> ref = new Response(GetGlobalObject(), ir, nullptr);
|
||||
return ref.forget();
|
||||
}
|
||||
already_AddRefed<InternalRequest>
|
||||
|
@ -347,7 +347,8 @@ already_AddRefed<Request>
|
|||
TypeUtils::ToRequest(const CacheRequest& aIn)
|
||||
{
|
||||
RefPtr<InternalRequest> internalRequest = ToInternalRequest(aIn);
|
||||
RefPtr<Request> request = new Request(GetGlobalObject(), internalRequest);
|
||||
RefPtr<Request> request =
|
||||
new Request(GetGlobalObject(), internalRequest, nullptr);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,12 @@ public:
|
|||
return mSignalMainThread;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetSignalForTargetThread()
|
||||
{
|
||||
return mFollowingSignal;
|
||||
}
|
||||
|
||||
void
|
||||
Shutdown()
|
||||
{
|
||||
|
@ -173,7 +179,7 @@ public:
|
|||
}
|
||||
|
||||
AbortSignal*
|
||||
GetAbortSignal()
|
||||
GetAbortSignalForMainThread()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -184,6 +190,18 @@ public:
|
|||
return mSignalProxy->GetOrCreateSignalForMainThread();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetAbortSignalForTargetThread()
|
||||
{
|
||||
mPromiseProxy->GetWorkerPrivate()->AssertIsOnWorkerThread();
|
||||
|
||||
if (!mSignalProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mSignalProxy->GetSignalForTargetThread();
|
||||
}
|
||||
|
||||
void
|
||||
OnResponseAvailableInternal(InternalResponse* aResponse) override;
|
||||
|
||||
|
@ -217,14 +235,17 @@ class MainThreadFetchResolver final : public FetchDriverObserver
|
|||
RefPtr<Promise> mPromise;
|
||||
RefPtr<Response> mResponse;
|
||||
RefPtr<FetchObserver> mFetchObserver;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
||||
NS_DECL_OWNINGTHREAD
|
||||
public:
|
||||
MainThreadFetchResolver(Promise* aPromise, FetchObserver* aObserver)
|
||||
MainThreadFetchResolver(Promise* aPromise, FetchObserver* aObserver,
|
||||
AbortSignal* aSignal)
|
||||
: mPromise(aPromise)
|
||||
, mFetchObserver(aObserver)
|
||||
, mSignal(aSignal)
|
||||
{}
|
||||
|
||||
void
|
||||
|
@ -306,7 +327,7 @@ public:
|
|||
fetch->SetWorkerScript(spec);
|
||||
}
|
||||
|
||||
RefPtr<AbortSignal> signal = mResolver->GetAbortSignal();
|
||||
RefPtr<AbortSignal> signal = mResolver->GetAbortSignalForMainThread();
|
||||
|
||||
// ...but release it before calling Fetch, because mResolver's callback can
|
||||
// be called synchronously and they want the mutex, too.
|
||||
|
@ -347,12 +368,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
|||
}
|
||||
|
||||
RefPtr<InternalRequest> r = request->GetInternalRequest();
|
||||
|
||||
RefPtr<AbortSignal> signal;
|
||||
if (aInit.mSignal.WasPassed()) {
|
||||
signal = &aInit.mSignal.Value();
|
||||
// Let's FetchDriver to deal with an already aborted signal.
|
||||
}
|
||||
RefPtr<AbortSignal> signal = request->GetSignal();
|
||||
|
||||
RefPtr<FetchObserver> observer;
|
||||
if (aInit.mObserve.WasPassed()) {
|
||||
|
@ -395,7 +411,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
|
|||
Telemetry::Accumulate(Telemetry::FETCH_IS_MAINTHREAD, 1);
|
||||
|
||||
RefPtr<MainThreadFetchResolver> resolver =
|
||||
new MainThreadFetchResolver(p, observer);
|
||||
new MainThreadFetchResolver(p, observer, signal);
|
||||
RefPtr<FetchDriver> fetch =
|
||||
new FetchDriver(r, principal, loadGroup,
|
||||
aGlobal->EventTargetFor(TaskCategory::Other), isTrackingFetch);
|
||||
|
@ -443,7 +459,7 @@ MainThreadFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = mPromise->GetParentObject();
|
||||
mResponse = new Response(go, aResponse);
|
||||
mResponse = new Response(go, aResponse, mSignal);
|
||||
mPromise->MaybeResolve(mResponse);
|
||||
} else {
|
||||
if (mFetchObserver) {
|
||||
|
@ -506,7 +522,9 @@ public:
|
|||
}
|
||||
|
||||
RefPtr<nsIGlobalObject> global = aWorkerPrivate->GlobalScope();
|
||||
RefPtr<Response> response = new Response(global, mInternalResponse);
|
||||
RefPtr<Response> response =
|
||||
new Response(global, mInternalResponse,
|
||||
mResolver->GetAbortSignalForTargetThread());
|
||||
promise->MaybeResolve(response);
|
||||
} else {
|
||||
if (mResolver->mFetchObserver) {
|
||||
|
@ -1020,6 +1038,12 @@ already_AddRefed<Promise>
|
|||
FetchBody<Derived>::ConsumeBody(JSContext* aCx, FetchConsumeType aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<AbortSignal> signal = DerivedClass()->GetSignal();
|
||||
if (signal && signal->Aborted()) {
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
|
@ -1034,7 +1058,7 @@ FetchBody<Derived>::ConsumeBody(JSContext* aCx, FetchConsumeType aType,
|
|||
|
||||
RefPtr<Promise> promise =
|
||||
FetchBodyConsumer<Derived>::Create(global, mMainThreadEventTarget, this,
|
||||
aType, aRv);
|
||||
signal, aType, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -230,6 +230,9 @@ public:
|
|||
mFetchStreamReader = nullptr;
|
||||
}
|
||||
|
||||
virtual AbortSignal*
|
||||
GetSignal() const = 0;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIGlobalObject> mOwner;
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ template <class Derived>
|
|||
FetchBodyConsumer<Derived>::Create(nsIGlobalObject* aGlobal,
|
||||
nsIEventTarget* aMainThreadEventTarget,
|
||||
FetchBody<Derived>* aBody,
|
||||
AbortSignal* aSignal,
|
||||
FetchConsumeType aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
|
@ -361,6 +362,10 @@ FetchBodyConsumer<Derived>::Create(nsIGlobalObject* aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (aSignal) {
|
||||
consumer->Follow(aSignal);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
|
@ -381,6 +386,8 @@ FetchBodyConsumer<Derived>::ReleaseObject()
|
|||
mGlobal = nullptr;
|
||||
mWorkerHolder = nullptr;
|
||||
mBody = nullptr;
|
||||
|
||||
Unfollow();
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
|
@ -724,6 +731,14 @@ FetchBodyConsumer<Derived>::Observe(nsISupports* aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
FetchBodyConsumer<Derived>::Aborted()
|
||||
{
|
||||
AssertIsOnTargetThread();
|
||||
ContinueConsumeBody(NS_ERROR_DOM_ABORT_ERR, 0, nullptr);
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
NS_IMPL_ADDREF(FetchBodyConsumer<Derived>)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_FetchConsumer_h
|
||||
|
||||
#include "Fetch.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
@ -31,6 +32,7 @@ template <class Derived> class FetchBody;
|
|||
template <class Derived>
|
||||
class FetchBodyConsumer final : public nsIObserver
|
||||
, public nsSupportsWeakReference
|
||||
, public AbortSignal::Follower
|
||||
{
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
@ -40,6 +42,7 @@ public:
|
|||
Create(nsIGlobalObject* aGlobal,
|
||||
nsIEventTarget* aMainThreadEventTarget,
|
||||
FetchBody<Derived>* aBody,
|
||||
AbortSignal* aSignal,
|
||||
FetchConsumeType aType,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
@ -76,6 +79,9 @@ public:
|
|||
mConsumeBodyPump = nullptr;
|
||||
}
|
||||
|
||||
// AbortSignal::Follower
|
||||
void Aborted() override;
|
||||
|
||||
private:
|
||||
FetchBodyConsumer(nsIEventTarget* aMainThreadEventTarget,
|
||||
nsIGlobalObject* aGlobalObject,
|
||||
|
|
|
@ -31,12 +31,14 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(Request)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Request)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mHeaders)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSignal)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Request)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHeaders)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSignal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Request)
|
||||
|
@ -51,14 +53,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Request)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest)
|
||||
Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
|
||||
AbortSignal* aSignal)
|
||||
: FetchBody<Request>(aOwner)
|
||||
, mRequest(aRequest)
|
||||
, mSignal(aSignal)
|
||||
{
|
||||
MOZ_ASSERT(aRequest->Headers()->Guard() == HeadersGuardEnum::Immutable ||
|
||||
aRequest->Headers()->Guard() == HeadersGuardEnum::Request ||
|
||||
aRequest->Headers()->Guard() == HeadersGuardEnum::Request_no_cors);
|
||||
SetMimeType();
|
||||
|
||||
// aSignal can be null.
|
||||
}
|
||||
|
||||
Request::~Request()
|
||||
|
@ -300,6 +306,8 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
RefPtr<AbortSignal> signal;
|
||||
|
||||
if (aInput.IsRequest()) {
|
||||
RefPtr<Request> inputReq = &aInput.GetAsRequest();
|
||||
nsCOMPtr<nsIInputStream> body;
|
||||
|
@ -315,6 +323,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
request = inputReq->GetInternalRequest();
|
||||
signal = inputReq->GetOrCreateSignal();
|
||||
} else {
|
||||
// aInput is USVString.
|
||||
// We need to get url before we create a InternalRequest.
|
||||
|
@ -433,6 +442,10 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
request->SetReferrerPolicy(aInit.mReferrerPolicy.Value());
|
||||
}
|
||||
|
||||
if (aInit.mSignal.WasPassed()) {
|
||||
signal = &aInit.mSignal.Value();
|
||||
}
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
|
||||
if (window) {
|
||||
|
@ -597,7 +610,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<Request> domRequest = new Request(global, request);
|
||||
RefPtr<Request> domRequest = new Request(global, request, signal);
|
||||
domRequest->SetMimeType();
|
||||
|
||||
if (aInput.IsRequest()) {
|
||||
|
@ -616,7 +629,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
already_AddRefed<Request>
|
||||
Request::Clone(ErrorResult& aRv) const
|
||||
Request::Clone(ErrorResult& aRv)
|
||||
{
|
||||
if (BodyUsed()) {
|
||||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
|
@ -629,7 +642,8 @@ Request::Clone(ErrorResult& aRv) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Request> request = new Request(mOwner, ir);
|
||||
RefPtr<Request> request = new Request(mOwner, ir, GetOrCreateSignal());
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
|
@ -643,5 +657,21 @@ Request::Headers_()
|
|||
return mHeaders;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
Request::GetOrCreateSignal()
|
||||
{
|
||||
if (!mSignal) {
|
||||
mSignal = new AbortSignal(false);
|
||||
}
|
||||
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
Request::GetSignal() const
|
||||
{
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -32,7 +32,8 @@ class Request final : public nsISupports
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
|
||||
|
||||
public:
|
||||
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest);
|
||||
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
|
||||
AbortSignal* aSignal);
|
||||
|
||||
static bool
|
||||
RequestContextEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
@ -143,7 +144,7 @@ public:
|
|||
}
|
||||
|
||||
already_AddRefed<Request>
|
||||
Clone(ErrorResult& aRv) const;
|
||||
Clone(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
GetInternalRequest();
|
||||
|
@ -154,12 +155,21 @@ public:
|
|||
return mRequest->GetPrincipalInfo();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
GetOrCreateSignal();
|
||||
|
||||
// This can return a null AbortSignal.
|
||||
AbortSignal*
|
||||
GetSignal() const override;
|
||||
|
||||
private:
|
||||
~Request();
|
||||
|
||||
RefPtr<InternalRequest> mRequest;
|
||||
|
||||
// Lazily created.
|
||||
RefPtr<Headers> mHeaders;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -37,6 +37,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(Response)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Response)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mHeaders)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSignal)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFetchStreamReader)
|
||||
|
||||
tmp->mReadableStreamBody = nullptr;
|
||||
|
@ -48,6 +49,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Response)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHeaders)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSignal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFetchStreamReader)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
|
@ -62,9 +64,12 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Response)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
Response::Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse)
|
||||
Response::Response(nsIGlobalObject* aGlobal,
|
||||
InternalResponse* aInternalResponse,
|
||||
AbortSignal* aSignal)
|
||||
: FetchBody<Response>(aGlobal)
|
||||
, mInternalResponse(aInternalResponse)
|
||||
, mSignal(aSignal)
|
||||
{
|
||||
MOZ_ASSERT(aInternalResponse->Headers()->Guard() == HeadersGuardEnum::Immutable ||
|
||||
aInternalResponse->Headers()->Guard() == HeadersGuardEnum::Response);
|
||||
|
@ -83,7 +88,7 @@ Response::Error(const GlobalObject& aGlobal)
|
|||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<InternalResponse> error = InternalResponse::NetworkError();
|
||||
RefPtr<Response> r = new Response(global, error);
|
||||
RefPtr<Response> r = new Response(global, error, nullptr);
|
||||
return r.forget();
|
||||
}
|
||||
|
||||
|
@ -203,7 +208,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
|||
internalResponse->InitChannelInfo(worker->GetChannelInfo());
|
||||
}
|
||||
|
||||
RefPtr<Response> r = new Response(global, internalResponse);
|
||||
RefPtr<Response> r = new Response(global, internalResponse, nullptr);
|
||||
|
||||
if (aInit.mHeaders.WasPassed()) {
|
||||
internalResponse->Headers()->Clear();
|
||||
|
@ -342,7 +347,7 @@ Response::Clone(JSContext* aCx, ErrorResult& aRv)
|
|||
? InternalResponse::eDontCloneInputStream
|
||||
: InternalResponse::eCloneInputStream);
|
||||
|
||||
RefPtr<Response> response = new Response(mOwner, ir);
|
||||
RefPtr<Response> response = new Response(mOwner, ir, mSignal);
|
||||
|
||||
if (body) {
|
||||
// Maybe we have a body, but we receive null from MaybeTeeReadableStreamBody
|
||||
|
@ -385,7 +390,7 @@ Response::CloneUnfiltered(JSContext* aCx, ErrorResult& aRv)
|
|||
: InternalResponse::eCloneInputStream);
|
||||
|
||||
RefPtr<InternalResponse> ir = clone->Unfiltered();
|
||||
RefPtr<Response> ref = new Response(mOwner, ir);
|
||||
RefPtr<Response> ref = new Response(mOwner, ir, mSignal);
|
||||
|
||||
if (body) {
|
||||
// Maybe we have a body, but we receive null from MaybeTeeReadableStreamBody
|
||||
|
|
|
@ -33,7 +33,8 @@ class Response final : public nsISupports
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Response)
|
||||
|
||||
public:
|
||||
Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse);
|
||||
Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse,
|
||||
AbortSignal* aSignal);
|
||||
|
||||
Response(const Response& aOther) = delete;
|
||||
|
||||
|
@ -136,12 +137,19 @@ public:
|
|||
already_AddRefed<InternalResponse>
|
||||
GetInternalResponse() const;
|
||||
|
||||
AbortSignal*
|
||||
GetSignal() const override
|
||||
{
|
||||
return mSignal;
|
||||
}
|
||||
|
||||
private:
|
||||
~Response();
|
||||
|
||||
RefPtr<InternalResponse> mInternalResponse;
|
||||
// Lazily created
|
||||
RefPtr<Headers> mHeaders;
|
||||
RefPtr<AbortSignal> mSignal;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -81,7 +81,9 @@ FlyWebPublishedServer::FireFetchEvent(InternalRequest* aRequest)
|
|||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
||||
RefPtr<FlyWebFetchEvent> e = new FlyWebFetchEvent(this,
|
||||
new Request(global, aRequest),
|
||||
new Request(global,
|
||||
aRequest,
|
||||
nullptr),
|
||||
aRequest);
|
||||
e->Init(this);
|
||||
e->InitEvent(NS_LITERAL_STRING("fetch"), false, false);
|
||||
|
@ -94,7 +96,9 @@ FlyWebPublishedServer::FireWebsocketEvent(InternalRequest* aConnectRequest)
|
|||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
||||
RefPtr<FlyWebFetchEvent> e = new FlyWebWebSocketEvent(this,
|
||||
new Request(global, aConnectRequest),
|
||||
new Request(global,
|
||||
aConnectRequest,
|
||||
nullptr),
|
||||
aConnectRequest);
|
||||
e->Init(this);
|
||||
e->InitEvent(NS_LITERAL_STRING("websocket"), false, false);
|
||||
|
|
|
@ -27,6 +27,10 @@ interface Request {
|
|||
readonly attribute RequestRedirect redirect;
|
||||
readonly attribute DOMString integrity;
|
||||
|
||||
[Func="AbortController::IsEnabledInFetch",
|
||||
BinaryName="getOrCreateSignal"]
|
||||
readonly attribute AbortSignal signal;
|
||||
|
||||
[Throws,
|
||||
NewObject] Request clone();
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ private:
|
|||
ir->Headers()->FillResponseHeaders(loadInfo.mChannel);
|
||||
|
||||
RefPtr<mozilla::dom::Response> response =
|
||||
new mozilla::dom::Response(mCacheCreator->Global(), ir);
|
||||
new mozilla::dom::Response(mCacheCreator->Global(), ir, nullptr);
|
||||
|
||||
mozilla::dom::RequestOrUSVString request;
|
||||
|
||||
|
|
|
@ -1611,7 +1611,10 @@ private:
|
|||
if (NS_WARN_IF(!global)) {
|
||||
return false;
|
||||
}
|
||||
RefPtr<Request> request = new Request(global, internalReq);
|
||||
|
||||
// TODO This request object should be created with a AbortSignal object
|
||||
// which should be aborted if the loading is aborted. See bug 1394102.
|
||||
RefPtr<Request> request = new Request(global, internalReq, nullptr);
|
||||
|
||||
MOZ_ASSERT_IF(internalReq->IsNavigationRequest(),
|
||||
request->Redirect() == RequestRedirect::Manual);
|
||||
|
|
|
@ -596,7 +596,8 @@ private:
|
|||
RefPtr<InternalHeaders> internalHeaders = aCN->GetInternalHeaders();
|
||||
ir->Headers()->Fill(*(internalHeaders.get()), ignored);
|
||||
|
||||
RefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir);
|
||||
RefPtr<Response> response =
|
||||
new Response(aCache->GetGlobalObject(), ir, nullptr);
|
||||
|
||||
RequestOrUSVString request;
|
||||
request.SetAsUSVString().Rebind(aCN->URL().Data(), aCN->URL().Length());
|
||||
|
|
|
@ -1,42 +1,12 @@
|
|||
[general.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[Window: Request objects have a signal property]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal on request object]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal on request object created from request object]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal on request object created from request object, with signal on second request]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal on request object created from request object, with signal on second request overriding another]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal retained after unrelated properties are overridden by fetch]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Signal removed by setting to null]
|
||||
expected: FAIL
|
||||
|
||||
[Window: response.arrayBuffer() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[Window: response.blob() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[Window: response.formData() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[Window: response.json() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[Window: response.text() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[Window: Underlying connection is closed when aborting after receiving response - no-cors]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -52,45 +22,15 @@
|
|||
[Window: Readable stream synchronously cancels with AbortError if aborted before reading]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Request objects have a signal property]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal on request object]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal on request object created from request object]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal on request object created from request object, with signal on second request]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal on request object created from request object, with signal on second request overriding another]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal retained after unrelated properties are overridden by fetch]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Signal removed by setting to null]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Already aborted signal rejects immediately]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: response.arrayBuffer() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: response.blob() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: response.formData() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: response.json() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: response.text() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[DedicatedWorkerGlobalScope: Underlying connection is closed when aborting after receiving response - no-cors]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -106,45 +46,15 @@
|
|||
[DedicatedWorkerGlobalScope: Readable stream synchronously cancels with AbortError if aborted before reading]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Request objects have a signal property]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal on request object]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal on request object created from request object]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal on request object created from request object, with signal on second request]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal on request object created from request object, with signal on second request overriding another]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal retained after unrelated properties are overridden by fetch]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Signal removed by setting to null]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Already aborted signal rejects immediately]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: response.arrayBuffer() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: response.blob() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: response.formData() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: response.json() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: response.text() rejects if already aborted]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorkerGlobalScope: Underlying connection is closed when aborting after receiving response - no-cors]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче