Backed out changeset 86d1da74131f (bug 1264175) for causing mochitest failures in dom/serviceworkers/test/test_fetch_event.html CLOSED TREE

This commit is contained in:
shindli 2020-01-24 06:18:04 +02:00
Родитель a688008906
Коммит 78f9c85759
17 изменённых файлов: 82 добавлений и 27 удалений

Просмотреть файл

@ -9858,6 +9858,11 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
return rv;
}
// Document loads should set the reload flag on the channel so that it
// can be exposed on the service worker FetchEvent.
rv = loadInfo->SetIsDocshellReload(mLoadType & LOAD_CMD_RELOAD);
NS_ENSURE_SUCCESS(rv, rv);
if (aLoadState->GetIsFromProcessingFrameAttributes()) {
loadInfo->SetIsFromProcessingFrameAttributes();
}

Просмотреть файл

@ -118,6 +118,7 @@ FetchEvent::FetchEvent(EventTarget* aOwner)
: ExtendableEvent(aOwner),
mPreventDefaultLineNumber(0),
mPreventDefaultColumnNumber(0),
mIsReload(false),
mWaitToRespond(false) {}
FetchEvent::~FetchEvent() {}
@ -153,6 +154,7 @@ already_AddRefed<FetchEvent> FetchEvent::Constructor(
e->mRequest = aOptions.mRequest;
e->mClientId = aOptions.mClientId;
e->mResultingClientId = aOptions.mResultingClientId;
e->mIsReload = aOptions.mIsReload;
return e.forget();
}

Просмотреть файл

@ -144,6 +144,7 @@ class FetchEvent final : public ExtendableEvent {
nsString mResultingClientId;
uint32_t mPreventDefaultLineNumber;
uint32_t mPreventDefaultColumnNumber;
bool mIsReload;
bool mWaitToRespond;
protected:
@ -184,6 +185,8 @@ class FetchEvent final : public ExtendableEvent {
aResultingClientId = mResultingClientId;
}
bool IsReload() const { return mIsReload; }
void RespondWith(JSContext* aCx, Promise& aArg, ErrorResult& aRv);
// Pull in the Event version of PreventDefault so we don't get

Просмотреть файл

@ -1916,16 +1916,18 @@ class ContinueDispatchFetchEventRunnable : public Runnable {
RefPtr<ServiceWorkerPrivate> mServiceWorkerPrivate;
nsCOMPtr<nsIInterceptedChannel> mChannel;
nsCOMPtr<nsILoadGroup> mLoadGroup;
bool mIsReload;
public:
ContinueDispatchFetchEventRunnable(
ServiceWorkerPrivate* aServiceWorkerPrivate,
nsIInterceptedChannel* aChannel, nsILoadGroup* aLoadGroup)
nsIInterceptedChannel* aChannel, nsILoadGroup* aLoadGroup, bool aIsReload)
: Runnable(
"dom::ServiceWorkerManager::ContinueDispatchFetchEventRunnable"),
mServiceWorkerPrivate(aServiceWorkerPrivate),
mChannel(aChannel),
mLoadGroup(aLoadGroup) {
mLoadGroup(aLoadGroup),
mIsReload(aIsReload) {
MOZ_ASSERT(aServiceWorkerPrivate);
MOZ_ASSERT(aChannel);
}
@ -1996,7 +1998,7 @@ class ContinueDispatchFetchEventRunnable : public Runnable {
}
rv = mServiceWorkerPrivate->SendFetchEvent(mChannel, mLoadGroup, clientId,
resultingClientId);
resultingClientId, mIsReload);
if (NS_WARN_IF(NS_FAILED(rv))) {
HandleError();
}
@ -2162,7 +2164,8 @@ void ServiceWorkerManager::DispatchFetchEvent(nsIInterceptedChannel* aChannel,
RefPtr<ContinueDispatchFetchEventRunnable> continueRunnable =
new ContinueDispatchFetchEventRunnable(serviceWorker->WorkerPrivate(),
aChannel, loadGroup);
aChannel, loadGroup,
loadInfo->GetIsDocshellReload());
// When this service worker was registered, we also sent down the permissions
// for the runnable. They should have arrived by now, but we still need to

Просмотреть файл

@ -1530,6 +1530,7 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
fetchEventInit.mRequest = request;
fetchEventInit.mBubbles = false;
fetchEventInit.mCancelable = true;
fetchEventInit.mIsReload = args.isReload();
/**
* TODO: only expose the FetchEvent.clientId on subresource requests for

Просмотреть файл

@ -65,6 +65,7 @@ struct ServiceWorkerFetchEventOpArgs {
IPCInternalRequest internalRequest;
nsString clientId;
nsString resultingClientId;
bool isReload;
bool isNonSubresourceRequest;
};

Просмотреть файл

@ -1202,6 +1202,7 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable,
nsCString mMethod;
nsString mClientId;
nsString mResultingClientId;
bool mIsReload;
bool mMarkLaunchServiceWorkerEnd;
RequestCache mCacheMode;
RequestMode mRequestMode;
@ -1224,13 +1225,15 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable,
const nsACString& aScriptSpec,
nsMainThreadPtrHandle<ServiceWorkerRegistrationInfo>& aRegistration,
const nsAString& aClientId, const nsAString& aResultingClientId,
bool aMarkLaunchServiceWorkerEnd, bool aIsNonSubresourceRequest)
bool aIsReload, bool aMarkLaunchServiceWorkerEnd,
bool aIsNonSubresourceRequest)
: ExtendableFunctionalEventWorkerRunnable(aWorkerPrivate, aKeepAliveToken,
aRegistration),
mInterceptedChannel(aChannel),
mScriptSpec(aScriptSpec),
mClientId(aClientId),
mResultingClientId(aResultingClientId),
mIsReload(aIsReload),
mMarkLaunchServiceWorkerEnd(aMarkLaunchServiceWorkerEnd),
mCacheMode(RequestCache::Default),
mRequestMode(RequestMode::No_cors),
@ -1478,6 +1481,7 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable,
init.mResultingClientId = mResultingClientId;
}
init.mIsReload = mIsReload;
RefPtr<FetchEvent> event =
FetchEvent::Constructor(globalObj, NS_LITERAL_STRING("fetch"), init);
@ -1516,7 +1520,8 @@ NS_IMPL_ISUPPORTS_INHERITED(FetchEventRunnable, WorkerRunnable,
nsresult ServiceWorkerPrivate::SendFetchEvent(
nsIInterceptedChannel* aChannel, nsILoadGroup* aLoadGroup,
const nsAString& aClientId, const nsAString& aResultingClientId) {
const nsAString& aClientId, const nsAString& aResultingClientId,
bool aIsReload) {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
@ -1574,7 +1579,7 @@ nsresult ServiceWorkerPrivate::SendFetchEvent(
if (mInner) {
return mInner->SendFetchEvent(std::move(registration), aChannel, aClientId,
aResultingClientId);
aResultingClientId, aIsReload);
}
aChannel->SetLaunchServiceWorkerStart(TimeStamp::Now());
@ -1600,7 +1605,7 @@ nsresult ServiceWorkerPrivate::SendFetchEvent(
RefPtr<FetchEventRunnable> r = new FetchEventRunnable(
mWorkerPrivate, token, handle, mInfo->ScriptSpec(), regInfo, aClientId,
aResultingClientId, newWorkerCreated, isNonSubresourceRequest);
aResultingClientId, aIsReload, newWorkerCreated, isNonSubresourceRequest);
rv = r->Init();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

Просмотреть файл

@ -136,7 +136,7 @@ class ServiceWorkerPrivate final {
virtual nsresult SendFetchEvent(
RefPtr<ServiceWorkerRegistrationInfo> aRegistration,
nsCOMPtr<nsIInterceptedChannel> aChannel, const nsAString& aClientId,
const nsAString& aResultingClientId) = 0;
const nsAString& aResultingClientId, bool aIsReload) = 0;
virtual nsresult SpawnWorkerIfNeeded() = 0;
@ -177,7 +177,7 @@ class ServiceWorkerPrivate final {
nsresult SendFetchEvent(nsIInterceptedChannel* aChannel,
nsILoadGroup* aLoadGroup, const nsAString& aClientId,
const nsAString& aResultingClientId);
const nsAString& aResultingClientId, bool aIsReload);
bool MaybeStoreISupports(nsISupports* aSupports);

Просмотреть файл

@ -573,7 +573,7 @@ ServiceWorkerPrivateImpl::PendingFetchEvent::~PendingFetchEvent() {
nsresult ServiceWorkerPrivateImpl::SendFetchEvent(
RefPtr<ServiceWorkerRegistrationInfo> aRegistration,
nsCOMPtr<nsIInterceptedChannel> aChannel, const nsAString& aClientId,
const nsAString& aResultingClientId) {
const nsAString& aResultingClientId, bool aIsReload) {
AssertIsOnMainThread();
MOZ_ASSERT(mOuter);
MOZ_ASSERT(aRegistration);
@ -598,7 +598,7 @@ nsresult ServiceWorkerPrivateImpl::SendFetchEvent(
// FetchEventOpChild will fill in the IPCInternalRequest.
ServiceWorkerFetchEventOpArgs args(
mOuter->mInfo->ScriptSpec(), IPCInternalRequest(), nsString(aClientId),
nsString(aResultingClientId),
nsString(aResultingClientId), aIsReload,
nsContentUtils::IsNonSubresourceRequest(channel));
if (mOuter->mInfo->State() == ServiceWorkerState::Activating) {

Просмотреть файл

@ -85,7 +85,8 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
nsresult SendFetchEvent(RefPtr<ServiceWorkerRegistrationInfo> aRegistration,
nsCOMPtr<nsIInterceptedChannel> aChannel,
const nsAString& aClientId,
const nsAString& aResultingClientId) override;
const nsAString& aResultingClientId,
bool aIsReload) override;
nsresult SpawnWorkerIfNeeded() override;

Просмотреть файл

@ -15,6 +15,7 @@ interface FetchEvent : ExtendableEvent {
[SameObject, BinaryName="request_"] readonly attribute Request request;
readonly attribute DOMString clientId;
readonly attribute DOMString resultingClientId;
readonly attribute boolean isReload;
[Throws]
void respondWith(Promise<Response> r);
@ -24,4 +25,5 @@ dictionary FetchEventInit : EventInit {
required Request request;
DOMString clientId = "";
DOMString resultingClientId = "";
boolean isReload = false;
};

Просмотреть файл

@ -566,11 +566,11 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
aLoadInfo->GetFrameOuterWindowID(), aLoadInfo->GetBrowsingContextID(),
aLoadInfo->GetFrameBrowsingContextID(),
aLoadInfo->GetInitialSecurityCheckDone(),
aLoadInfo->GetIsInThirdPartyContext(), aLoadInfo->GetIsFormSubmission(),
aLoadInfo->GetSendCSPViolationEvents(), aLoadInfo->GetOriginAttributes(),
redirectChainIncludingInternalRedirects, redirectChain,
ancestorPrincipals, aLoadInfo->AncestorOuterWindowIDs(), ipcClientInfo,
ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
aLoadInfo->GetIsInThirdPartyContext(), aLoadInfo->GetIsDocshellReload(),
aLoadInfo->GetIsFormSubmission(), aLoadInfo->GetSendCSPViolationEvents(),
aLoadInfo->GetOriginAttributes(), redirectChainIncludingInternalRedirects,
redirectChain, ancestorPrincipals, aLoadInfo->AncestorOuterWindowIDs(),
ipcClientInfo, ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(),
aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(),
aLoadInfo->GetServiceWorkerTaintingSynthesized(),
@ -756,12 +756,13 @@ nsresult LoadInfoArgsToLoadInfo(
loadInfoArgs.topOuterWindowID(), loadInfoArgs.frameOuterWindowID(),
loadInfoArgs.browsingContextID(), loadInfoArgs.frameBrowsingContextID(),
loadInfoArgs.initialSecurityCheckDone(),
loadInfoArgs.isInThirdPartyContext(), loadInfoArgs.isFormSubmission(),
loadInfoArgs.sendCSPViolationEvents(), loadInfoArgs.originAttributes(),
redirectChainIncludingInternalRedirects, redirectChain,
std::move(ancestorPrincipals), loadInfoArgs.ancestorOuterWindowIDs(),
loadInfoArgs.corsUnsafeHeaders(), loadInfoArgs.forcePreflight(),
loadInfoArgs.isPreflight(), loadInfoArgs.loadTriggeredFromExternal(),
loadInfoArgs.isInThirdPartyContext(), loadInfoArgs.isDocshellReload(),
loadInfoArgs.isFormSubmission(), loadInfoArgs.sendCSPViolationEvents(),
loadInfoArgs.originAttributes(), redirectChainIncludingInternalRedirects,
redirectChain, std::move(ancestorPrincipals),
loadInfoArgs.ancestorOuterWindowIDs(), loadInfoArgs.corsUnsafeHeaders(),
loadInfoArgs.forcePreflight(), loadInfoArgs.isPreflight(),
loadInfoArgs.loadTriggeredFromExternal(),
loadInfoArgs.serviceWorkerTaintingSynthesized(),
loadInfoArgs.documentHasUserInteracted(),
loadInfoArgs.documentHasLoaded(),

Просмотреть файл

@ -90,6 +90,7 @@ LoadInfo::LoadInfo(
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false),
mIsDocshellReload(false),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
@ -352,6 +353,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false), // NB: TYPE_DOCUMENT implies !third-party.
mIsDocshellReload(false),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
@ -462,6 +464,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
mFrameBrowsingContextID(rhs.mFrameBrowsingContextID),
mInitialSecurityCheckDone(rhs.mInitialSecurityCheckDone),
mIsThirdPartyContext(rhs.mIsThirdPartyContext),
mIsDocshellReload(rhs.mIsDocshellReload),
mIsFormSubmission(rhs.mIsFormSubmission),
mSendCSPViolationEvents(rhs.mSendCSPViolationEvents),
mOriginAttributes(rhs.mOriginAttributes),
@ -508,8 +511,8 @@ LoadInfo::LoadInfo(
uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
bool aInitialSecurityCheckDone, bool aIsThirdPartyContext,
bool aIsFormSubmission, bool aSendCSPViolationEvents,
const OriginAttributes& aOriginAttributes,
bool aIsDocshellReload, bool aIsFormSubmission,
bool aSendCSPViolationEvents, const OriginAttributes& aOriginAttributes,
RedirectHistoryArray& aRedirectChainIncludingInternalRedirects,
RedirectHistoryArray& aRedirectChain,
nsTArray<nsCOMPtr<nsIPrincipal>>&& aAncestorPrincipals,
@ -559,6 +562,7 @@ LoadInfo::LoadInfo(
mFrameBrowsingContextID(aFrameBrowsingContextID),
mInitialSecurityCheckDone(aInitialSecurityCheckDone),
mIsThirdPartyContext(aIsThirdPartyContext),
mIsDocshellReload(aIsDocshellReload),
mIsFormSubmission(aIsFormSubmission),
mSendCSPViolationEvents(aSendCSPViolationEvents),
mOriginAttributes(aOriginAttributes),
@ -883,6 +887,18 @@ LoadInfo::GetLoadErrorPage(bool* aResult) {
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetIsDocshellReload(bool* aResult) {
*aResult = mIsDocshellReload;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::SetIsDocshellReload(bool aValue) {
mIsDocshellReload = aValue;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetIsFormSubmission(bool* aResult) {
*aResult = mIsFormSubmission;

Просмотреть файл

@ -146,7 +146,8 @@ class LoadInfo final : public nsILoadInfo {
uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
bool aInitialSecurityCheckDone, bool aIsThirdPartyRequest,
bool aIsFormSubmission, bool aSendCSPViolationEvents,
bool aIsDocshellReload, bool aIsFormSubmission,
bool aSendCSPViolationEvents,
const OriginAttributes& aOriginAttributes,
RedirectHistoryArray& aRedirectChainIncludingInternalRedirects,
RedirectHistoryArray& aRedirectChain,
@ -236,6 +237,7 @@ class LoadInfo final : public nsILoadInfo {
uint64_t mFrameBrowsingContextID;
bool mInitialSecurityCheckDone;
bool mIsThirdPartyContext;
bool mIsDocshellReload;
bool mIsFormSubmission;
bool mSendCSPViolationEvents;
OriginAttributes mOriginAttributes;

Просмотреть файл

@ -511,6 +511,15 @@ interface nsILoadInfo : nsISupports
*/
[infallible] readonly attribute boolean loadErrorPage;
/**
* Returns true if this is a non-subresource request that was triggered
* by docshell with the LOAD_CMD_RELOAD flag set. Note, this is more
* specific than looking at the load flags which indicate whether to
* bypass the http cache. The load flags can be set for other reasons,
* so they can't be used to infer this value.
*/
[infallible] attribute boolean isDocshellReload;
/**
* True if the load was initiated by a form request.
* This is important to know to handle the CSP directive navigate-to.

Просмотреть файл

@ -98,6 +98,7 @@ struct LoadInfoArgs
uint64_t frameBrowsingContextID;
bool initialSecurityCheckDone;
bool isInThirdPartyContext;
bool isDocshellReload;
bool isFormSubmission;
bool sendCSPViolationEvents;
OriginAttributes originAttributes;

Просмотреть файл

@ -41,6 +41,9 @@
[ServiceWorkerRegistration interface: self.registration must inherit property "navigationPreload" with the proper type]
expected: FAIL
[Event constructors]
expected: FAIL
[ServiceWorkerGlobalScope interface: self must inherit property "serviceWorker" with the proper type]
expected: FAIL