Actually throw an exception when the first argument to setTimeout or setInterval is not a valid callable function. bug 342448, r+sr=bzbarsky

This commit is contained in:
mrbkap%gmail.com 2006-06-27 17:51:42 +00:00
Родитель ff4af6a927
Коммит fe0e4a1530
2 изменённых файлов: 8 добавлений и 4 удалений

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

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 et tw=80: */
/* vim: set sw=2 ts=2 et tw=78: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -49,6 +49,7 @@
#include "nsHistory.h"
#include "nsBarProps.h"
#include "nsDOMStorage.h"
#include "nsDOMError.h"
// Helper Classes
#include "nsXPIDLString.h"
@ -6311,7 +6312,7 @@ nsGlobalWindow::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn)
&interval,
getter_AddRefs(handler));
if (NS_FAILED(rv))
return rv;
return (rv == NS_ERROR_DOM_TYPE_ERR) ? NS_OK : rv;
return SetTimeoutOrInterval(handler, interval, aIsInterval, aReturn);
}

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

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=80: */
/* vim: set ts=2 sw=2 et tw=78: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -48,6 +48,7 @@
#include "nsContentUtils.h"
#include "nsJSEnvironment.h"
#include "nsServiceManagerUtils.h"
#include "nsDOMError.h"
static const char kSetIntervalStr[] = "setInterval";
static const char kSetTimeoutStr[] = "setTimeout";
@ -242,7 +243,9 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool aIsInterval,
::JS_ReportError(cx, "useless %s call (missing quotes around argument?)",
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
return ncc->SetExceptionWasThrown(PR_TRUE);
// Return an error that nsGlobalWindow can recognize and turn into NS_OK.
ncc->SetExceptionWasThrown(PR_TRUE);
return NS_ERROR_DOM_TYPE_ERR;
}
if (expr) {