mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out a0bc511b1d75 (bug 744910) and c85d6a254baa (bug 673752) on suspicion of causing Win debug "make check" hangs
This commit is contained in:
parent
68fdd39a98
commit
2993d5d45a
@ -7505,34 +7505,18 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
|||||||
mLoadType = mFailedLoadType;
|
mLoadType = mFailedLoadType;
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> failedChannel = mFailedChannel;
|
nsCOMPtr<nsIChannel> failedChannel = mFailedChannel;
|
||||||
|
nsCOMPtr<nsIURI> failedURI = mFailedURI;
|
||||||
// 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.");
|
|
||||||
|
|
||||||
mFailedChannel = nsnull;
|
mFailedChannel = nsnull;
|
||||||
mFailedURI = nsnull;
|
mFailedURI = nsnull;
|
||||||
|
|
||||||
// Create an shistory entry for the old load.
|
// Create an shistory entry for the old load, if we have a channel
|
||||||
if (failedURI) {
|
if (failedChannel) {
|
||||||
#ifdef DEBUG
|
mURIResultedInDocument = true;
|
||||||
bool errorOnLocationChangeNeeded =
|
OnLoadingSite(failedChannel, true, false);
|
||||||
#endif
|
} else if (failedURI) {
|
||||||
OnNewURI(failedURI, failedChannel, nsnull, mLoadType, true, false,
|
mURIResultedInDocument = true;
|
||||||
|
OnNewURI(failedURI, nsnull, nsnull, mLoadType, true, false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
MOZ_ASSERT(!errorOnLocationChangeNeeded,
|
|
||||||
"We have to fire onLocationChange again.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Be sure to have a correct mLSHE, it may have been cleared by
|
// 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);
|
mLSHE = do_QueryInterface(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set our current URI
|
||||||
|
SetCurrentURI(failedURI);
|
||||||
|
|
||||||
mLoadType = LOAD_ERROR_PAGE;
|
mLoadType = LOAD_ERROR_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,11 @@ function step1A() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function step1B(aWebProgress, aRequest, aLocation, aFlags) {
|
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)");
|
is(aLocation.spec, kDNSErrorURI, "Error page's URI (1)");
|
||||||
|
|
||||||
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
|
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
|
||||||
@ -156,6 +161,9 @@ function step4A() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function step4B(aWebProgress, aRequest, aLocation, aFlags) {
|
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)");
|
is(aLocation.spec, kDNSErrorURI, "Go back to the error URI (4)");
|
||||||
|
|
||||||
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
|
ok(!(aFlags & Components.interfaces.nsIWebProgressListener
|
||||||
|
@ -177,7 +177,7 @@ NSResultToNameAndMessage(nsresult aNSResult,
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
|
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
|
||||||
const char** aMessage, PRUint16* aCode)
|
const char** aMessage)
|
||||||
{
|
{
|
||||||
const char* name = nsnull;
|
const char* name = nsnull;
|
||||||
const char* message = nsnull;
|
const char* message = nsnull;
|
||||||
@ -187,9 +187,6 @@ NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
|
|||||||
if (name && message) {
|
if (name && message) {
|
||||||
*aName = name;
|
*aName = name;
|
||||||
*aMessage = message;
|
*aMessage = message;
|
||||||
if (aCode) {
|
|
||||||
*aCode = code;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ protected:
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
|
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, const char** aName,
|
||||||
const char** aMessage,
|
const char** aMessage);
|
||||||
PRUint16* aCode = nsnull);
|
|
||||||
|
|
||||||
#define DECL_INTERNAL_DOM_EXCEPTION(domname) \
|
#define DECL_INTERNAL_DOM_EXCEPTION(domname) \
|
||||||
nsresult \
|
nsresult \
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define mozilla_dom_bindings_Utils_h__
|
#define mozilla_dom_bindings_Utils_h__
|
||||||
|
|
||||||
#include "mozilla/dom/bindings/DOMJSClass.h"
|
#include "mozilla/dom/bindings/DOMJSClass.h"
|
||||||
#include "mozilla/dom/workers/Workers.h"
|
|
||||||
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsfriendapi.h"
|
#include "jsfriendapi.h"
|
||||||
@ -26,14 +25,12 @@ template<bool mainThread>
|
|||||||
inline bool
|
inline bool
|
||||||
Throw(JSContext* cx, nsresult rv)
|
Throw(JSContext* cx, nsresult rv)
|
||||||
{
|
{
|
||||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
|
|
||||||
|
|
||||||
// XXX Introduce exception machinery.
|
// XXX Introduce exception machinery.
|
||||||
if (mainThread) {
|
if (mainThread) {
|
||||||
XPCThrower::Throw(rv, cx);
|
XPCThrower::Throw(rv, cx);
|
||||||
} else {
|
} else {
|
||||||
if (!JS_IsExceptionPending(cx)) {
|
if (!JS_IsExceptionPending(cx)) {
|
||||||
ThrowDOMExceptionForNSResult(cx, rv);
|
JS_ReportError(cx, "Exception thrown (nsresult = %x).", rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include "jsfriendapi.h"
|
#include "jsfriendapi.h"
|
||||||
#include "jsprf.h"
|
#include "jsprf.h"
|
||||||
#include "mozilla/Util.h"
|
#include "mozilla/Util.h"
|
||||||
#include "nsDOMException.h"
|
|
||||||
#include "nsTraceRefcnt.h"
|
#include "nsTraceRefcnt.h"
|
||||||
|
|
||||||
#include "WorkerInlines.h"
|
#include "WorkerInlines.h"
|
||||||
@ -69,7 +68,6 @@ class DOMException : public PrivatizableBase
|
|||||||
enum SLOT {
|
enum SLOT {
|
||||||
SLOT_code = 0,
|
SLOT_code = 0,
|
||||||
SLOT_name,
|
SLOT_name,
|
||||||
SLOT_message,
|
|
||||||
|
|
||||||
SLOT_COUNT
|
SLOT_COUNT
|
||||||
};
|
};
|
||||||
@ -89,7 +87,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JSObject*
|
static JSObject*
|
||||||
Create(JSContext* aCx, nsresult aNSResult);
|
Create(JSContext* aCx, int aCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DOMException()
|
DOMException()
|
||||||
@ -133,23 +131,18 @@ private:
|
|||||||
return false;
|
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);
|
jsval name = JS_GetReservedSlot(obj, SLOT_name);
|
||||||
JS_ASSERT(name.isString());
|
JS_ASSERT(JSVAL_IS_STRING(name));
|
||||||
|
|
||||||
JSString *colon = JS_NewStringCopyN(aCx, ": ", 2);
|
JSString* out = JS_ConcatStrings(aCx, classString, JSVAL_TO_STRING(name));
|
||||||
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());
|
|
||||||
if (!out) {
|
if (!out) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -197,7 +190,6 @@ JSClass DOMException::sClass = {
|
|||||||
JSPropertySpec DOMException::sProperties[] = {
|
JSPropertySpec DOMException::sProperties[] = {
|
||||||
{ "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
|
{ "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
|
||||||
{ "name", SLOT_name, 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 }
|
{ 0, 0, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -211,6 +203,9 @@ JSPropertySpec DOMException::sStaticProperties[] = {
|
|||||||
#define EXCEPTION_ENTRY(_name) \
|
#define EXCEPTION_ENTRY(_name) \
|
||||||
{ #_name, _name, CONSTANT_FLAGS, GetConstant, NULL },
|
{ #_name, _name, CONSTANT_FLAGS, GetConstant, NULL },
|
||||||
|
|
||||||
|
// Make sure this one is always first.
|
||||||
|
EXCEPTION_ENTRY(UNKNOWN_ERR)
|
||||||
|
|
||||||
EXCEPTION_ENTRY(INDEX_SIZE_ERR)
|
EXCEPTION_ENTRY(INDEX_SIZE_ERR)
|
||||||
EXCEPTION_ENTRY(DOMSTRING_SIZE_ERR)
|
EXCEPTION_ENTRY(DOMSTRING_SIZE_ERR)
|
||||||
EXCEPTION_ENTRY(HIERARCHY_REQUEST_ERR)
|
EXCEPTION_ENTRY(HIERARCHY_REQUEST_ERR)
|
||||||
@ -244,35 +239,32 @@ JSPropertySpec DOMException::sStaticProperties[] = {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
JSObject*
|
JSObject*
|
||||||
DOMException::Create(JSContext* aCx, nsresult aNSResult)
|
DOMException::Create(JSContext* aCx, int aCode)
|
||||||
{
|
{
|
||||||
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name;
|
size_t foundIndex = size_t(-1);
|
||||||
const char* message;
|
for (size_t index = 0; index < ArrayLength(sStaticProperties) - 1; index++) {
|
||||||
uint16_t code;
|
if (sStaticProperties[index].tinyid == aCode) {
|
||||||
if (NS_FAILED(NS_GetNameAndMessageForDOMNSResult(aNSResult, &name, &message,
|
foundIndex = index;
|
||||||
&code))) {
|
break;
|
||||||
JS_ReportError(aCx, "Exception thrown (nsresult = 0x%x).", aNSResult);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundIndex == size_t(-1)) {
|
||||||
|
foundIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSString* name = JS_NewStringCopyZ(aCx, sStaticProperties[foundIndex].name);
|
||||||
|
if (!name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSString* jsname = JS_NewStringCopyZ(aCx, name);
|
JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
|
||||||
if (!jsname) {
|
JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
|
||||||
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));
|
|
||||||
|
|
||||||
DOMException* priv = new DOMException();
|
DOMException* priv = new DOMException();
|
||||||
SetJSPrivateSafeish(obj, priv);
|
SetJSPrivateSafeish(obj, priv);
|
||||||
@ -280,6 +272,147 @@ DOMException::Create(JSContext* aCx, nsresult aNSResult)
|
|||||||
return obj;
|
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
|
} // anonymous namespace
|
||||||
|
|
||||||
BEGIN_WORKERS_NAMESPACE
|
BEGIN_WORKERS_NAMESPACE
|
||||||
@ -289,16 +422,24 @@ namespace exceptions {
|
|||||||
bool
|
bool
|
||||||
InitClasses(JSContext* aCx, JSObject* aGlobal)
|
InitClasses(JSContext* aCx, JSObject* aGlobal)
|
||||||
{
|
{
|
||||||
return DOMException::InitClass(aCx, aGlobal);
|
return DOMException::InitClass(aCx, aGlobal) &&
|
||||||
|
FileException::InitClass(aCx, aGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ThrowDOMExceptionForNSResult(JSContext* aCx, nsresult aNSResult)
|
ThrowDOMExceptionForCode(JSContext* aCx, int aCode)
|
||||||
{
|
{
|
||||||
JSObject* exception = DOMException::Create(aCx, aNSResult);
|
JSObject* exception = DOMException::Create(aCx, aCode);
|
||||||
if (!exception) {
|
JS_ASSERT(exception);
|
||||||
return;
|
|
||||||
}
|
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));
|
JS_SetPendingException(aCx, OBJECT_TO_JSVAL(exception));
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,16 @@
|
|||||||
#define INVALID_NODE_TYPE_ERR 24
|
#define INVALID_NODE_TYPE_ERR 24
|
||||||
#define DATA_CLONE_ERR 25
|
#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
|
BEGIN_WORKERS_NAMESPACE
|
||||||
|
|
||||||
namespace exceptions {
|
namespace exceptions {
|
||||||
@ -78,6 +88,12 @@ namespace exceptions {
|
|||||||
bool
|
bool
|
||||||
InitClasses(JSContext* aCx, JSObject* aGlobal);
|
InitClasses(JSContext* aCx, JSObject* aGlobal);
|
||||||
|
|
||||||
|
void
|
||||||
|
ThrowDOMExceptionForCode(JSContext* aCx, int aCode);
|
||||||
|
|
||||||
|
void
|
||||||
|
ThrowFileExceptionForCode(JSContext* aCx, int aCode);
|
||||||
|
|
||||||
} // namespace exceptions
|
} // namespace exceptions
|
||||||
|
|
||||||
END_WORKERS_NAMESPACE
|
END_WORKERS_NAMESPACE
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include "nsIDOMFile.h"
|
#include "nsIDOMFile.h"
|
||||||
#include "nsDOMBlobBuilder.h"
|
#include "nsDOMBlobBuilder.h"
|
||||||
#include "nsDOMError.h"
|
|
||||||
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsatom.h"
|
#include "jsatom.h"
|
||||||
@ -59,7 +58,8 @@
|
|||||||
|
|
||||||
USING_WORKERS_NAMESPACE
|
USING_WORKERS_NAMESPACE
|
||||||
|
|
||||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
|
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
|
||||||
|
using mozilla::dom::workers::exceptions::ThrowFileExceptionForCode;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -125,7 +125,9 @@ private:
|
|||||||
nsresult rv = file->InitInternal(aCx, aArgc, JS_ARGV(aCx, aVp),
|
nsresult rv = file->InitInternal(aCx, aArgc, JS_ARGV(aCx, aVp),
|
||||||
Unwrap);
|
Unwrap);
|
||||||
if (NS_FAILED(rv)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +159,7 @@ private:
|
|||||||
|
|
||||||
PRUint64 size;
|
PRUint64 size;
|
||||||
if (NS_FAILED(blob->GetSize(&size))) {
|
if (NS_FAILED(blob->GetSize(&size))) {
|
||||||
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
|
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_NewNumberValue(aCx, double(size), aVp)) {
|
if (!JS_NewNumberValue(aCx, double(size), aVp)) {
|
||||||
@ -178,8 +179,7 @@ private:
|
|||||||
|
|
||||||
nsString type;
|
nsString type;
|
||||||
if (NS_FAILED(blob->GetType(type))) {
|
if (NS_FAILED(blob->GetType(type))) {
|
||||||
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
|
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSString* jsType = JS_NewUCStringCopyN(aCx, type.get(), type.Length());
|
JSString* jsType = JS_NewUCStringCopyN(aCx, type.get(), type.Length());
|
||||||
@ -223,7 +223,7 @@ private:
|
|||||||
static_cast<PRUint64>(end),
|
static_cast<PRUint64>(end),
|
||||||
contentType, optionalArgc,
|
contentType, optionalArgc,
|
||||||
getter_AddRefs(rtnBlob)))) {
|
getter_AddRefs(rtnBlob)))) {
|
||||||
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
|
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ private:
|
|||||||
|
|
||||||
if (GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal() &&
|
if (GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal() &&
|
||||||
NS_FAILED(file->GetMozFullPathInternal(fullPath))) {
|
NS_FAILED(file->GetMozFullPathInternal(fullPath))) {
|
||||||
ThrowDOMExceptionForNSResult(aCx, NS_ERROR_DOM_FILE_NOT_READABLE_ERR);
|
ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "FileReaderSync.h"
|
#include "FileReaderSync.h"
|
||||||
|
|
||||||
#include "nsIDOMFile.h"
|
#include "nsIDOMFile.h"
|
||||||
#include "nsDOMError.h"
|
|
||||||
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsatom.h"
|
#include "jsatom.h"
|
||||||
@ -57,7 +56,7 @@
|
|||||||
|
|
||||||
USING_WORKERS_NAMESPACE
|
USING_WORKERS_NAMESPACE
|
||||||
|
|
||||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
|
using mozilla::dom::workers::exceptions::ThrowFileExceptionForCode;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -68,10 +67,10 @@ EnsureSucceededOrThrow(JSContext* aCx, nsresult rv)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = rv == NS_ERROR_FILE_NOT_FOUND ?
|
int code = rv == NS_ERROR_FILE_NOT_FOUND ?
|
||||||
NS_ERROR_DOM_FILE_NOT_FOUND_ERR :
|
FILE_NOT_FOUND_ERR :
|
||||||
NS_ERROR_DOM_FILE_NOT_READABLE_ERR;
|
FILE_NOT_READABLE_ERR;
|
||||||
ThrowDOMExceptionForNSResult(aCx, rv);
|
ThrowFileExceptionForCode(aCx, code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
using mozilla::MutexAutoLock;
|
using mozilla::MutexAutoLock;
|
||||||
using mozilla::TimeDuration;
|
using mozilla::TimeDuration;
|
||||||
using mozilla::TimeStamp;
|
using mozilla::TimeStamp;
|
||||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
|
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
|
||||||
|
|
||||||
USING_WORKERS_NAMESPACE
|
USING_WORKERS_NAMESPACE
|
||||||
using namespace mozilla::dom::workers::events;
|
using namespace mozilla::dom::workers::events;
|
||||||
@ -415,7 +415,7 @@ struct WorkerStructuredCloneCallbacks
|
|||||||
static void
|
static void
|
||||||
Error(JSContext* aCx, uint32_t /* aErrorId */)
|
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
|
// Random unique constant to facilitate JSPrincipal debugging
|
||||||
const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
|
const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
|
||||||
|
|
||||||
namespace exceptions {
|
|
||||||
|
|
||||||
// Implemented in Exceptions.cpp
|
|
||||||
void
|
|
||||||
ThrowDOMExceptionForNSResult(JSContext* aCx, nsresult aNSResult);
|
|
||||||
|
|
||||||
} // namespace exceptions
|
|
||||||
|
|
||||||
END_WORKERS_NAMESPACE
|
END_WORKERS_NAMESPACE
|
||||||
|
|
||||||
#endif // mozilla_dom_workers_workers_h__
|
#endif // mozilla_dom_workers_workers_h__
|
||||||
|
@ -34,7 +34,7 @@ USING_WORKERS_NAMESPACE
|
|||||||
namespace XMLHttpRequestResponseTypeValues =
|
namespace XMLHttpRequestResponseTypeValues =
|
||||||
mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
|
mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
|
||||||
|
|
||||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
|
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
|
||||||
|
|
||||||
// XXX Need to figure this out...
|
// XXX Need to figure this out...
|
||||||
#define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
|
#define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
|
||||||
@ -214,6 +214,21 @@ END_WORKERS_NAMESPACE
|
|||||||
|
|
||||||
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
|
inline void
|
||||||
ConvertResponseTypeToString(XMLHttpRequestResponseType aType, nsString& aString)
|
ConvertResponseTypeToString(XMLHttpRequestResponseType aType, nsString& aString)
|
||||||
{
|
{
|
||||||
@ -768,11 +783,11 @@ private:
|
|||||||
class ResponseRunnable : public MainThreadProxyRunnable
|
class ResponseRunnable : public MainThreadProxyRunnable
|
||||||
{
|
{
|
||||||
PRUint32 mSyncQueueKey;
|
PRUint32 mSyncQueueKey;
|
||||||
nsresult mErrorCode;
|
int mErrorCode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResponseRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
|
ResponseRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
|
||||||
PRUint32 aSyncQueueKey, nsresult aErrorCode)
|
PRUint32 aSyncQueueKey, int aErrorCode)
|
||||||
: MainThreadProxyRunnable(aWorkerPrivate, SkipWhenClearing, aProxy),
|
: MainThreadProxyRunnable(aWorkerPrivate, SkipWhenClearing, aProxy),
|
||||||
mSyncQueueKey(aSyncQueueKey), mErrorCode(aErrorCode)
|
mSyncQueueKey(aSyncQueueKey), mErrorCode(aErrorCode)
|
||||||
{
|
{
|
||||||
@ -782,8 +797,8 @@ private:
|
|||||||
bool
|
bool
|
||||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||||
{
|
{
|
||||||
if (NS_FAILED(mErrorCode)) {
|
if (mErrorCode) {
|
||||||
ThrowDOMExceptionForNSResult(aCx, mErrorCode);
|
ThrowDOMExceptionForCode(aCx, mErrorCode);
|
||||||
aWorkerPrivate->StopSyncLoop(mSyncQueueKey, false);
|
aWorkerPrivate->StopSyncLoop(mSyncQueueKey, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -821,7 +836,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsresult
|
virtual int
|
||||||
MainThreadRun() = 0;
|
MainThreadRun() = 0;
|
||||||
|
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
@ -832,7 +847,7 @@ public:
|
|||||||
PRUint32 oldSyncQueueKey = mProxy->mSyncEventResponseSyncQueueKey;
|
PRUint32 oldSyncQueueKey = mProxy->mSyncEventResponseSyncQueueKey;
|
||||||
mProxy->mSyncEventResponseSyncQueueKey = mSyncQueueKey;
|
mProxy->mSyncEventResponseSyncQueueKey = mSyncQueueKey;
|
||||||
|
|
||||||
nsresult rv = MainThreadRun();
|
int rv = MainThreadRun();
|
||||||
|
|
||||||
nsRefPtr<ResponseRunnable> response =
|
nsRefPtr<ResponseRunnable> response =
|
||||||
new ResponseRunnable(mWorkerPrivate, mProxy, mSyncQueueKey, rv);
|
new ResponseRunnable(mWorkerPrivate, mProxy, mSyncQueueKey, rv);
|
||||||
@ -856,7 +871,7 @@ public:
|
|||||||
MOZ_ASSERT(aProxy);
|
MOZ_ASSERT(aProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsresult
|
virtual int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
@ -877,10 +892,10 @@ public:
|
|||||||
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
|
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
return mProxy->mXHR->SetMultipart(mValue);
|
return GetDOMExceptionCodeFromResult(mProxy->mXHR->SetMultipart(mValue));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -894,10 +909,11 @@ public:
|
|||||||
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
|
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
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)
|
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mValue(aValue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
return mProxy->mXHR->SetWithCredentials(mValue);
|
nsresult rv = mProxy->mXHR->SetWithCredentials(mValue);
|
||||||
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -929,7 +946,7 @@ public:
|
|||||||
mResponseType(aResponseType)
|
mResponseType(aResponseType)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
nsresult rv = mProxy->mXHR->SetResponseType(mResponseType);
|
nsresult rv = mProxy->mXHR->SetResponseType(mResponseType);
|
||||||
@ -937,7 +954,7 @@ public:
|
|||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = mProxy->mXHR->GetResponseType(mResponseType);
|
rv = mProxy->mXHR->GetResponseType(mResponseType);
|
||||||
}
|
}
|
||||||
return rv;
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -957,10 +974,10 @@ public:
|
|||||||
mTimeout(aTimeout)
|
mTimeout(aTimeout)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
return mProxy->mXHR->SetTimeout(mTimeout);
|
return GetDOMExceptionCodeFromResult(mProxy->mXHR->SetTimeout(mTimeout));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -971,7 +988,7 @@ public:
|
|||||||
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy)
|
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
mProxy->mInnerEventStreamId++;
|
mProxy->mInnerEventStreamId++;
|
||||||
@ -985,7 +1002,7 @@ public:
|
|||||||
|
|
||||||
mProxy->Reset();
|
mProxy->Reset();
|
||||||
|
|
||||||
return NS_OK;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1000,11 +1017,11 @@ public:
|
|||||||
mResponseHeaders(aResponseHeaders)
|
mResponseHeaders(aResponseHeaders)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
mProxy->mXHR->GetAllResponseHeaders(mResponseHeaders);
|
mProxy->mXHR->GetAllResponseHeaders(mResponseHeaders);
|
||||||
return NS_OK;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1020,10 +1037,11 @@ public:
|
|||||||
mValue(aValue)
|
mValue(aValue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
return mProxy->mXHR->GetResponseHeader(mHeader, mValue);
|
nsresult rv = mProxy->mXHR->GetResponseHeader(mHeader, mValue);
|
||||||
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1050,45 +1068,53 @@ public:
|
|||||||
mTimeout(aTimeout)
|
mTimeout(aTimeout)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
WorkerPrivate* oldWorker = mProxy->mWorkerPrivate;
|
WorkerPrivate* oldWorker = mProxy->mWorkerPrivate;
|
||||||
mProxy->mWorkerPrivate = mWorkerPrivate;
|
mProxy->mWorkerPrivate = mWorkerPrivate;
|
||||||
|
|
||||||
nsresult rv = MainThreadRunInternal();
|
int retval = MainThreadRunInternal();
|
||||||
|
|
||||||
mProxy->mWorkerPrivate = oldWorker;
|
mProxy->mWorkerPrivate = oldWorker;
|
||||||
return rv;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRunInternal()
|
MainThreadRunInternal()
|
||||||
{
|
{
|
||||||
if (!mProxy->Init()) {
|
if (!mProxy->Init()) {
|
||||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
return INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (mMultipart) {
|
if (mMultipart) {
|
||||||
rv = mProxy->mXHR->SetMultipart(mMultipart);
|
rv = mProxy->mXHR->SetMultipart(mMultipart);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBackgroundRequest) {
|
if (mBackgroundRequest) {
|
||||||
rv = mProxy->mXHR->SetMozBackgroundRequest(mBackgroundRequest);
|
rv = mProxy->mXHR->SetMozBackgroundRequest(mBackgroundRequest);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWithCredentials) {
|
if (mWithCredentials) {
|
||||||
rv = mProxy->mXHR->SetWithCredentials(mWithCredentials);
|
rv = mProxy->mXHR->SetWithCredentials(mWithCredentials);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTimeout) {
|
if (mTimeout) {
|
||||||
rv = mProxy->mXHR->SetTimeout(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!");
|
NS_ASSERTION(!mProxy->mInOpen, "Reentrancy is bad!");
|
||||||
@ -1103,7 +1129,7 @@ public:
|
|||||||
rv = mProxy->mXHR->SetResponseType(NS_LITERAL_STRING("text"));
|
rv = mProxy->mXHR->SetResponseType(NS_LITERAL_STRING("text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1128,7 +1154,7 @@ public:
|
|||||||
mClonedObjects.SwapElements(aClonedObjects);
|
mClonedObjects.SwapElements(aClonedObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIVariant> variant;
|
nsCOMPtr<nsIVariant> variant;
|
||||||
@ -1138,7 +1164,7 @@ public:
|
|||||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||||
NS_ASSERTION(xpc, "This should never be null!");
|
NS_ASSERTION(xpc, "This should never be null!");
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
int error = 0;
|
||||||
|
|
||||||
JSStructuredCloneCallbacks* callbacks =
|
JSStructuredCloneCallbacks* callbacks =
|
||||||
mWorkerPrivate->IsChromeWorker() ?
|
mWorkerPrivate->IsChromeWorker() ?
|
||||||
@ -1149,22 +1175,24 @@ public:
|
|||||||
if (mBody.read(cx, &body, callbacks, &mClonedObjects)) {
|
if (mBody.read(cx, &body, callbacks, &mClonedObjects)) {
|
||||||
if (NS_FAILED(xpc->JSValToVariant(cx, &body,
|
if (NS_FAILED(xpc->JSValToVariant(cx, &body,
|
||||||
getter_AddRefs(variant)))) {
|
getter_AddRefs(variant)))) {
|
||||||
rv = NS_ERROR_DOM_INVALID_STATE_ERR;
|
error = INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = NS_ERROR_DOM_DATA_CLONE_ERR;
|
error = DATA_CLONE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
mBody.clear();
|
mBody.clear();
|
||||||
mClonedObjects.Clear();
|
mClonedObjects.Clear();
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsCOMPtr<nsIWritableVariant> wvariant =
|
nsCOMPtr<nsIWritableVariant> wvariant =
|
||||||
do_CreateInstance(NS_VARIANT_CONTRACTID);
|
do_CreateInstance(NS_VARIANT_CONTRACTID);
|
||||||
NS_ENSURE_TRUE(wvariant, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(wvariant, UNKNOWN_ERR);
|
||||||
|
|
||||||
if (NS_FAILED(wvariant->SetAsAString(mStringBody))) {
|
if (NS_FAILED(wvariant->SetAsAString(mStringBody))) {
|
||||||
NS_ERROR("This should never fail!");
|
NS_ERROR("This should never fail!");
|
||||||
@ -1201,7 +1229,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return GetDOMExceptionCodeFromResult(rv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1217,10 +1245,11 @@ public:
|
|||||||
mValue(aValue)
|
mValue(aValue)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
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)
|
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mMimeType(aMimeType)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
nsresult
|
int
|
||||||
MainThreadRun()
|
MainThreadRun()
|
||||||
{
|
{
|
||||||
mProxy->mXHR->OverrideMimeType(mMimeType);
|
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 +
|
throw new Error("Failed to throw when getting responseText on '" + type +
|
||||||
"' 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");
|
testResponseTextException("arraybuffer");
|
||||||
@ -112,16 +102,6 @@ onmessage = function(event) {
|
|||||||
"calling open()");
|
"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.open("GET", url);
|
||||||
xhr.responseType = "text";
|
xhr.responseType = "text";
|
||||||
xhr.onload = function(event) {
|
xhr.onload = function(event) {
|
||||||
@ -172,14 +152,4 @@ onmessage = function(event) {
|
|||||||
throw new Error("Failed to throw when setting responseType after " +
|
throw new Error("Failed to throw when setting responseType after " +
|
||||||
"calling send()");
|
"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()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user