зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1149987) for mochitest crashes.
Backed out changeset b62e371d6189 (bug 1149987) Backed out changeset daa762fca8e6 (bug 1149987) Backed out changeset bdb64d5befa5 (bug 1149987) Backed out changeset 693901a4bcde (bug 1149987) Backed out changeset e7c41c8653c4 (bug 1149987) CLOSED TREE
This commit is contained in:
Родитель
efdecf747e
Коммит
d8ade60200
|
@ -13,7 +13,6 @@
|
|||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "AccessCheck.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
@ -47,7 +46,6 @@
|
|||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "WorkerPrivate.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "ipc/ErrorIPCUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -151,31 +149,6 @@ ErrorResult::ThrowErrorWithMessage(va_list ap, const dom::ErrNum errorNumber,
|
|||
mMessage = message;
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::SerializeMessage(IPC::Message* aMsg) const
|
||||
{
|
||||
using namespace IPC;
|
||||
MOZ_ASSERT(mMessage);
|
||||
WriteParam(aMsg, mMessage->mArgs);
|
||||
WriteParam(aMsg, mMessage->mErrorNumber);
|
||||
}
|
||||
|
||||
bool
|
||||
ErrorResult::DeserializeMessage(const IPC::Message* aMsg, void** aIter)
|
||||
{
|
||||
using namespace IPC;
|
||||
nsAutoPtr<Message> readMessage(new Message());
|
||||
if (!ReadParam(aMsg, aIter, &readMessage->mArgs) ||
|
||||
!ReadParam(aMsg, aIter, &readMessage->mErrorNumber)) {
|
||||
return false;
|
||||
}
|
||||
if (mMessage) {
|
||||
delete mMessage;
|
||||
}
|
||||
mMessage = readMessage.forget();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...)
|
||||
{
|
||||
|
@ -328,37 +301,6 @@ ErrorResult::ReportNotEnoughArgsError(JSContext* cx,
|
|||
ThrowErrorMessage(cx, dom::MSG_MISSING_ARGUMENTS, errorMessage.get());
|
||||
}
|
||||
|
||||
ErrorResult&
|
||||
ErrorResult::operator=(ErrorResult&& aRHS)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mMightHaveUnreportedJSException = aRHS.mMightHaveUnreportedJSException;
|
||||
aRHS.mMightHaveUnreportedJSException = false;
|
||||
#endif
|
||||
if (aRHS.IsErrorWithMessage()) {
|
||||
mMessage = aRHS.mMessage;
|
||||
aRHS.mMessage = nullptr;
|
||||
} else if (aRHS.IsJSException()) {
|
||||
JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
|
||||
MOZ_ASSERT(cx);
|
||||
mJSException.setUndefined();
|
||||
if (!js::AddRawValueRoot(cx, &mJSException, "ErrorResult::mJSException")) {
|
||||
MOZ_CRASH("Could not root mJSException, we're about to OOM");
|
||||
}
|
||||
mJSException = aRHS.mJSException;
|
||||
aRHS.mJSException.setUndefined();
|
||||
js::RemoveRawValueRoot(cx, &aRHS.mJSException);
|
||||
} else {
|
||||
// Null out the union on both sides for hygiene purposes.
|
||||
mMessage = aRHS.mMessage = nullptr;
|
||||
}
|
||||
// Note: It's important to do this last, since this affects the condition
|
||||
// checks above!
|
||||
mResult = aRHS.mResult;
|
||||
aRHS.mResult = NS_OK;
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
bool
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Move.h"
|
||||
|
||||
#ifndef IPC_ErrorIPCUtils_h
|
||||
#define IPC_ErrorIPCUtils_h
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::dom::ErrNum> :
|
||||
public ContiguousEnumSerializer<mozilla::dom::ErrNum,
|
||||
mozilla::dom::ErrNum(0),
|
||||
mozilla::dom::ErrNum(mozilla::dom::Err_Limit)> {};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::ErrorResult>
|
||||
{
|
||||
typedef mozilla::ErrorResult paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
// It should be the case that mMightHaveUnreportedJSException can only be
|
||||
// true when we're expecting a JS exception. We cannot send such messages
|
||||
// over the IPC channel since there is no sane way of transferring the JS
|
||||
// value over to the other side. Callers should never do that.
|
||||
MOZ_ASSERT_IF(aParam.IsJSException(), aParam.mMightHaveUnreportedJSException);
|
||||
if (aParam.IsJSException()
|
||||
#ifdef DEBUG
|
||||
|| aParam.mMightHaveUnreportedJSException
|
||||
#endif
|
||||
) {
|
||||
MOZ_CRASH("Cannot encode an ErrorResult representing a Javascript exception");
|
||||
}
|
||||
|
||||
WriteParam(aMsg, aParam.mResult);
|
||||
WriteParam(aMsg, aParam.IsErrorWithMessage());
|
||||
if (aParam.IsErrorWithMessage()) {
|
||||
aParam.SerializeMessage(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
paramType readValue;
|
||||
if (!ReadParam(aMsg, aIter, &readValue.mResult)) {
|
||||
return false;
|
||||
}
|
||||
bool hasMessage = false;
|
||||
if (!ReadParam(aMsg, aIter, &hasMessage)) {
|
||||
return false;
|
||||
}
|
||||
if (hasMessage && !readValue.DeserializeMessage(aMsg, aIter)) {
|
||||
return false;
|
||||
}
|
||||
*aResult = Move(readValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -17,12 +17,6 @@
|
|||
#include "nscore.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Move.h"
|
||||
|
||||
namespace IPC {
|
||||
class Message;
|
||||
template <typename> struct ParamTraits;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -62,12 +56,6 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
ErrorResult(ErrorResult&& aRHS)
|
||||
{
|
||||
*this = Move(aRHS);
|
||||
}
|
||||
ErrorResult& operator=(ErrorResult&& aRHS);
|
||||
|
||||
void Throw(nsresult rv) {
|
||||
MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
|
||||
MOZ_ASSERT(rv != NS_ERROR_TYPE_ERR, "Use ThrowTypeError()");
|
||||
|
@ -173,10 +161,6 @@ private:
|
|||
JS::Value mJSException; // valid when IsJSException()
|
||||
};
|
||||
|
||||
friend struct IPC::ParamTraits<ErrorResult>;
|
||||
void SerializeMessage(IPC::Message* aMsg) const;
|
||||
bool DeserializeMessage(const IPC::Message* aMsg, void** aIter);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Used to keep track of codepaths that might throw JS exceptions,
|
||||
// for assertion purposes.
|
||||
|
@ -186,7 +170,6 @@ private:
|
|||
// Not to be implemented, to make sure people always pass this by
|
||||
// reference, not by value.
|
||||
ErrorResult(const ErrorResult&) = delete;
|
||||
void operator=(const ErrorResult&) = delete;
|
||||
void ThrowErrorWithMessage(va_list ap, const dom::ErrNum errorNumber,
|
||||
nsresult errorType);
|
||||
};
|
||||
|
|
|
@ -73,5 +73,4 @@ MSG_DEF(MSG_INVALID_RESPONSE_STATUSCODE_ERROR, 0, JSEXN_RANGEERR, "Invalid respo
|
|||
MSG_DEF(MSG_INVALID_REDIRECT_STATUSCODE_ERROR, 0, JSEXN_RANGEERR, "Invalid redirect status code.")
|
||||
MSG_DEF(MSG_INVALID_URL_SCHEME, 2, JSEXN_TYPEERR, "{0} URL {1} must be either http:// or https://.")
|
||||
MSG_DEF(MSG_RESPONSE_URL_IS_NULL, 0, JSEXN_TYPEERR, "Cannot set Response.finalURL when Response.url is null.")
|
||||
MSG_DEF(MSG_RESPONSE_HAS_VARY_STAR, 0, JSEXN_TYPEERR, "Invalid Response object with a 'Vary: *' header.")
|
||||
MSG_DEF(MSG_BAD_FORMDATA, 0, JSEXN_TYPEERR, "Could not parse content as FormData.")
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
|
||||
TEST_DIRS += ['test']
|
||||
|
||||
EXPORTS.ipc += [
|
||||
'ErrorIPCUtils.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'ErrorResult.h',
|
||||
]
|
||||
|
|
|
@ -452,16 +452,12 @@ Cache::RecvMatchAllResponse(RequestId aRequestId, nsresult aRv,
|
|||
}
|
||||
|
||||
void
|
||||
Cache::RecvAddAllResponse(RequestId aRequestId,
|
||||
const mozilla::ErrorResult& aError)
|
||||
Cache::RecvAddAllResponse(RequestId aRequestId, nsresult aRv)
|
||||
{
|
||||
nsRefPtr<Promise> promise = RemoveRequestPromise(aRequestId);
|
||||
|
||||
if (aError.Failed()) {
|
||||
// TODO: Remove this const_cast (bug 1152078).
|
||||
// It is safe for now since this ErrorResult is handed off to us by IPDL
|
||||
// and is thrown into the trash afterwards.
|
||||
promise->MaybeReject(const_cast<ErrorResult&>(aError));
|
||||
if (NS_FAILED(aRv)) {
|
||||
promise->MaybeReject(aRv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,7 @@ public:
|
|||
const PCacheResponseOrVoid& aResponse);
|
||||
void RecvMatchAllResponse(RequestId aRequestId, nsresult aRv,
|
||||
const nsTArray<PCacheResponse>& aResponses);
|
||||
void RecvAddAllResponse(RequestId aRequestId,
|
||||
const mozilla::ErrorResult& aError);
|
||||
void RecvAddAllResponse(RequestId aRequestId, nsresult aRv);
|
||||
void RecvPutResponse(RequestId aRequestId, nsresult aRv);
|
||||
|
||||
void RecvDeleteResponse(RequestId aRequestId, nsresult aRv,
|
||||
|
|
|
@ -146,13 +146,12 @@ CacheChild::RecvMatchAllResponse(const RequestId& requestId, const nsresult& aRv
|
|||
}
|
||||
|
||||
bool
|
||||
CacheChild::RecvAddAllResponse(const RequestId& requestId,
|
||||
const mozilla::ErrorResult& aError)
|
||||
CacheChild::RecvAddAllResponse(const RequestId& requestId, const nsresult& aRv)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheChild);
|
||||
nsRefPtr<Cache> listener = mListener;
|
||||
if (listener) {
|
||||
listener->RecvAddAllResponse(requestId, aError);
|
||||
listener->RecvAddAllResponse(requestId, aRv);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
nsTArray<PCacheResponse>&& responses) override;
|
||||
virtual bool
|
||||
RecvAddAllResponse(const RequestId& requestId,
|
||||
const mozilla::ErrorResult& aError) override;
|
||||
const nsresult& aRv) override;
|
||||
virtual bool
|
||||
RecvPutResponse(const RequestId& aRequestId,
|
||||
const nsresult& aRv) override;
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace cache {
|
||||
|
||||
using mozilla::dom::ErrNum;
|
||||
using mozilla::ipc::FileDescriptorSetParent;
|
||||
using mozilla::ipc::PFileDescriptorSetParent;
|
||||
|
||||
|
@ -122,10 +121,7 @@ CacheParent::RecvAddAll(const RequestId& aRequestId,
|
|||
aRequests, requestStreams,
|
||||
getter_AddRefs(fetchPut));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
MOZ_ASSERT(rv != NS_ERROR_TYPE_ERR);
|
||||
ErrorResult error;
|
||||
error.Throw(rv);
|
||||
if (!SendAddAllResponse(aRequestId, error)) {
|
||||
if (!SendAddAllResponse(aRequestId, rv)) {
|
||||
// child process is gone, warn and allow actor to clean up normally
|
||||
NS_WARNING("Cache failed to send AddAll response.");
|
||||
}
|
||||
|
@ -260,7 +256,7 @@ CacheParent::OnCacheKeys(RequestId aRequestId, nsresult aRv,
|
|||
}
|
||||
|
||||
void
|
||||
CacheParent::OnFetchPut(FetchPut* aFetchPut, RequestId aRequestId, const ErrorResult& aRv)
|
||||
CacheParent::OnFetchPut(FetchPut* aFetchPut, RequestId aRequestId, nsresult aRv)
|
||||
{
|
||||
aFetchPut->ClearListener();
|
||||
mFetchPutList.RemoveElement(aFetchPut);
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
// FetchPut::Listener methods
|
||||
virtual void OnFetchPut(FetchPut* aFetchPut, RequestId aRequestId,
|
||||
const mozilla::ErrorResult& aRv) override;
|
||||
nsresult aRv) override;
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
DeserializeCacheStream(const PCacheReadStreamOrVoid& aStreamOrVoid);
|
||||
|
|
|
@ -944,9 +944,9 @@ DBSchema::MatchByVaryHeader(mozIStorageConnection* aConn,
|
|||
for (; token;
|
||||
token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer)) {
|
||||
nsDependentCString header(token);
|
||||
MOZ_ASSERT(!header.EqualsLiteral("*"),
|
||||
"We should have already caught this in "
|
||||
"TypeUtils::ToPCacheResponseWithoutBody()");
|
||||
if (header.EqualsLiteral("*")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ErrorResult errorResult;
|
||||
nsAutoCString queryValue;
|
||||
|
|
|
@ -136,6 +136,7 @@ FetchPut::FetchPut(Listener* aListener, Manager* aManager,
|
|||
, mInitiatingThread(NS_GetCurrentThread())
|
||||
, mStateList(aRequests.Length())
|
||||
, mPendingCount(0)
|
||||
, mResult(NS_OK)
|
||||
{
|
||||
MOZ_ASSERT(mListener);
|
||||
MOZ_ASSERT(mManager);
|
||||
|
@ -156,7 +157,6 @@ FetchPut::~FetchPut()
|
|||
MOZ_ASSERT(!mListener);
|
||||
mManager->RemoveListener(this);
|
||||
mManager->ReleaseCacheId(mCacheId);
|
||||
mResult.ClearMessage(); // This may contain a TypeError.
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -249,7 +249,7 @@ FetchPut::FetchComplete(FetchObserver* aObserver,
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aInternalResponse->IsError() && !mResult.Failed()) {
|
||||
if (aInternalResponse->IsError() && NS_SUCCEEDED(mResult)) {
|
||||
MaybeSetError(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -259,10 +259,10 @@ FetchPut::FetchComplete(FetchObserver* aObserver,
|
|||
ToPCacheResponseWithoutBody(mStateList[i].mPCacheResponse,
|
||||
*aInternalResponse, rv);
|
||||
if (rv.Failed()) {
|
||||
mResult = Move(rv);
|
||||
} else {
|
||||
aInternalResponse->GetBody(getter_AddRefs(mStateList[i].mResponseStream));
|
||||
MaybeSetError(rv.ErrorCode());
|
||||
return;
|
||||
}
|
||||
aInternalResponse->GetBody(getter_AddRefs(mStateList[i].mResponseStream));
|
||||
mStateList[i].mFetchObserver = nullptr;
|
||||
MOZ_ASSERT(mPendingCount > 0);
|
||||
mPendingCount -= 1;
|
||||
|
@ -291,7 +291,7 @@ FetchPut::DoPutOnWorkerThread()
|
|||
{
|
||||
MOZ_ASSERT(mInitiatingThread == NS_GetCurrentThread());
|
||||
|
||||
if (mResult.Failed()) {
|
||||
if (NS_FAILED(mResult)) {
|
||||
MaybeNotifyListener();
|
||||
return;
|
||||
}
|
||||
|
@ -377,9 +377,9 @@ FetchPut::MatchInPutList(const PCacheRequest& aRequest,
|
|||
for (; token;
|
||||
token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer)) {
|
||||
nsDependentCString header(token);
|
||||
MOZ_ASSERT(!header.EqualsLiteral("*"),
|
||||
"We should have already caught this in "
|
||||
"TypeUtils::ToPCacheResponseWithoutBody()");
|
||||
if (header.EqualsLiteral("*")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ErrorResult headerRv;
|
||||
nsAutoCString value;
|
||||
|
@ -428,10 +428,10 @@ FetchPut::OnCachePutAll(RequestId aRequestId, nsresult aRv)
|
|||
void
|
||||
FetchPut::MaybeSetError(nsresult aRv)
|
||||
{
|
||||
if (mResult.Failed() || NS_SUCCEEDED(aRv)) {
|
||||
if (NS_FAILED(mResult) || NS_SUCCEEDED(aRv)) {
|
||||
return;
|
||||
}
|
||||
mResult.Throw(aRv);
|
||||
mResult = aRv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -442,7 +442,6 @@ FetchPut::MaybeNotifyListener()
|
|||
return;
|
||||
}
|
||||
mListener->OnFetchPut(this, mRequestId, mResult);
|
||||
mResult.ClearMessage(); // This may contain a TypeError.
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/cache/Manager.h"
|
||||
#include "mozilla/dom/cache/PCacheTypes.h"
|
||||
#include "mozilla/dom/cache/Types.h"
|
||||
|
@ -40,7 +39,7 @@ public:
|
|||
{
|
||||
public:
|
||||
virtual void
|
||||
OnFetchPut(FetchPut* aFetchPut, RequestId aRequestId, const ErrorResult& aRv) = 0;
|
||||
OnFetchPut(FetchPut* aFetchPut, RequestId aRequestId, nsresult aRv) = 0;
|
||||
};
|
||||
|
||||
static nsresult
|
||||
|
@ -105,7 +104,7 @@ private:
|
|||
nsCOMPtr<nsIThread> mInitiatingThread;
|
||||
nsTArray<State> mStateList;
|
||||
uint32_t mPendingCount;
|
||||
ErrorResult mResult;
|
||||
nsresult mResult;
|
||||
nsCOMPtr<nsIRunnable> mRunnable;
|
||||
|
||||
public:
|
||||
|
|
|
@ -11,7 +11,6 @@ include protocol PBlob; // FIXME: bug 792908
|
|||
include protocol PCacheStreamControl;
|
||||
|
||||
using mozilla::dom::cache::RequestId from "mozilla/dom/cache/Types.h";
|
||||
using mozilla::ErrorResult from "ipc/ErrorIPCUtils.h";
|
||||
include "mozilla/dom/cache/IPCUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -36,7 +35,7 @@ parent:
|
|||
child:
|
||||
MatchResponse(RequestId requestId, nsresult aRv, PCacheResponseOrVoid aResponse);
|
||||
MatchAllResponse(RequestId requestId, nsresult aRv, PCacheResponse[] responses);
|
||||
AddAllResponse(RequestId requestId, ErrorResult aRv);
|
||||
AddAllResponse(RequestId requestId, nsresult aRv);
|
||||
PutResponse(RequestId requestId, nsresult aRv);
|
||||
DeleteResponse(RequestId requestId, nsresult aRv, bool success);
|
||||
KeysResponse(RequestId requestId, nsresult aRv, PCacheRequest[] requests);
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include "nsStreamUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsURLParsers.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsHttp.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -106,29 +104,6 @@ ProcessURL(nsAString& aUrl, bool* aSchemeValidOut,
|
|||
*aUrlWithoutQueryOut = Substring(aUrl, 0, queryPos - 1);
|
||||
}
|
||||
|
||||
static bool
|
||||
HasVaryStar(mozilla::dom::InternalHeaders* aHeaders)
|
||||
{
|
||||
nsAutoTArray<nsCString, 16> varyHeaders;
|
||||
ErrorResult rv;
|
||||
aHeaders->GetAll(NS_LITERAL_CSTRING("vary"), varyHeaders, rv);
|
||||
MOZ_ALWAYS_TRUE(!rv.Failed());
|
||||
|
||||
for (uint32_t i = 0; i < varyHeaders.Length(); ++i) {
|
||||
nsAutoCString varyValue(varyHeaders[i]);
|
||||
char* rawBuffer = varyValue.BeginWriting();
|
||||
char* token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer);
|
||||
for (; token;
|
||||
token = nsCRT::strtok(rawBuffer, NS_HTTP_HEADER_SEPS, &rawBuffer)) {
|
||||
nsDependentCString header(token);
|
||||
if (header.EqualsLiteral("*")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
SerializeNormalStream(nsIInputStream* aStream, PCacheReadStream& aReadStreamOut)
|
||||
{
|
||||
|
@ -291,10 +266,6 @@ TypeUtils::ToPCacheResponseWithoutBody(PCacheResponse& aOut,
|
|||
aOut.statusText() = aIn.GetStatusText();
|
||||
nsRefPtr<InternalHeaders> headers = aIn.UnfilteredHeaders();
|
||||
MOZ_ASSERT(headers);
|
||||
if (HasVaryStar(headers)) {
|
||||
aRv.ThrowTypeError(MSG_RESPONSE_HAS_VARY_STAR);
|
||||
return;
|
||||
}
|
||||
headers->GetPHeaders(aOut.headers());
|
||||
aOut.headersGuard() = headers->Guard();
|
||||
aOut.securityInfo() = aIn.GetSecurityInfo();
|
||||
|
@ -310,9 +281,6 @@ TypeUtils::ToPCacheResponse(PCacheResponse& aOut, Response& aIn, ErrorResult& aR
|
|||
|
||||
nsRefPtr<InternalResponse> ir = aIn.GetInternalResponse();
|
||||
ToPCacheResponseWithoutBody(aOut, *ir, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
aIn.GetBody(getter_AddRefs(stream));
|
||||
|
|
|
@ -107,59 +107,15 @@ function testBasicKeys() {
|
|||
}
|
||||
|
||||
function testStar() {
|
||||
function ensurePromiseRejected(promise) {
|
||||
return promise
|
||||
.then(function() {
|
||||
ok(false, "Promise should be rejected");
|
||||
}, function(err) {
|
||||
is(err.name, "TypeError", "Attempting to store a Response with a Vary:* header must fail");
|
||||
});
|
||||
}
|
||||
var test;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var cache;
|
||||
caches.open(name).then(function(c) {
|
||||
cache = c;
|
||||
Promise.all([
|
||||
ensurePromiseRejected(
|
||||
cache.add(new Request(requestURL + "1", {headers: {"WhatToVary": "*"}}))),
|
||||
ensurePromiseRejected(
|
||||
cache.addAll([
|
||||
new Request(requestURL + "2", {headers: {"WhatToVary": "*"}}),
|
||||
requestURL + "3",
|
||||
])),
|
||||
ensurePromiseRejected(
|
||||
fetch(new Request(requestURL + "4", {headers: {"WhatToVary": "*"}}))
|
||||
.then(function(response) {
|
||||
return cache.put(requestURL + "4", response);
|
||||
})),
|
||||
ensurePromiseRejected(
|
||||
cache.add(new Request(requestURL + "5", {headers: {"WhatToVary": "*,User-Agent"}}))),
|
||||
ensurePromiseRejected(
|
||||
cache.addAll([
|
||||
new Request(requestURL + "6", {headers: {"WhatToVary": "*,User-Agent"}}),
|
||||
requestURL + "7",
|
||||
])),
|
||||
ensurePromiseRejected(
|
||||
fetch(new Request(requestURL + "8", {headers: {"WhatToVary": "*,User-Agent"}}))
|
||||
.then(function(response) {
|
||||
return cache.put(requestURL + "8", response);
|
||||
})),
|
||||
ensurePromiseRejected(
|
||||
cache.add(new Request(requestURL + "9", {headers: {"WhatToVary": "User-Agent,*"}}))),
|
||||
ensurePromiseRejected(
|
||||
cache.addAll([
|
||||
new Request(requestURL + "10", {headers: {"WhatToVary": "User-Agent,*"}}),
|
||||
requestURL + "10",
|
||||
])),
|
||||
ensurePromiseRejected(
|
||||
fetch(new Request(requestURL + "11", {headers: {"WhatToVary": "User-Agent,*"}}))
|
||||
.then(function(response) {
|
||||
return cache.put(requestURL + "11", response);
|
||||
})),
|
||||
]).then(reject, resolve);
|
||||
return setupTest({"WhatToVary": "*", "Cookie": "foo=bar"})
|
||||
.then(function(t) {
|
||||
test = t;
|
||||
// Ensure that searching with a different Cookie header with Vary:* succeeds.
|
||||
return test.cache.match(new Request(requestURL, {headers: {"Cookie": "bar=baz"}}));
|
||||
}).then(function(r) {
|
||||
return checkResponse(r, test.response, test.responseText);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testMatch() {
|
||||
|
@ -178,6 +134,23 @@ function testMatch() {
|
|||
});
|
||||
}
|
||||
|
||||
function testStarAndAnotherHeader() {
|
||||
var test;
|
||||
return setupTest({"WhatToVary": "*,User-Agent"})
|
||||
.then(function(t) {
|
||||
test = t;
|
||||
// Ensure that searching with a different User-Agent header fails.
|
||||
return test.cache.match(new Request(requestURL, {headers: {"User-Agent": "MyUA"}}));
|
||||
}).then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for a request with a non-matching User-Agent header should not succeed");
|
||||
// Ensure that searching with a different User-Agent header but with ignoreVary succeeds.
|
||||
return test.cache.match(new Request(requestURL, {headers: {"User-Agent": "MyUA"}}),
|
||||
{ignoreVary: true});
|
||||
}).then(function(r) {
|
||||
return checkResponse(r, test.response, test.responseText);
|
||||
});
|
||||
}
|
||||
|
||||
function testInvalidHeaderName() {
|
||||
var test;
|
||||
return setupTest({"WhatToVary": "Foo/Bar, User-Agent"})
|
||||
|
@ -312,8 +285,6 @@ function testMultipleCacheEntries() {
|
|||
function step(testPromise) {
|
||||
return testPromise.then(function() {
|
||||
caches.delete(name);
|
||||
}, function() {
|
||||
caches.delete(name);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -323,6 +294,8 @@ step(testBasics()).then(function() {
|
|||
return step(testStar());
|
||||
}).then(function() {
|
||||
return step(testMatch());
|
||||
}).then(function() {
|
||||
return step(testStarAndAnotherHeader());
|
||||
}).then(function() {
|
||||
return step(testInvalidHeaderName());
|
||||
}).then(function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче