зеркало из https://github.com/mozilla/pjs.git
Backed out changeset 1c68eb288c85 for mochitest timeouts.
This commit is contained in:
Родитель
c63930de05
Коммит
77a620fafc
|
@ -67,22 +67,6 @@ interface nsIWorkerMessageEvent : nsIDOMEvent
|
|||
in nsISupports aSourceArg);
|
||||
};
|
||||
|
||||
[scriptable, uuid(73d82c1d-05de-49c9-a23b-7121ff09a67a)]
|
||||
interface nsIWorkerErrorEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute DOMString message;
|
||||
readonly attribute DOMString filename;
|
||||
|
||||
readonly attribute unsigned long lineno;
|
||||
|
||||
void initErrorEvent(in DOMString aTypeArg,
|
||||
in boolean aCanBubbleArg,
|
||||
in boolean aCancelableArg,
|
||||
in DOMString aMessageArg,
|
||||
in DOMString aFilenameArg,
|
||||
in unsigned long aLinenoArg);
|
||||
};
|
||||
|
||||
[scriptable, uuid(74fb665a-e477-4ce2-b3c6-c58b1b28b6c3)]
|
||||
interface nsIWorkerNavigator : nsISupports
|
||||
{
|
||||
|
@ -92,13 +76,11 @@ interface nsIWorkerNavigator : nsISupports
|
|||
readonly attribute DOMString userAgent;
|
||||
};
|
||||
|
||||
[scriptable, uuid(d7d7cf59-6c8a-4598-8753-630953ae7409)]
|
||||
[scriptable, uuid(a41ac154-ba18-4926-8954-cd6973ea490e)]
|
||||
interface nsIWorkerGlobalScope : nsISupports
|
||||
{
|
||||
readonly attribute nsIWorkerGlobalScope self;
|
||||
readonly attribute nsIWorkerNavigator navigator;
|
||||
|
||||
attribute nsIDOMEventListener onerror;
|
||||
};
|
||||
|
||||
[scriptable, uuid(d30a2f61-86e2-434e-837f-4f1985efa865)]
|
||||
|
|
|
@ -160,8 +160,7 @@ class nsReportErrorRunnable : public nsIRunnable
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsReportErrorRunnable(nsDOMWorker* aWorker,
|
||||
nsIScriptError* aScriptError)
|
||||
nsReportErrorRunnable(nsDOMWorker* aWorker, nsIScriptError* aScriptError)
|
||||
: mWorker(aWorker), mWorkerWN(aWorker->GetWrappedNative()),
|
||||
mScriptError(aScriptError) {
|
||||
NS_ASSERTION(aScriptError, "Null pointer!");
|
||||
|
@ -192,38 +191,35 @@ public:
|
|||
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "error");
|
||||
|
||||
nsresult rv;
|
||||
PRBool hasListener = PR_FALSE, stopPropagation = PR_FALSE;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mWorker->mOuterHandler->HasListeners(errorStr)) {
|
||||
// Construct the error event.
|
||||
nsString message;
|
||||
rv = mScriptError->GetErrorMessage(message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsString filename;
|
||||
rv = mScriptError->GetSourceName(filename);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint32 lineno;
|
||||
rv = mScriptError->GetLineNumber(&lineno);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<nsDOMWorkerErrorEvent> event(new nsDOMWorkerErrorEvent());
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = event->InitErrorEvent(errorStr, PR_FALSE, PR_TRUE, message,
|
||||
filename, lineno);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
event->SetTarget(mWorker);
|
||||
|
||||
PRBool stopPropagation = PR_FALSE;
|
||||
rv = mWorker->DispatchEvent(static_cast<nsDOMWorkerEvent*>(event),
|
||||
&stopPropagation);
|
||||
if (NS_SUCCEEDED(rv) && stopPropagation) {
|
||||
return NS_OK;
|
||||
hasListener = PR_TRUE;
|
||||
nsRefPtr<nsDOMWorkerMessageEvent> event(new nsDOMWorkerMessageEvent());
|
||||
if (event) {
|
||||
nsCString errorMessage;
|
||||
rv = mScriptError->ToString(errorMessage);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = event->InitMessageEvent(errorStr, PR_FALSE, PR_FALSE,
|
||||
NS_ConvertUTF8toUTF16(errorMessage),
|
||||
EmptyString(), nsnull);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
event->SetTarget(mWorker);
|
||||
rv = mWorker->DispatchEvent(static_cast<nsDOMWorkerEvent*>(event),
|
||||
&stopPropagation);
|
||||
if (NS_FAILED(rv)) {
|
||||
stopPropagation = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (stopPropagation) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMWorker> parent = mWorker->GetParent();
|
||||
if (!parent) {
|
||||
|
@ -508,31 +504,6 @@ DOMWorkerErrorReporter(JSContext* aCx,
|
|||
column, aReport->flags, "DOM Worker javascript");
|
||||
NS_ENSURE_SUCCESS(rv,);
|
||||
|
||||
// Try the onerror handler for the worker's scope.
|
||||
nsCOMPtr<nsIDOMEventListener> handler =
|
||||
worker->mInnerHandler->GetOnXListener(NS_LITERAL_STRING("error"));
|
||||
|
||||
if (handler) {
|
||||
nsRefPtr<nsDOMWorkerErrorEvent> event(new nsDOMWorkerErrorEvent());
|
||||
NS_ENSURE_TRUE(event,);
|
||||
|
||||
rv = event->InitErrorEvent(NS_LITERAL_STRING("error"), PR_FALSE, PR_TRUE,
|
||||
nsDependentString(message), filename,
|
||||
aReport->lineno);
|
||||
NS_ENSURE_SUCCESS(rv,);
|
||||
|
||||
NS_ASSERTION(worker->GetInnerScope(), "Null scope!");
|
||||
event->SetTarget(worker->GetInnerScope());
|
||||
|
||||
rv = handler->HandleEvent(static_cast<nsDOMWorkerEvent*>(event));
|
||||
NS_ENSURE_SUCCESS(rv,);
|
||||
|
||||
if (event->PreventDefaultCalled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Still unhandled, fire at the onerror handler on the worker.
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new nsReportErrorRunnable(worker, scriptError);
|
||||
NS_ENSURE_TRUE(runnable,);
|
||||
|
|
|
@ -522,12 +522,29 @@ GetStringForArgument(nsAString& aString,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMWorkerScope::nsDOMWorkerScope(nsDOMWorker* aWorker)
|
||||
: mWorker(aWorker),
|
||||
mHasOnerror(PR_FALSE)
|
||||
class nsDOMWorkerScope : public nsIWorkerScope,
|
||||
public nsIDOMEventTarget,
|
||||
public nsIXPCScriptable,
|
||||
public nsIClassInfo
|
||||
{
|
||||
NS_ASSERTION(aWorker, "Null pointer!");
|
||||
}
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWORKERGLOBALSCOPE
|
||||
NS_DECL_NSIWORKERSCOPE
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
nsDOMWorkerScope(nsDOMWorker* aWorker)
|
||||
: mWorker(aWorker) {
|
||||
NS_ASSERTION(aWorker, "Null pointer!");
|
||||
}
|
||||
|
||||
private:
|
||||
nsDOMWorker* mWorker;
|
||||
|
||||
nsRefPtr<nsDOMWorkerNavigator> mNavigator;
|
||||
};
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsDOMWorkerScope, nsIWorkerScope,
|
||||
nsIWorkerGlobalScope,
|
||||
|
@ -600,56 +617,6 @@ nsDOMWorkerScope::GetNavigator(nsIWorkerNavigator** _retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerScope::GetOnerror(nsIDOMEventListener** aOnerror)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ENSURE_ARG_POINTER(aOnerror);
|
||||
|
||||
if (mWorker->IsCanceled()) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
if (!mHasOnerror) {
|
||||
// Spec says we have to return 'undefined' until something is set here.
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
NS_ENSURE_TRUE(xpc, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsAXPCNativeCallContext* cc;
|
||||
nsresult rv = xpc->GetCurrentNativeCallContext(&cc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(cc, NS_ERROR_UNEXPECTED);
|
||||
|
||||
jsval* retval;
|
||||
rv = cc->GetRetValPtr(&retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*retval = JSVAL_VOID;
|
||||
return cc->SetReturnValueWasSet(PR_TRUE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> listener =
|
||||
mWorker->mInnerHandler->GetOnXListener(NS_LITERAL_STRING("error"));
|
||||
listener.forget(aOnerror);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerScope::SetOnerror(nsIDOMEventListener* aOnerror)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (mWorker->IsCanceled()) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
mHasOnerror = PR_TRUE;
|
||||
|
||||
return mWorker->mInnerHandler->SetOnXListener(NS_LITERAL_STRING("error"),
|
||||
aOnerror);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerScope::PostMessage(/* JSObject aMessage */)
|
||||
{
|
||||
|
|
|
@ -54,11 +54,9 @@
|
|||
|
||||
#include "nsDOMWorkerMessageHandler.h"
|
||||
|
||||
class nsDOMWorker;
|
||||
class nsDOMWorkerFeature;
|
||||
class nsDOMWorkerMessageHandler;
|
||||
class nsDOMWorkerNavigator;
|
||||
class nsDOMWorkerPool;
|
||||
class nsDOMWorkerScope;
|
||||
class nsDOMWorkerTimeout;
|
||||
class nsICancelable;
|
||||
class nsIDOMEventListener;
|
||||
|
@ -66,28 +64,7 @@ class nsIEventTarget;
|
|||
class nsIScriptGlobalObject;
|
||||
class nsIXPConnectWrappedNative;
|
||||
|
||||
class nsDOMWorkerScope : public nsIWorkerScope,
|
||||
public nsIDOMEventTarget,
|
||||
public nsIXPCScriptable,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWORKERGLOBALSCOPE
|
||||
NS_DECL_NSIWORKERSCOPE
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
nsDOMWorkerScope(nsDOMWorker* aWorker);
|
||||
|
||||
private:
|
||||
nsDOMWorker* mWorker;
|
||||
|
||||
nsRefPtr<nsDOMWorkerNavigator> mNavigator;
|
||||
|
||||
PRPackedBool mHasOnerror;
|
||||
};
|
||||
class nsDOMWorkerFeature;
|
||||
|
||||
class nsDOMWorker : public nsIWorker,
|
||||
public nsIJSNativeInitializer,
|
||||
|
|
|
@ -56,7 +56,6 @@ nsDOMWorkerPrivateEvent::nsDOMWorkerPrivateEvent(nsIDOMEvent* aEvent)
|
|||
: mEvent(aEvent),
|
||||
mProgressEvent(do_QueryInterface(aEvent)),
|
||||
mMessageEvent(do_QueryInterface(aEvent)),
|
||||
mErrorEvent(do_QueryInterface(aEvent)),
|
||||
mPreventDefaultCalled(PR_FALSE)
|
||||
{
|
||||
NS_ASSERTION(aEvent, "Null pointer!");
|
||||
|
@ -71,7 +70,6 @@ NS_INTERFACE_MAP_BEGIN(nsDOMWorkerPrivateEvent)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMWorkerPrivateEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMProgressEvent, mProgressEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIWorkerMessageEvent, mMessageEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIWorkerErrorEvent, mErrorEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -93,13 +91,7 @@ nsDOMWorkerPrivateEvent::GetInterfaces(PRUint32* aCount, nsIID*** aArray)
|
|||
NS_IMETHODIMP
|
||||
nsDOMWorkerPrivateEvent::PreventDefault()
|
||||
{
|
||||
PRBool cancelable = PR_FALSE;
|
||||
mEvent->GetCancelable(&cancelable);
|
||||
|
||||
if (cancelable) {
|
||||
mPreventDefaultCalled = PR_TRUE;
|
||||
}
|
||||
|
||||
mPreventDefaultCalled = PR_TRUE;
|
||||
return mEvent->PreventDefault();
|
||||
}
|
||||
|
||||
|
@ -144,21 +136,6 @@ nsDOMWorkerPrivateEvent::InitMessageEvent(const nsAString& aTypeArg,
|
|||
aSourceArg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerPrivateEvent::InitErrorEvent(const nsAString& aTypeArg,
|
||||
PRBool aCanBubbleArg,
|
||||
PRBool aCancelableArg,
|
||||
const nsAString& aMessageArg,
|
||||
const nsAString& aFilenameArg,
|
||||
PRUint32 aLinenoArg)
|
||||
{
|
||||
NS_ASSERTION(mErrorEvent, "Impossible!");
|
||||
|
||||
mPreventDefaultCalled = PR_FALSE;
|
||||
return mErrorEvent->InitErrorEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
|
||||
aMessageArg, aFilenameArg, aLinenoArg);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDOMWorkerPrivateEvent::PreventDefaultCalled()
|
||||
{
|
||||
|
@ -562,47 +539,3 @@ nsDOMWorkerXHREvent::Run()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsDOMWorkerErrorEvent, nsDOMWorkerEvent,
|
||||
nsIWorkerErrorEvent)
|
||||
|
||||
NS_IMPL_CI_INTERFACE_GETTER2(nsDOMWorkerErrorEvent, nsIDOMEvent,
|
||||
nsIWorkerErrorEvent)
|
||||
|
||||
NS_IMPL_THREADSAFE_DOM_CI_GETINTERFACES(nsDOMWorkerErrorEvent)
|
||||
|
||||
nsresult
|
||||
nsDOMWorkerErrorEvent::GetMessage(nsAString& aMessage)
|
||||
{
|
||||
aMessage.Assign(mMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMWorkerErrorEvent::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
aFilename.Assign(mFilename);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMWorkerErrorEvent::GetLineno(PRUint32* aLineno)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLineno);
|
||||
*aLineno = mLineno;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMWorkerErrorEvent::InitErrorEvent(const nsAString& aTypeArg,
|
||||
PRBool aCanBubbleArg,
|
||||
PRBool aCancelableArg,
|
||||
const nsAString& aMessageArg,
|
||||
const nsAString& aFilenameArg,
|
||||
PRUint32 aLinenoArg)
|
||||
{
|
||||
mMessage.Assign(aMessageArg);
|
||||
mFilename.Assign(aFilenameArg);
|
||||
mLineno = aLinenoArg;
|
||||
return InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
|
||||
}
|
||||
|
|
|
@ -108,18 +108,9 @@ public:
|
|||
NS_IMETHOD GetSource(nsISupports** aSource) \
|
||||
{ return mMessageEvent->GetSource(aSource); }
|
||||
|
||||
#define NS_FORWARD_NSIWORKERERROREVENT_SPECIAL \
|
||||
NS_IMETHOD GetMessage(nsAString& aMessage) \
|
||||
{ return mErrorEvent->GetMessage(aMessage); } \
|
||||
NS_IMETHOD GetFilename(nsAString& aFilename) \
|
||||
{ return mErrorEvent->GetFilename(aFilename); } \
|
||||
NS_IMETHOD GetLineno(PRUint32* aLineno) \
|
||||
{ return mErrorEvent->GetLineno(aLineno); }
|
||||
|
||||
class nsDOMWorkerPrivateEvent : public nsIDOMWorkerPrivateEvent,
|
||||
public nsIDOMProgressEvent,
|
||||
public nsIWorkerMessageEvent,
|
||||
public nsIWorkerErrorEvent,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
|
@ -127,7 +118,6 @@ public:
|
|||
NS_FORWARD_NSIDOMEVENT_SPECIAL
|
||||
NS_FORWARD_NSIWORKERMESSAGEEVENT_SPECIAL
|
||||
NS_FORWARD_NSIDOMPROGRESSEVENT_SPECIAL
|
||||
NS_FORWARD_NSIWORKERERROREVENT_SPECIAL
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
nsDOMWorkerPrivateEvent(nsIDOMEvent* aEvent);
|
||||
|
@ -152,20 +142,12 @@ public:
|
|||
const nsAString& aOriginArg,
|
||||
nsISupports* aSourceArg);
|
||||
|
||||
NS_IMETHOD InitErrorEvent(const nsAString& aTypeArg,
|
||||
PRBool aCanBubbleArg,
|
||||
PRBool aCancelableArg,
|
||||
const nsAString& aMessageArg,
|
||||
const nsAString& aFilenameArg,
|
||||
PRUint32 aLinenoArg);
|
||||
|
||||
virtual PRBool PreventDefaultCalled();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMEvent> mEvent;
|
||||
nsCOMPtr<nsIDOMProgressEvent> mProgressEvent;
|
||||
nsCOMPtr<nsIWorkerMessageEvent> mMessageEvent;
|
||||
nsCOMPtr<nsIWorkerErrorEvent> mErrorEvent;
|
||||
PRBool mPreventDefaultCalled;
|
||||
};
|
||||
|
||||
|
@ -185,10 +167,6 @@ public:
|
|||
mTarget = aTarget;
|
||||
}
|
||||
|
||||
PRBool PreventDefaultCalled() {
|
||||
return PRBool(mPreventDefaultCalled);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMWorkerEvent() { }
|
||||
|
||||
|
@ -322,22 +300,4 @@ protected:
|
|||
PRPackedBool mProgressEvent;
|
||||
};
|
||||
|
||||
class nsDOMWorkerErrorEvent : public nsDOMWorkerEvent,
|
||||
public nsIWorkerErrorEvent
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_NSIDOMEVENT(nsDOMWorkerEvent::)
|
||||
NS_DECL_NSIWORKERERROREVENT
|
||||
NS_DECL_NSICLASSINFO_GETINTERFACES
|
||||
|
||||
nsDOMWorkerErrorEvent()
|
||||
: mLineno(0) { }
|
||||
|
||||
protected:
|
||||
nsString mMessage;
|
||||
nsString mFilename;
|
||||
PRUint32 mLineno;
|
||||
};
|
||||
|
||||
#endif /* __NSDOMWORKEREVENTS_H__ */
|
||||
|
|
|
@ -70,8 +70,6 @@ _TEST_FILES = \
|
|||
relativeLoad_worker.js \
|
||||
relativeLoad_worker2.js \
|
||||
relativeLoad_import.js \
|
||||
test_scopeOnerror.html \
|
||||
scopeOnerror_worker.js \
|
||||
test_simpleThread.html \
|
||||
simpleThread_worker.js \
|
||||
test_terminate.html \
|
||||
|
|
|
@ -10,11 +10,11 @@ worker.onerror = function(event) {
|
|||
case 2:
|
||||
// Stop and rethrow.
|
||||
event.preventDefault();
|
||||
throw event.message;
|
||||
throw event.data;
|
||||
break;
|
||||
case 3:
|
||||
event.preventDefault();
|
||||
postMessage(event.message);
|
||||
postMessage(event.data);
|
||||
worker.onerror = null;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -3,4 +3,5 @@ var myConstructor = {}.constructor;
|
|||
|
||||
// Try to call a function defined in the imported script.
|
||||
function importedScriptFunction() {
|
||||
dump("running importedScriptFunction\n");
|
||||
}
|
||||
|
|
|
@ -3,4 +3,5 @@ var myConstructor2 = {}.constructor;
|
|||
|
||||
// Try to call a function defined in the imported script.
|
||||
function importedScriptFunction2() {
|
||||
dump("running importedScriptFunction2\n");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ onmessage = function(event) {
|
|||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "testXHR.txt", false);
|
||||
xhr.send(null);
|
||||
dump("XXXben: " + xhr.responseText + "\n");
|
||||
if (xhr.status != 200 ||
|
||||
xhr.responseText != "A noisy noise annoys an oyster.") {
|
||||
throw "Couldn't get xhr text from where we wanted it!";
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
if (onerror !== undefined || typeof(onerror) != "undefined") {
|
||||
throw "Undefined onerror has bad type!";
|
||||
}
|
||||
|
||||
onerror = function(event) {
|
||||
if (!event.cancelable) {
|
||||
throw "Error event is not cancelable!";
|
||||
}
|
||||
|
||||
if (event.target != this) {
|
||||
throw "Error event is targeted at the wrong object!";
|
||||
}
|
||||
|
||||
if (event.message == "uncaught exception: This error should not make it back out") {
|
||||
event.preventDefault();
|
||||
setTimeout("postMessage('Done');", 10);
|
||||
}
|
||||
}
|
||||
|
||||
onmessage = function(event) {
|
||||
if (onerror === undefined || typeof(onerror) == "undefined") {
|
||||
throw "onerror has a bad type!";
|
||||
}
|
||||
throw event.data;
|
||||
}
|
|
@ -35,7 +35,8 @@ Tests of DOM Worker Threads
|
|||
|
||||
worker.onmessage = function(event) {
|
||||
is(event.target, worker);
|
||||
isnot(-1, event.data.indexOf(errors[errorIndex]));
|
||||
ok(event.data.indexOf(errors[errorIndex]) != -1,
|
||||
"Wrong message!");
|
||||
ok(errorIndex == errors.length - 1, "Wrong number of errors seen!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -48,7 +49,8 @@ Tests of DOM Worker Threads
|
|||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
is(event.target, worker);
|
||||
isnot(-1, event.message.indexOf(errors[errorIndex]));
|
||||
ok(event.data.indexOf(errors[errorIndex]) != -1,
|
||||
"Wrong message!");
|
||||
|
||||
switch (errorIndex) {
|
||||
case 1:
|
||||
|
@ -77,9 +79,7 @@ Tests of DOM Worker Threads
|
|||
return;
|
||||
}
|
||||
|
||||
is(message.message,
|
||||
'[JavaScript Error: "uncaught exception: This exception should show ' +
|
||||
'up in the JS console"]');
|
||||
ok(message.message.indexOf(errors[errorIndex]) != -1, "Wrong message!");
|
||||
worker.onerror = errorHandler;
|
||||
nextError();
|
||||
},
|
||||
|
|
|
@ -20,7 +20,9 @@ Tests of DOM Worker Threads
|
|||
var worker = new Worker("recursion_worker.js");
|
||||
|
||||
worker.onerror = function(event) {
|
||||
is(event.message, "too much recursion");
|
||||
is(event.data,
|
||||
'[JavaScript Error: "too much recursion" {file: "http://localhost:8888' +
|
||||
'/tests/dom/src/threads/test/recursion_worker.js" line: 2}]');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Tests of DOM Worker Threads
|
||||
-->
|
||||
<head>
|
||||
<title>Test for DOM Worker Threads</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
||||
var errors = [
|
||||
"This exception should make it to onerror",
|
||||
"This error should not make it back out"
|
||||
];
|
||||
|
||||
var worker = new Worker("scopeOnError_worker.js");
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
ok(event.data == "Done");
|
||||
|
||||
if (consoleListener) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
consoleService.unregisterListener(consoleListener);
|
||||
consoleService.reset();
|
||||
consoleListener = null;
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
worker.onerror = function(event) {
|
||||
is(event.target, worker);
|
||||
is(event.message,
|
||||
"uncaught exception: This exception should make it to onerror");
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
var consoleListener = {
|
||||
observe: function(message) {
|
||||
ok(false, "An error made it to the console: " + message);
|
||||
|
||||
if (consoleListener) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
consoleService.unregisterListener(consoleListener);
|
||||
consoleService.reset();
|
||||
consoleListener = null;
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
if (iid.equals(Ci.nsIConsoleListener) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
var consoleService =
|
||||
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
|
||||
|
||||
consoleService.reset();
|
||||
consoleService.registerListener(consoleListener);
|
||||
|
||||
for (var index in errors) {
|
||||
worker.postMessage(errors[index]);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -43,15 +43,19 @@ Tests of DOM Worker Threads (Bug 437152)
|
|||
var gotErrors = false;
|
||||
worker.onerror = function(event) {
|
||||
is(event.target, worker);
|
||||
is(event.message, "uncaught exception: Bad message: asdf");
|
||||
is(event.data,
|
||||
'[JavaScript Error: "uncaught exception: Bad message: asdf"]');
|
||||
|
||||
worker.onerror = function(otherEvent) {
|
||||
is(otherEvent.target, worker);
|
||||
is(otherEvent.message, "Components is not defined");
|
||||
is(otherEvent.data,
|
||||
'[JavaScript Error: "Components is not defined" {file: ' +
|
||||
'"http://localhost:8888/tests/dom/src/threads/test/' +
|
||||
'simpleThread_worker.js" line: 6}]');
|
||||
gotErrors = true;
|
||||
|
||||
worker.onerror = function(oneMoreEvent) {
|
||||
ok(false, "Worker had an error:" + oneMoreEvent.message);
|
||||
ok(false, "Worker had an error:" + oneMoreEvent.data);
|
||||
SimpleTest.finish();
|
||||
};
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче