Back out a0bc511b1d75 (bug 744910) and c85d6a254baa (bug 673752) on suspicion of causing Win debug "make check" hangs

This commit is contained in:
Matt Brubeck 2012-04-24 20:47:13 -07:00
Родитель 8d58d62bb2
Коммит b09944e383
13 изменённых файлов: 314 добавлений и 179 удалений

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

@ -7505,34 +7505,18 @@ nsDocShell::CreateContentViewer(const char *aContentType,
mLoadType = mFailedLoadType;
nsCOMPtr<nsIChannel> failedChannel = mFailedChannel;
// Make sure we have a URI to set currentURI.
nsCOMPtr<nsIURI> failedURI;
if (failedChannel) {
NS_GetFinalChannelURI(failedChannel, getter_AddRefs(failedURI));
}
if (!failedURI) {
failedURI = mFailedURI;
}
// When we don't have failedURI, something wrong will happen. See
// bug 291876.
MOZ_ASSERT(failedURI, "We don't have a URI for history APIs.");
nsCOMPtr<nsIURI> failedURI = mFailedURI;
mFailedChannel = nsnull;
mFailedURI = nsnull;
// Create an shistory entry for the old load.
if (failedURI) {
#ifdef DEBUG
bool errorOnLocationChangeNeeded =
#endif
OnNewURI(failedURI, failedChannel, nsnull, mLoadType, true, false,
// Create an shistory entry for the old load, if we have a channel
if (failedChannel) {
mURIResultedInDocument = true;
OnLoadingSite(failedChannel, true, false);
} else if (failedURI) {
mURIResultedInDocument = true;
OnNewURI(failedURI, nsnull, nsnull, mLoadType, true, false,
false);
MOZ_ASSERT(!errorOnLocationChangeNeeded,
"We have to fire onLocationChange again.");
}
// Be sure to have a correct mLSHE, it may have been cleared by
@ -7549,6 +7533,9 @@ nsDocShell::CreateContentViewer(const char *aContentType,
mLSHE = do_QueryInterface(entry);
}
// Set our current URI
SetCurrentURI(failedURI);
mLoadType = LOAD_ERROR_PAGE;
}

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

@ -79,6 +79,11 @@ function step1A() {
}
function step1B(aWebProgress, aRequest, aLocation, aFlags) {
/* XXX Here we receive 2 notifications, due to bug 673752. */
if (!aRequest) {
return;
}
is(aLocation.spec, kDNSErrorURI, "Error page's URI (1)");
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
@ -156,6 +161,9 @@ function step4A() {
}
function step4B(aWebProgress, aRequest, aLocation, aFlags) {
if (!aRequest) // See step1B(...) and bug 673752.
return;
is(aLocation.spec, kDNSErrorURI, "Go back to the error URI (4)");
ok(!(aFlags & Components.interfaces.nsIWebProgressListener

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

@ -177,7 +177,7 @@ NSResultToNameAndMessage(nsresult aNSResult,
nsresult
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
const char** aMessage, PRUint16* aCode)
const char** aMessage)
{
const char* name = nsnull;
const char* message = nsnull;
@ -187,9 +187,6 @@ NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
if (name && message) {
*aName = name;
*aMessage = message;
if (aCode) {
*aCode = code;
}
return NS_OK;
}

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

@ -64,8 +64,7 @@ protected:
nsresult
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
const char** aMessage,
PRUint16* aCode = nsnull);
const char** aMessage);
#define DECL_INTERNAL_DOM_EXCEPTION(domname) \
nsresult \

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

@ -8,7 +8,6 @@
#define mozilla_dom_bindings_Utils_h__
#include "mozilla/dom/bindings/DOMJSClass.h"
#include "mozilla/dom/workers/Workers.h"
#include "jsapi.h"
#include "jsfriendapi.h"
@ -26,14 +25,12 @@ template<bool mainThread>
inline bool
Throw(JSContext* cx, nsresult rv)
{
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
// XXX Introduce exception machinery.
if (mainThread) {
XPCThrower::Throw(rv, cx);
} else {
if (!JS_IsExceptionPending(cx)) {
ThrowDOMExceptionForNSResult(cx, rv);
JS_ReportError(cx, "Exception thrown (nsresult = %x).", rv);
}
}
return false;

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

@ -43,7 +43,6 @@
#include "jsfriendapi.h"
#include "jsprf.h"
#include "mozilla/Util.h"
#include "nsDOMException.h"
#include "nsTraceRefcnt.h"
#include "WorkerInlines.h"
@ -69,7 +68,6 @@ class DOMException : public PrivatizableBase
enum SLOT {
SLOT_code = 0,
SLOT_name,
SLOT_message,
SLOT_COUNT
};
@ -89,7 +87,7 @@ public:
}
static JSObject*
Create(JSContext* aCx, nsresult aNSResult);
Create(JSContext* aCx, int aCode);
private:
DOMException()
@ -133,23 +131,18 @@ private:
return false;
}
char buf[100];
JS_snprintf(buf, sizeof(buf), "%s: ", sClass.name);
JSString* classString = JS_NewStringCopyZ(aCx, buf);
if (!classString) {
return false;
}
jsval name = JS_GetReservedSlot(obj, SLOT_name);
JS_ASSERT(name.isString());
JS_ASSERT(JSVAL_IS_STRING(name));
JSString *colon = JS_NewStringCopyN(aCx, ": ", 2);
if (!colon){
return false;
}
JSString* out = JS_ConcatStrings(aCx, name.toString(), colon);
if (!out) {
return false;
}
jsval message = JS_GetReservedSlot(obj, SLOT_message);
JS_ASSERT(message.isString());
out = JS_ConcatStrings(aCx, out, message.toString());
JSString* out = JS_ConcatStrings(aCx, classString, JSVAL_TO_STRING(name));
if (!out) {
return false;
}
@ -197,7 +190,6 @@ JSClass DOMException::sClass = {
JSPropertySpec DOMException::sProperties[] = {
{ "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
{ "name", SLOT_name, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
{ "message", SLOT_message, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
{ 0, 0, 0, NULL, NULL }
};
@ -211,6 +203,9 @@ JSPropertySpec DOMException::sStaticProperties[] = {
#define EXCEPTION_ENTRY(_name) \
{ #_name, _name, CONSTANT_FLAGS, GetConstant, NULL },
// Make sure this one is always first.
EXCEPTION_ENTRY(UNKNOWN_ERR)
EXCEPTION_ENTRY(INDEX_SIZE_ERR)
EXCEPTION_ENTRY(DOMSTRING_SIZE_ERR)
EXCEPTION_ENTRY(HIERARCHY_REQUEST_ERR)
@ -244,35 +239,32 @@ JSPropertySpec DOMException::sStaticProperties[] = {
// static
JSObject*
DOMException::Create(JSContext* aCx, nsresult aNSResult)
DOMException::Create(JSContext* aCx, int aCode)
{
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
if (!obj) {
return NULL;
}
const char* name;
const char* message;
uint16_t code;
if (NS_FAILED(NS_GetNameAndMessageForDOMNSResult(aNSResult, &name, &message,
&code))) {
JS_ReportError(aCx, "Exception thrown (nsresult = 0x%x).", aNSResult);
size_t foundIndex = size_t(-1);
for (size_t index = 0; index < ArrayLength(sStaticProperties) - 1; index++) {
if (sStaticProperties[index].tinyid == aCode) {
foundIndex = index;
break;
}
}
if (foundIndex == size_t(-1)) {
foundIndex = 0;
}
JSString* name = JS_NewStringCopyZ(aCx, sStaticProperties[foundIndex].name);
if (!name) {
return NULL;
}
JSString* jsname = JS_NewStringCopyZ(aCx, name);
if (!jsname) {
return NULL;
}
JSString* jsmessage = JS_NewStringCopyZ(aCx, message);
if (!jsmessage) {
return NULL;
}
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(code));
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(jsname));
JS_SetReservedSlot(obj, SLOT_message, STRING_TO_JSVAL(jsmessage));
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
DOMException* priv = new DOMException();
SetJSPrivateSafeish(obj, priv);
@ -280,6 +272,147 @@ DOMException::Create(JSContext* aCx, nsresult aNSResult)
return obj;
}
class FileException : public PrivatizableBase
{
static JSClass sClass;
static JSPropertySpec sProperties[];
static JSPropertySpec sStaticProperties[];
enum SLOT {
SLOT_code = 0,
SLOT_name,
SLOT_COUNT
};
public:
static JSObject*
InitClass(JSContext* aCx, JSObject* aObj)
{
return JS_InitClass(aCx, aObj, NULL, &sClass, Construct, 0, sProperties,
NULL, sStaticProperties, NULL);
}
static JSObject*
Create(JSContext* aCx, int aCode);
private:
FileException()
{
MOZ_COUNT_CTOR(mozilla::dom::workers::exceptions::FileException);
}
~FileException()
{
MOZ_COUNT_DTOR(mozilla::dom::workers::exceptions::FileException);
}
static JSBool
Construct(JSContext* aCx, unsigned aArgc, jsval* aVp)
{
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
sClass.name);
return false;
}
static void
Finalize(JSFreeOp* aFop, JSObject* aObj)
{
JS_ASSERT(JS_GetClass(aObj) == &sClass);
delete GetJSPrivateSafeish<FileException>(aObj);
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
int32 slot = JSID_TO_INT(aIdval);
JSClass* classPtr = JS_GetClass(aObj);
if (classPtr != &sClass || !GetJSPrivateSafeish<FileException>(aObj)) {
JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, sClass.name,
sProperties[slot].name, classPtr->name);
return false;
}
*aVp = JS_GetReservedSlot(aObj, slot);
return true;
}
static JSBool
GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(idval));
*aVp = INT_TO_JSVAL(JSID_TO_INT(idval));
return true;
}
};
JSClass FileException::sClass = {
"FileException",
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
};
JSPropertySpec FileException::sProperties[] = {
{ "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
{ "name", SLOT_name, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
{ 0, 0, 0, NULL, NULL }
};
JSPropertySpec FileException::sStaticProperties[] = {
#define EXCEPTION_ENTRY(_name) \
{ #_name, FILE_##_name, CONSTANT_FLAGS, GetConstant, NULL },
EXCEPTION_ENTRY(NOT_FOUND_ERR)
EXCEPTION_ENTRY(SECURITY_ERR)
EXCEPTION_ENTRY(ABORT_ERR)
EXCEPTION_ENTRY(NOT_READABLE_ERR)
EXCEPTION_ENTRY(ENCODING_ERR)
#undef EXCEPTION_ENTRY
{ 0, 0, 0, NULL, NULL }
};
// static
JSObject*
FileException::Create(JSContext* aCx, int aCode)
{
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
if (!obj) {
return NULL;
}
size_t foundIndex = size_t(-1);
for (size_t index = 0; index < ArrayLength(sStaticProperties) - 1; index++) {
if (sStaticProperties[index].tinyid == aCode) {
foundIndex = index;
break;
}
}
JS_ASSERT(foundIndex != size_t(-1));
JSString* name = JS_NewStringCopyZ(aCx, sStaticProperties[foundIndex].name);
if (!name) {
return NULL;
}
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
FileException* priv = new FileException();
SetJSPrivateSafeish(obj, priv);
return obj;
}
} // anonymous namespace
BEGIN_WORKERS_NAMESPACE
@ -289,16 +422,24 @@ namespace exceptions {
bool
InitClasses(JSContext* aCx, JSObject* aGlobal)
{
return DOMException::InitClass(aCx, aGlobal);
return DOMException::InitClass(aCx, aGlobal) &&
FileException::InitClass(aCx, aGlobal);
}
void
ThrowDOMExceptionForNSResult(JSContext* aCx, nsresult aNSResult)
ThrowDOMExceptionForCode(JSContext* aCx, int aCode)
{
JSObject* exception = DOMException::Create(aCx, aNSResult);
if (!exception) {
return;
}
JSObject* exception = DOMException::Create(aCx, aCode);
JS_ASSERT(exception);
JS_SetPendingException(aCx, OBJECT_TO_JSVAL(exception));
}
void
ThrowFileExceptionForCode(JSContext* aCx, int aCode)
{
JSObject* exception = FileException::Create(aCx, aCode);
JS_ASSERT(exception);
JS_SetPendingException(aCx, OBJECT_TO_JSVAL(exception));
}

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

@ -71,6 +71,16 @@
#define INVALID_NODE_TYPE_ERR 24
#define DATA_CLONE_ERR 25
// This one isn't actually spec'd anywhere, use it when we can't find a match.
#define UNKNOWN_ERR 0
// FileException Codes
#define FILE_NOT_FOUND_ERR 1
#define FILE_SECURITY_ERR 2
#define FILE_ABORT_ERR 3
#define FILE_NOT_READABLE_ERR 4
#define FILE_ENCODING_ERR 5
BEGIN_WORKERS_NAMESPACE
namespace exceptions {
@ -78,6 +88,12 @@ namespace exceptions {
bool
InitClasses(JSContext* aCx, JSObject* aGlobal);
void
ThrowDOMExceptionForCode(JSContext* aCx, int aCode);
void
ThrowFileExceptionForCode(JSContext* aCx, int aCode);
} // namespace exceptions
END_WORKERS_NAMESPACE

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

@ -41,7 +41,6 @@
#include "nsIDOMFile.h"
#include "nsDOMBlobBuilder.h"
#include "nsDOMError.h"
#include "jsapi.h"
#include "jsatom.h"
@ -59,7 +58,8 @@
USING_WORKERS_NAMESPACE
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
using mozilla::dom::workers::exceptions::ThrowFileExceptionForCode;
namespace {
@ -125,7 +125,9 @@ private:
nsresult rv = file->InitInternal(aCx, aArgc, JS_ARGV(aCx, aVp),
Unwrap);
if (NS_FAILED(rv)) {
ThrowDOMExceptionForNSResult(aCx, rv);
ThrowDOMExceptionForCode(aCx,
NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM ?
NS_ERROR_GET_CODE(rv) : UNKNOWN_ERR);
return false;
}
@ -157,8 +159,7 @@ private:
PRUint64 size;
if (NS_FAILED(blob->GetSize(&size))) {
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
return false;
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
}
if (!JS_NewNumberValue(aCx, double(size), aVp)) {
@ -178,8 +179,7 @@ private:
nsString type;
if (NS_FAILED(blob->GetType(type))) {
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
return false;
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
}
JSString* jsType = JS_NewUCStringCopyN(aCx, type.get(), type.Length());
@ -223,7 +223,7 @@ private:
static_cast<PRUint64>(end),
contentType, optionalArgc,
getter_AddRefs(rtnBlob)))) {
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
return false;
}
@ -350,7 +350,7 @@ private:
if (GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal() &&
NS_FAILED(file->GetMozFullPathInternal(fullPath))) {
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
return false;
}

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

@ -40,7 +40,6 @@
#include "FileReaderSync.h"
#include "nsIDOMFile.h"
#include "nsDOMError.h"
#include "jsapi.h"
#include "jsatom.h"
@ -57,7 +56,7 @@
USING_WORKERS_NAMESPACE
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
using mozilla::dom::workers::exceptions::ThrowFileExceptionForCode;
namespace {
@ -68,10 +67,10 @@ EnsureSucceededOrThrow(JSContext* aCx, nsresult rv)
return true;
}
rv = rv == NS_ERROR_FILE_NOT_FOUND ?
NS_ERROR_DOM_FILE_NOT_FOUND_ERR :
NS_ERROR_DOM_FILE_NOT_READABLE_ERR;
ThrowDOMExceptionForNSResult(aCx, rv);
int code = rv == NS_ERROR_FILE_NOT_FOUND ?
FILE_NOT_FOUND_ERR :
FILE_NOT_READABLE_ERR;
ThrowFileExceptionForCode(aCx, code);
return false;
}

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

@ -100,7 +100,7 @@
using mozilla::MutexAutoLock;
using mozilla::TimeDuration;
using mozilla::TimeStamp;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
USING_WORKERS_NAMESPACE
using namespace mozilla::dom::workers::events;
@ -415,7 +415,7 @@ struct WorkerStructuredCloneCallbacks
static void
Error(JSContext* aCx, uint32_t /* aErrorId */)
{
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
ThrowDOMExceptionForCode(aCx, DATA_CLONE_ERR);
}
};

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

@ -97,14 +97,6 @@ GetWorkerCrossThreadDispatcher(JSContext* aCx, jsval aWorker);
// Random unique constant to facilitate JSPrincipal debugging
const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
namespace exceptions {
// Implemented in Exceptions.cpp
void
ThrowDOMExceptionForNSResult(JSContext* aCx, nsresult aNSResult);
} // namespace exceptions
END_WORKERS_NAMESPACE
#endif // mozilla_dom_workers_workers_h__

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

@ -34,7 +34,7 @@ USING_WORKERS_NAMESPACE
namespace XMLHttpRequestResponseTypeValues =
mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
// XXX Need to figure this out...
#define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
@ -214,6 +214,21 @@ END_WORKERS_NAMESPACE
namespace {
inline int
GetDOMExceptionCodeFromResult(nsresult aResult)
{
if (NS_SUCCEEDED(aResult)) {
return 0;
}
if (NS_ERROR_GET_MODULE(aResult) == NS_ERROR_MODULE_DOM) {
return NS_ERROR_GET_CODE(aResult);
}
NS_WARNING("Update main thread implementation for a DOM error code here!");
return INVALID_STATE_ERR;
}
inline void
ConvertResponseTypeToString(XMLHttpRequestResponseType aType, nsString& aString)
{
@ -768,11 +783,11 @@ private:
class ResponseRunnable : public MainThreadProxyRunnable
{
PRUint32 mSyncQueueKey;
nsresult mErrorCode;
int mErrorCode;
public:
ResponseRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
PRUint32 aSyncQueueKey, nsresult aErrorCode)
PRUint32 aSyncQueueKey, int aErrorCode)
: MainThreadProxyRunnable(aWorkerPrivate, SkipWhenClearing, aProxy),
mSyncQueueKey(aSyncQueueKey), mErrorCode(aErrorCode)
{
@ -782,8 +797,8 @@ private:
bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
{
if (NS_FAILED(mErrorCode)) {
ThrowDOMExceptionForNSResult(aCx, mErrorCode);
if (mErrorCode) {
ThrowDOMExceptionForCode(aCx, mErrorCode);
aWorkerPrivate->StopSyncLoop(mSyncQueueKey, false);
}
else {
@ -821,7 +836,7 @@ public:
return true;
}
virtual nsresult
virtual int
MainThreadRun() = 0;
NS_IMETHOD
@ -832,7 +847,7 @@ public:
PRUint32 oldSyncQueueKey = mProxy->mSyncEventResponseSyncQueueKey;
mProxy->mSyncEventResponseSyncQueueKey = mSyncQueueKey;
nsresult rv = MainThreadRun();
int rv = MainThreadRun();
nsRefPtr<ResponseRunnable> response =
new ResponseRunnable(mWorkerPrivate, mProxy, mSyncQueueKey, rv);
@ -856,7 +871,7 @@ public:
MOZ_ASSERT(aProxy);
}
virtual nsresult
virtual int
MainThreadRun()
{
AssertIsOnMainThread();
@ -877,10 +892,10 @@ public:
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->SetMultipart(mValue);
return GetDOMExceptionCodeFromResult(mProxy->mXHR->SetMultipart(mValue));
}
};
@ -894,10 +909,11 @@ public:
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->SetMozBackgroundRequest(mValue);
nsresult rv = mProxy->mXHR->SetMozBackgroundRequest(mValue);
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -911,10 +927,11 @@ public:
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->SetWithCredentials(mValue);
nsresult rv = mProxy->mXHR->SetWithCredentials(mValue);
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -929,7 +946,7 @@ public:
mResponseType(aResponseType)
{ }
nsresult
int
MainThreadRun()
{
nsresult rv = mProxy->mXHR->SetResponseType(mResponseType);
@ -937,7 +954,7 @@ public:
if (NS_SUCCEEDED(rv)) {
rv = mProxy->mXHR->GetResponseType(mResponseType);
}
return rv;
return GetDOMExceptionCodeFromResult(rv);
}
void
@ -957,10 +974,10 @@ public:
mTimeout(aTimeout)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->SetTimeout(mTimeout);
return GetDOMExceptionCodeFromResult(mProxy->mXHR->SetTimeout(mTimeout));
}
};
@ -971,7 +988,7 @@ public:
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy)
{ }
nsresult
int
MainThreadRun()
{
mProxy->mInnerEventStreamId++;
@ -985,7 +1002,7 @@ public:
mProxy->Reset();
return NS_OK;
return 0;
}
};
@ -1000,11 +1017,11 @@ public:
mResponseHeaders(aResponseHeaders)
{ }
nsresult
int
MainThreadRun()
{
mProxy->mXHR->GetAllResponseHeaders(mResponseHeaders);
return NS_OK;
return 0;
}
};
@ -1020,10 +1037,11 @@ public:
mValue(aValue)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->GetResponseHeader(mHeader, mValue);
nsresult rv = mProxy->mXHR->GetResponseHeader(mHeader, mValue);
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -1050,45 +1068,53 @@ public:
mTimeout(aTimeout)
{ }
nsresult
int
MainThreadRun()
{
WorkerPrivate* oldWorker = mProxy->mWorkerPrivate;
mProxy->mWorkerPrivate = mWorkerPrivate;
nsresult rv = MainThreadRunInternal();
int retval = MainThreadRunInternal();
mProxy->mWorkerPrivate = oldWorker;
return rv;
return retval;
}
nsresult
int
MainThreadRunInternal()
{
if (!mProxy->Init()) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
return INVALID_STATE_ERR;
}
nsresult rv;
if (mMultipart) {
rv = mProxy->mXHR->SetMultipart(mMultipart);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
return GetDOMExceptionCodeFromResult(rv);
}
}
if (mBackgroundRequest) {
rv = mProxy->mXHR->SetMozBackgroundRequest(mBackgroundRequest);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
return GetDOMExceptionCodeFromResult(rv);
}
}
if (mWithCredentials) {
rv = mProxy->mXHR->SetWithCredentials(mWithCredentials);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
return GetDOMExceptionCodeFromResult(rv);
}
}
if (mTimeout) {
rv = mProxy->mXHR->SetTimeout(mTimeout);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
return GetDOMExceptionCodeFromResult(rv);
}
}
NS_ASSERTION(!mProxy->mInOpen, "Reentrancy is bad!");
@ -1103,7 +1129,7 @@ public:
rv = mProxy->mXHR->SetResponseType(NS_LITERAL_STRING("text"));
}
return rv;
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -1128,7 +1154,7 @@ public:
mClonedObjects.SwapElements(aClonedObjects);
}
nsresult
int
MainThreadRun()
{
nsCOMPtr<nsIVariant> variant;
@ -1138,7 +1164,7 @@ public:
nsIXPConnect* xpc = nsContentUtils::XPConnect();
NS_ASSERTION(xpc, "This should never be null!");
nsresult rv = NS_OK;
int error = 0;
JSStructuredCloneCallbacks* callbacks =
mWorkerPrivate->IsChromeWorker() ?
@ -1149,22 +1175,24 @@ public:
if (mBody.read(cx, &body, callbacks, &mClonedObjects)) {
if (NS_FAILED(xpc->JSValToVariant(cx, &body,
getter_AddRefs(variant)))) {
rv = NS_ERROR_DOM_INVALID_STATE_ERR;
error = INVALID_STATE_ERR;
}
}
else {
rv = NS_ERROR_DOM_DATA_CLONE_ERR;
error = DATA_CLONE_ERR;
}
mBody.clear();
mClonedObjects.Clear();
NS_ENSURE_SUCCESS(rv, rv);
if (error) {
return error;
}
}
else {
nsCOMPtr<nsIWritableVariant> wvariant =
do_CreateInstance(NS_VARIANT_CONTRACTID);
NS_ENSURE_TRUE(wvariant, NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(wvariant, UNKNOWN_ERR);
if (NS_FAILED(wvariant->SetAsAString(mStringBody))) {
NS_ERROR("This should never fail!");
@ -1201,7 +1229,7 @@ public:
}
}
return rv;
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -1217,10 +1245,11 @@ public:
mValue(aValue)
{ }
nsresult
int
MainThreadRun()
{
return mProxy->mXHR->SetRequestHeader(mHeader, mValue);
nsresult rv = mProxy->mXHR->SetRequestHeader(mHeader, mValue);
return GetDOMExceptionCodeFromResult(rv);
}
};
@ -1234,11 +1263,11 @@ public:
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mMimeType(aMimeType)
{ }
nsresult
int
MainThreadRun()
{
mProxy->mXHR->OverrideMimeType(mMimeType);
return NS_OK;
return 0;
}
};

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

@ -66,16 +66,6 @@ onmessage = function(event) {
throw new Error("Failed to throw when getting responseText on '" + type +
"' type");
}
if (exception.name != "InvalidStateError") {
throw new Error("Unexpected error when getting responseText on '" + type +
"' type");
}
if (exception.code != DOMException.INVALID_STATE_ERR) {
throw new Error("Unexpected error code when getting responseText on '" + type +
"' type");
}
}
testResponseTextException("arraybuffer");
@ -112,16 +102,6 @@ onmessage = function(event) {
"calling open()");
}
if (exception.name != "InvalidStateError") {
throw new Error("Unexpected error when setting responseType before " +
"calling open()");
}
if (exception.code != DOMException.INVALID_STATE_ERR) {
throw new Error("Unexpected error code when setting responseType before " +
"calling open()");
}
xhr.open("GET", url);
xhr.responseType = "text";
xhr.onload = function(event) {
@ -172,14 +152,4 @@ onmessage = function(event) {
throw new Error("Failed to throw when setting responseType after " +
"calling send()");
}
if (exception.name != "InvalidStateError") {
throw new Error("Unexpected error when setting responseType after " +
"calling send()");
}
if (exception.code != DOMException.INVALID_STATE_ERR) {
throw new Error("Unexpected error code when setting responseType after " +
"calling send()");
}
}