mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 9b0fcaacb788 & bf3fef257e68 (bug 752226) for mochitest-other orange
This commit is contained in:
parent
c99a274e2c
commit
79899a6f75
@ -164,20 +164,19 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext)
|
||||
obj = proto;
|
||||
JSClass *objectClass = JS_GetClass(obj);
|
||||
|
||||
JS::Value v;
|
||||
jsval v;
|
||||
if (!JS_GetProperty(cx, global, "netscape", &v))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSObject *securityObj;
|
||||
if (v.isObject()) {
|
||||
if (JSVAL_IS_OBJECT(v)) {
|
||||
/*
|
||||
* "netscape" property of window object exists; get the
|
||||
* "security" property.
|
||||
*/
|
||||
obj = &v.toObject();
|
||||
if (!JS_GetProperty(cx, obj, "security", &v) || !v.isObject())
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
if (!JS_GetProperty(cx, obj, "security", &v) || !JSVAL_IS_OBJECT(v))
|
||||
return NS_ERROR_FAILURE;
|
||||
securityObj = &v.toObject();
|
||||
securityObj = JSVAL_TO_OBJECT(v);
|
||||
} else {
|
||||
/* define netscape.security object */
|
||||
obj = JS_DefineObject(cx, global, "netscape", objectClass, nsnull, 0);
|
||||
|
@ -1,4 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
var worker = new Worker("data:text/javascript,setTimeout(null)");
|
||||
</script>
|
@ -1,4 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
document.createElement("video").src = null
|
||||
</script>
|
@ -107,6 +107,4 @@ load 713417.html
|
||||
load 713417-2.html
|
||||
load 715056.html
|
||||
load 741163-1.html
|
||||
load 752226-1.html
|
||||
load 752226-2.html
|
||||
HTTP(..) load xhr_abortinprogress.html
|
||||
|
@ -404,18 +404,18 @@ nsDOMBlobBuilder::GetFile(const nsAString& aName,
|
||||
/* [implicit_jscontext] void append (in jsval data,
|
||||
[optional] in DOMString endings); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMBlobBuilder::Append(const JS::Value& aData,
|
||||
nsDOMBlobBuilder::Append(const jsval& aData,
|
||||
const nsAString& aEndings, JSContext* aCx)
|
||||
{
|
||||
// We need to figure out what our jsval is
|
||||
|
||||
// Just return for null
|
||||
if (aData.isNull())
|
||||
return NS_OK;
|
||||
|
||||
// Is it an object?
|
||||
if (aData.isObject()) {
|
||||
JSObject* obj = &aData.toObject();
|
||||
if (JSVAL_IS_OBJECT(aData)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aData);
|
||||
if (!obj) {
|
||||
// We got passed null. Just do nothing.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Is it a Blob?
|
||||
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(
|
||||
|
@ -517,7 +517,7 @@ nsDOMFileFile::Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
PRUint32 aArgc,
|
||||
JS::Value* aArgv)
|
||||
jsval* aArgv)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -533,13 +533,14 @@ nsDOMFileFile::Initialize(nsISupports* aOwner,
|
||||
// We expect to get a path to represent as a File object,
|
||||
// or an nsIFile
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (!aArgv[0].isString()) {
|
||||
if (!JSVAL_IS_STRING(aArgv[0])) {
|
||||
// Lets see if it's an nsIFile
|
||||
if (!aArgv[0].isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(aArgv[0])) {
|
||||
return NS_ERROR_UNEXPECTED; // We're not interested
|
||||
}
|
||||
|
||||
JSObject* obj = &aArgv[0].toObject();
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aArgv[0]);
|
||||
NS_ASSERTION(obj, "This is a bit odd");
|
||||
|
||||
// Is it an nsIFile
|
||||
file = do_QueryInterface(
|
||||
|
@ -326,16 +326,16 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
|
||||
}
|
||||
|
||||
static nsQueryInterface
|
||||
JSvalToInterface(JSContext* cx, JS::Value val, nsIXPConnect* xpc, bool* wasNull)
|
||||
JSvalToInterface(JSContext* cx, jsval val, nsIXPConnect* xpc, bool* wasNull)
|
||||
{
|
||||
if (val.isNull()) {
|
||||
if (val == JSVAL_NULL) {
|
||||
*wasNull = true;
|
||||
return nsQueryInterface(nsnull);
|
||||
}
|
||||
|
||||
*wasNull = false;
|
||||
if (val.isObject()) {
|
||||
JSObject* arg = &val.toObject();
|
||||
if (JSVAL_IS_OBJECT(val)) {
|
||||
JSObject* arg = JSVAL_TO_OBJECT(val);
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> native;
|
||||
xpc->GetWrappedNativeOfJSObject(cx, arg, getter_AddRefs(native));
|
||||
|
@ -453,10 +453,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
|
||||
jsval thisValue = JSVAL_VOID;
|
||||
|
||||
JS::Value funval;
|
||||
jsval funval = JSVAL_VOID;
|
||||
if (JS_ObjectIsCallable(ctx, object)) {
|
||||
// If the listener is a JS function:
|
||||
funval.setObject(*object);
|
||||
funval = OBJECT_TO_JSVAL(object);
|
||||
|
||||
// A small hack to get 'this' value right on content side where
|
||||
// messageManager is wrapped in TabChildGlobal.
|
||||
@ -471,13 +471,13 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
defaultThisValue, &thisValue, nsnull, true);
|
||||
} else {
|
||||
// If the listener is a JS object which has receiveMessage function:
|
||||
if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) ||
|
||||
!funval.isObject())
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Check if the object is even callable.
|
||||
NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, &funval.toObject()));
|
||||
thisValue.setObject(*object);
|
||||
NS_ENSURE_STATE(JS_GetProperty(ctx, object, "receiveMessage",
|
||||
&funval) &&
|
||||
JSVAL_IS_OBJECT(funval) &&
|
||||
!JSVAL_IS_NULL(funval));
|
||||
JSObject* funobject = JSVAL_TO_OBJECT(funval);
|
||||
NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, funobject));
|
||||
thisValue = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
|
||||
jsval rval = JSVAL_VOID;
|
||||
|
@ -562,7 +562,7 @@ nsWebSocket::Initialize(nsISupports* aOwner,
|
||||
JSContext* aContext,
|
||||
JSObject* aObject,
|
||||
PRUint32 aArgc,
|
||||
JS::Value* aArgv)
|
||||
jsval* aArgv)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
|
||||
nsAutoString urlParam;
|
||||
@ -608,10 +608,11 @@ nsWebSocket::Initialize(nsISupports* aOwner,
|
||||
nsTArray<nsString> protocolArray;
|
||||
|
||||
if (aArgc == 2) {
|
||||
if (aArgv[1].isObject() &&
|
||||
JS_IsArrayObject(aContext, &aArgv[1].toObject())) {
|
||||
JSObject* jsobj = &aArgv[1].toObject();
|
||||
JSObject *jsobj;
|
||||
|
||||
if (JSVAL_IS_OBJECT(aArgv[1]) &&
|
||||
(jsobj = JSVAL_TO_OBJECT(aArgv[1])) &&
|
||||
JS_IsArrayObject(aContext, jsobj)) {
|
||||
uint32_t len;
|
||||
JS_GetArrayLength(aContext, jsobj, &len);
|
||||
|
||||
|
@ -73,8 +73,6 @@ _CHROME_FILES = \
|
||||
test_bug599295.html \
|
||||
test_bug650776.html \
|
||||
test_bug650784.html \
|
||||
test_bug752226-3.xul \
|
||||
test_bug752226-4.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=752226
|
||||
-->
|
||||
<window title="Mozilla Bug 752226"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=752226"
|
||||
target="_blank">Mozilla Bug 752226</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 752226 **/
|
||||
try {
|
||||
new File(null);
|
||||
} catch (e) {}
|
||||
ok(true, "Didn't crash.");
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=752226
|
||||
-->
|
||||
<window title="Mozilla Bug 752226"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=752226"
|
||||
target="_blank">Mozilla Bug 752226</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 752226 **/
|
||||
new Components.utils.Sandbox("about:blank", null);
|
||||
ok(true, "Didn't crash.");
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
@ -193,14 +193,14 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (argc < 6 || argc == 7 || argc == 8)
|
||||
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
|
||||
JS::Value* argv = JS_ARGV(cx, vp);
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
// arguments common to all cases
|
||||
GET_UINT32_ARG(argv0, 0);
|
||||
GET_INT32_ARG(argv1, 1);
|
||||
GET_UINT32_ARG(argv2, 2);
|
||||
|
||||
if (argc > 5 && argv[5].isObject()) {
|
||||
if (argc > 5 && !JSVAL_IS_PRIMITIVE(argv[5])) {
|
||||
// implement the variants taking a DOMElement as argv[5]
|
||||
GET_UINT32_ARG(argv3, 3);
|
||||
GET_UINT32_ARG(argv4, 4);
|
||||
@ -210,7 +210,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
rv = NS_OK;
|
||||
} else if (argc > 8 && argv[8].isObjectOrNull()) {
|
||||
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
||||
// here, we allow null !
|
||||
// implement the variants taking a buffer/array as argv[8]
|
||||
GET_INT32_ARG(argv3, 3);
|
||||
@ -219,7 +219,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp)
|
||||
GET_UINT32_ARG(argv6, 6);
|
||||
GET_UINT32_ARG(argv7, 7);
|
||||
|
||||
JSObject* argv8 = argv[8].toObjectOrNull();
|
||||
JSObject *argv8 = JSVAL_TO_OBJECT(argv[8]);
|
||||
|
||||
// then try to grab either a js::TypedArray, or null
|
||||
if (argv8 == nsnull) {
|
||||
|
@ -498,7 +498,7 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
|
||||
const JS::Value& aContextOptions,
|
||||
const jsval& aContextOptions,
|
||||
nsISupports **aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -521,18 +521,19 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// note: if any contexts end up supporting something other
|
||||
// than objects, e.g. plain strings, then we'll need to expand
|
||||
// this to know how to create nsISupportsStrings etc.
|
||||
|
||||
nsCOMPtr<nsIWritablePropertyBag2> contextProps;
|
||||
if (aContextOptions.isObject())
|
||||
if (!JSVAL_IS_NULL(aContextOptions) &&
|
||||
!JSVAL_IS_VOID(aContextOptions))
|
||||
{
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContext();
|
||||
|
||||
// note: if any contexts end up supporting something other
|
||||
// than objects, e.g. plain strings, then we'll need to expand
|
||||
// this to know how to create nsISupportsStrings etc.
|
||||
if (JSVAL_IS_OBJECT(aContextOptions)) {
|
||||
contextProps = do_CreateInstance("@mozilla.org/hash-property-bag;1");
|
||||
|
||||
JSObject *opts = &aContextOptions.toObject();
|
||||
JSObject *opts = JSVAL_TO_OBJECT(aContextOptions);
|
||||
JS::AutoIdArray props(cx, JS_Enumerate(cx, opts));
|
||||
for (size_t i = 0; !!props && i < props.length(); ++i) {
|
||||
jsid propid = props[i];
|
||||
@ -565,7 +566,7 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
|
||||
|
||||
contextProps->SetPropertyAsAString(pstr, vstr);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2087,19 +2087,19 @@ CreateExceptionFromResult(JSContext *cx, nsresult aResult)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::Value jv;
|
||||
jsval jv;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = WrapNative(cx, ::JS_GetGlobalObject(cx), exception,
|
||||
&NS_GET_IID(nsIException), false, &jv,
|
||||
getter_AddRefs(holder));
|
||||
if (NS_FAILED(rv) || jv.isNull()) {
|
||||
if (NS_FAILED(rv) || JSVAL_IS_NULL(jv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (jv.isObject()) {
|
||||
if (!ac.enter(cx, &jv.toObject())) {
|
||||
if (JSVAL_IS_OBJECT(jv)) {
|
||||
if (!ac.enter(cx, JSVAL_TO_OBJECT(jv))) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
@ -6492,23 +6492,26 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||
JSObject *proto = nsnull;
|
||||
|
||||
if (class_parent_name) {
|
||||
jsval val;
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, winobj)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JS::Value val;
|
||||
if (!JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
|
||||
if (!::JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (val.isObject()) {
|
||||
if (!JS_LookupProperty(cx, &val.toObject(), "prototype", &val)) {
|
||||
JSObject *tmp = JSVAL_IS_OBJECT(val) ? JSVAL_TO_OBJECT(val) : nsnull;
|
||||
|
||||
if (tmp) {
|
||||
if (!::JS_LookupProperty(cx, tmp, "prototype", &val)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (val.isObject()) {
|
||||
proto = &val.toObject();
|
||||
if (JSVAL_IS_OBJECT(val)) {
|
||||
proto = JSVAL_TO_OBJECT(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8953,9 +8956,8 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
// If we are called via document.all(id) instead of document.all.item(i) or
|
||||
// another method, use the document.all callee object as self.
|
||||
JSObject *self;
|
||||
JS::Value callee = JS_CALLEE(cx, vp);
|
||||
if (callee.isObject() &&
|
||||
JS_GetClass(&callee.toObject()) == &sHTMLDocumentAllClass) {
|
||||
if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) &&
|
||||
::JS_GetClass(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) {
|
||||
self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
|
||||
} else {
|
||||
self = JS_THIS_OBJECT(cx, vp);
|
||||
@ -8999,7 +9001,7 @@ PrivateToFlags(void *priv)
|
||||
|
||||
JSBool
|
||||
nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||
jsid id, JS::Value *vp)
|
||||
jsid id, jsval *vp)
|
||||
{
|
||||
if (id != nsDOMClassInfo::sAll_id) {
|
||||
return JS_TRUE;
|
||||
@ -9022,12 +9024,12 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||
// or it was not being resolved with a qualified name. Claim that
|
||||
// document.all is undefined.
|
||||
|
||||
vp->setUndefined();
|
||||
*vp = JSVAL_VOID;
|
||||
} else {
|
||||
// document.all is not being detected, and it resolved with a
|
||||
// qualified name. Expose the document.all collection.
|
||||
|
||||
if (!vp->isObjectOrNull()) {
|
||||
if (!JSVAL_IS_OBJECT(*vp)) {
|
||||
// First time through, create the collection, and set the
|
||||
// document as its private nsISupports data.
|
||||
nsresult rv;
|
||||
@ -9049,7 +9051,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
|
||||
|
||||
doc.forget();
|
||||
|
||||
vp->setObject(*all);
|
||||
*vp = OBJECT_TO_JSVAL(all);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9493,21 +9495,26 @@ nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsHTMLSelectElementSH::SetOption(JSContext *cx, JS::Value *vp, PRUint32 aIndex,
|
||||
nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
|
||||
nsIDOMHTMLOptionsCollection *aOptCollection)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// vp must refer to an object
|
||||
if (!vp->isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> new_option = do_QueryWrapper(cx, &vp->toObject());
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> new_option;
|
||||
|
||||
if (!JSVAL_IS_NULL(*vp)) {
|
||||
new_option = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
|
||||
if (!new_option) {
|
||||
// Someone is trying to set an option to a non-option object.
|
||||
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
return aOptCollection->SetOption(aIndex, new_option);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ WriteCallback(const jschar *buf, uint32_t len, void *data)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
|
||||
nsJSON::EncodeFromJSVal(jsval *value, JSContext *cx, nsAString &result)
|
||||
{
|
||||
result.Truncate();
|
||||
|
||||
@ -212,9 +212,9 @@ nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
JSObject *obj;
|
||||
nsIScriptSecurityManager *ssm = nsnull;
|
||||
if (value->isObject()) {
|
||||
JSObject *obj = &value->toObject();
|
||||
if (JSVAL_IS_OBJECT(*value) && (obj = JSVAL_TO_OBJECT(*value))) {
|
||||
if (!ac.enter(cx, obj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -254,11 +254,14 @@ nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue, nsJSONWriter* wri
|
||||
|
||||
// Backward compatibility:
|
||||
// nsIJSON does not allow to serialize anything other than objects
|
||||
if (!aValue.isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(aValue)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JSObject* obj = &aValue.toObject();
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aValue);
|
||||
if (!obj) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS::Value val = aValue;
|
||||
|
||||
|
@ -1846,7 +1846,7 @@ WorkerRunnable::NotifyScriptExecutedIfNeeded() const
|
||||
struct WorkerPrivate::TimeoutInfo
|
||||
{
|
||||
TimeoutInfo()
|
||||
: mTimeoutVal(JS::UndefinedValue()), mLineNumber(0), mId(0), mIsInterval(false),
|
||||
: mTimeoutVal(JSVAL_VOID), mLineNumber(0), mId(0), mIsInterval(false),
|
||||
mCanceled(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo);
|
||||
@ -1867,7 +1867,7 @@ struct WorkerPrivate::TimeoutInfo
|
||||
return mTargetTime < aOther.mTargetTime;
|
||||
}
|
||||
|
||||
JS::Value mTimeoutVal;
|
||||
jsval mTimeoutVal;
|
||||
nsTArray<jsval> mExtraArgVals;
|
||||
mozilla::TimeStamp mTargetTime;
|
||||
mozilla::TimeDuration mInterval;
|
||||
@ -3619,11 +3619,11 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp,
|
||||
mNextTimeoutId = 1;
|
||||
}
|
||||
|
||||
JS::Value* argv = JS_ARGV(aCx, aVp);
|
||||
jsval* argv = JS_ARGV(aCx, aVp);
|
||||
|
||||
// Take care of the main argument.
|
||||
if (argv[0].isObject()) {
|
||||
if (JS_ObjectIsCallable(aCx, &argv[0].toObject())) {
|
||||
if (JSVAL_IS_OBJECT(argv[0])) {
|
||||
if (JS_ObjectIsCallable(aCx, JSVAL_TO_OBJECT(argv[0]))) {
|
||||
newInfo->mTimeoutVal = argv[0];
|
||||
}
|
||||
else {
|
||||
@ -3631,10 +3631,10 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp,
|
||||
if (!timeoutStr) {
|
||||
return false;
|
||||
}
|
||||
newInfo->mTimeoutVal.setString(timeoutStr);
|
||||
newInfo->mTimeoutVal = STRING_TO_JSVAL(timeoutStr);
|
||||
}
|
||||
}
|
||||
else if (argv[0].isString()) {
|
||||
else if (JSVAL_IS_STRING(argv[0])) {
|
||||
newInfo->mTimeoutVal = argv[0];
|
||||
}
|
||||
else {
|
||||
@ -3651,7 +3651,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp,
|
||||
}
|
||||
newInfo->mInterval = TimeDuration::FromMilliseconds(intervalMS);
|
||||
|
||||
if (aArgc > 2 && newInfo->mTimeoutVal.isObject()) {
|
||||
if (aArgc > 2 && JSVAL_IS_OBJECT(newInfo->mTimeoutVal)) {
|
||||
nsTArray<jsval> extraArgVals(aArgc - 2);
|
||||
for (unsigned index = 2; index < aArgc; index++) {
|
||||
extraArgVals.AppendElement(argv[index]);
|
||||
@ -3662,7 +3662,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp,
|
||||
|
||||
newInfo->mTargetTime = TimeStamp::Now() + newInfo->mInterval;
|
||||
|
||||
if (newInfo->mTimeoutVal.isString()) {
|
||||
if (JSVAL_IS_STRING(newInfo->mTimeoutVal)) {
|
||||
const char* filenameChars;
|
||||
PRUint32 lineNumber;
|
||||
if (nsJSUtils::GetCallingLocation(aCx, &filenameChars, &lineNumber)) {
|
||||
@ -3786,8 +3786,8 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
||||
// JS_ReportPendingException returns false (i.e. uncatchable exception) then
|
||||
// break out of the loop.
|
||||
|
||||
if (info->mTimeoutVal.isString()) {
|
||||
JSString* expression = info->mTimeoutVal.toString();
|
||||
if (JSVAL_IS_STRING(info->mTimeoutVal)) {
|
||||
JSString* expression = JSVAL_TO_STRING(info->mTimeoutVal);
|
||||
|
||||
size_t stringLength;
|
||||
const jschar* string = JS_GetStringCharsAndLength(aCx, expression,
|
||||
|
@ -297,18 +297,19 @@ private:
|
||||
static JSBool
|
||||
UnwrapErrorEvent(JSContext* aCx, unsigned aArgc, jsval* aVp)
|
||||
{
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(JS_CALLEE(aCx, aVp)));
|
||||
JS_ASSERT(aArgc == 1);
|
||||
JS_ASSERT((JS_ARGV(aCx, aVp)[0]).isObject());
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(JS_ARGV(aCx, aVp)[0]));
|
||||
|
||||
JSObject* wrapper = &JS_CALLEE(aCx, aVp).toObject();
|
||||
JSObject* wrapper = JSVAL_TO_OBJECT(JS_CALLEE(aCx, aVp));
|
||||
JS_ASSERT(JS_ObjectIsFunction(aCx, wrapper));
|
||||
|
||||
jsval scope = js::GetFunctionNativeReserved(wrapper, SLOT_wrappedScope);
|
||||
jsval listener = js::GetFunctionNativeReserved(wrapper, SLOT_wrappedFunction);
|
||||
|
||||
JS_ASSERT(scope.isObject());
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(scope));
|
||||
|
||||
JSObject* event = &JS_ARGV(aCx, aVp)[0].toObject();
|
||||
JSObject* event = JSVAL_TO_OBJECT(JS_ARGV(aCx, aVp)[0]);
|
||||
|
||||
jsval argv[3] = { JSVAL_VOID, JSVAL_VOID, JSVAL_VOID };
|
||||
if (!JS_GetProperty(aCx, event, "message", &argv[0]) ||
|
||||
|
@ -51,7 +51,7 @@ void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
|
||||
if(!JS_CLIST_IS_EMPTY(&jsdval->props))
|
||||
{
|
||||
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS));
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val));
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
|
||||
}
|
||||
|
||||
if(jsdval->proto)
|
||||
@ -87,7 +87,7 @@ void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop)
|
||||
JSBool
|
||||
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return !JSVAL_IS_PRIMITIVE(jsdval->val) || JSVAL_IS_NULL(jsdval->val);
|
||||
return JSVAL_IS_OBJECT(jsdval->val);
|
||||
}
|
||||
|
||||
JSBool
|
||||
@ -449,7 +449,7 @@ static JSBool _buildProps(JSDContext* jsdc, JSDValue* jsdval)
|
||||
|
||||
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
|
||||
JS_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)));
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val));
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
|
||||
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return JS_FALSE;
|
||||
@ -675,16 +675,16 @@ jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
JSObject *obj;
|
||||
JSFunction *fun;
|
||||
|
||||
JSCrossCompartmentCall *call = NULL;
|
||||
if (JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
if (!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
obj = JS_UnwrapObject(obj);
|
||||
|
||||
obj = JS_UnwrapObject(JSVAL_TO_OBJECT(jsdval->val));
|
||||
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
||||
if (!call)
|
||||
return NULL;
|
||||
|
||||
fun = JS_ValueToFunction(jsdc->dumbContext, OBJECT_TO_JSVAL(obj));
|
||||
JS_LeaveCrossCompartmentCall(call);
|
||||
|
||||
@ -702,9 +702,10 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
|
||||
JSObject* proto;
|
||||
JS_ASSERT(!jsdval->proto);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
proto = JS_GetPrototype(obj);
|
||||
if(!proto)
|
||||
return NULL;
|
||||
@ -726,9 +727,10 @@ jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
|
||||
JSObject* parent;
|
||||
JS_ASSERT(!jsdval->parent);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
JS_BeginRequest(jsdc->dumbContext);
|
||||
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
||||
if(!call) {
|
||||
@ -760,9 +762,10 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
|
||||
JSObject* ctor;
|
||||
JS_ASSERT(!jsdval->ctor);
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
if(!JSVAL_IS_OBJECT(jsdval->val))
|
||||
return NULL;
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
return NULL;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
proto = JS_GetPrototype(obj);
|
||||
if(!proto)
|
||||
return NULL;
|
||||
@ -791,9 +794,11 @@ jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
|
||||
jsval val = jsdval->val;
|
||||
JSCrossCompartmentCall *call = NULL;
|
||||
|
||||
if(!jsdval->className && !JSVAL_IS_PRIMITIVE(val))
|
||||
if(!jsdval->className && JSVAL_IS_OBJECT(val))
|
||||
{
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj;
|
||||
if(!(obj = JSVAL_TO_OBJECT(val)))
|
||||
return NULL;
|
||||
JS_BeginRequest(jsdc->dumbContext);
|
||||
call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
|
||||
if(!call) {
|
||||
|
@ -2240,7 +2240,7 @@ jsdValue::GetJsType (PRUint32 *_rval)
|
||||
*_rval = TYPE_VOID;
|
||||
else if (JSD_IsValueFunction (mCx, mValue))
|
||||
*_rval = TYPE_FUNCTION;
|
||||
else if (!JSVAL_IS_PRIMITIVE(val))
|
||||
else if (JSVAL_IS_OBJECT(val))
|
||||
*_rval = TYPE_OBJECT;
|
||||
else
|
||||
NS_ASSERTION (0, "Value has no discernible type.");
|
||||
|
@ -3633,8 +3633,8 @@ PointerType::ConstructData(JSContext* cx,
|
||||
jsval* argv = JS_ARGV(cx, vp);
|
||||
JSObject* baseObj = PointerType::GetBaseType(obj);
|
||||
bool looksLikeClosure = CType::GetTypeCode(baseObj) == TYPE_function &&
|
||||
argv[0].isObject() &&
|
||||
JS_ObjectIsCallable(cx, &argv[0].toObject());
|
||||
JSVAL_IS_OBJECT(argv[0]) &&
|
||||
JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||
|
||||
//
|
||||
// Case 2 - Initialized pointer
|
||||
@ -3656,9 +3656,7 @@ PointerType::ConstructData(JSContext* cx,
|
||||
// wish to pass the third argument.
|
||||
JSObject* thisObj = NULL;
|
||||
if (argc >= 2) {
|
||||
if (JSVAL_IS_NULL(argv[1])) {
|
||||
thisObj = NULL;
|
||||
} else if (!JSVAL_IS_PRIMITIVE(argv[1])) {
|
||||
if (JSVAL_IS_OBJECT(argv[1])) {
|
||||
thisObj = JSVAL_TO_OBJECT(argv[1]);
|
||||
} else if (!JS_ValueToObject(cx, argv[1], &thisObj)) {
|
||||
return JS_FALSE;
|
||||
@ -3698,7 +3696,7 @@ PointerType::TargetTypeGetter(JSContext* cx,
|
||||
}
|
||||
|
||||
*vp = JS_GetReservedSlot(obj, SLOT_TARGET_T);
|
||||
JS_ASSERT(vp->isObject());
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(*vp));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -6532,12 +6530,12 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
jsval* argv = JS_ARGV(cx, vp);
|
||||
JS::Value valCodePtr = argv[1];
|
||||
if (!valCodePtr.isObject()) {
|
||||
jsval valCodePtr = argv[1];
|
||||
if (!JSVAL_IS_OBJECT(valCodePtr) || JSVAL_IS_NULL(valCodePtr)) {
|
||||
return TypeError(cx, "_a CData object_ of a function pointer type",
|
||||
valCodePtr);
|
||||
}
|
||||
JSObject *objCodePtr = &valCodePtr.toObject();
|
||||
JSObject *objCodePtr = JSVAL_TO_OBJECT(valCodePtr);
|
||||
|
||||
//Note: Using a custom argument formatter here would be awkward (requires
|
||||
//a destructor just to uninstall the formatter).
|
||||
|
@ -4,11 +4,11 @@ BEGIN_TEST(test_BindCallable)
|
||||
{
|
||||
jsval v;
|
||||
EVAL("({ somename : 1717 })", &v);
|
||||
CHECK(v.isObject());
|
||||
CHECK(JSVAL_IS_OBJECT(v));
|
||||
|
||||
jsval func;
|
||||
EVAL("(function() { return this.somename; })", &func);
|
||||
CHECK(func.isObject());
|
||||
CHECK(JSVAL_IS_OBJECT(func));
|
||||
|
||||
JSObject* newCallable = JS_BindCallable(cx, JSVAL_TO_OBJECT(func),
|
||||
JSVAL_TO_OBJECT(v));
|
||||
|
@ -6,7 +6,7 @@ BEGIN_TEST(testConservativeGC)
|
||||
{
|
||||
jsval v2;
|
||||
EVAL("({foo: 'bar'});", &v2);
|
||||
CHECK(v2.isObject());
|
||||
CHECK(JSVAL_IS_OBJECT(v2));
|
||||
char objCopy[sizeof(JSObject)];
|
||||
js_memcpy(&objCopy, JSVAL_TO_OBJECT(v2), sizeof(JSObject));
|
||||
|
||||
@ -18,7 +18,7 @@ BEGIN_TEST(testConservativeGC)
|
||||
|
||||
jsval tmp;
|
||||
EVAL("({foo2: 'bar2'});", &tmp);
|
||||
CHECK(tmp.isObject());
|
||||
CHECK(JSVAL_IS_OBJECT(tmp));
|
||||
JSObject *obj2 = JSVAL_TO_OBJECT(tmp);
|
||||
char obj2Copy[sizeof(JSObject)];
|
||||
js_memcpy(&obj2Copy, obj2, sizeof(JSObject));
|
||||
|
@ -24,8 +24,8 @@ BEGIN_TEST(testLookup_bug522590)
|
||||
// This lookup must not return an internal function object.
|
||||
jsvalRoot r(cx);
|
||||
CHECK(JS_LookupProperty(cx, xobj, "f", r.addr()));
|
||||
CHECK(r.value().isObject());
|
||||
JSObject *funobj = &r.value().toObject();
|
||||
CHECK(JSVAL_IS_OBJECT(r));
|
||||
JSObject *funobj = JSVAL_TO_OBJECT(r);
|
||||
CHECK(funobj->isFunction());
|
||||
CHECK(!js::IsInternalFunctionObject(funobj));
|
||||
|
||||
|
@ -36,7 +36,7 @@ BEGIN_TEST(testTrap_gc)
|
||||
// execute
|
||||
jsvalRoot v2(cx);
|
||||
CHECK(JS_ExecuteScript(cx, global, script, v2.addr()));
|
||||
CHECK(v2.value().isObject());
|
||||
CHECK(JSVAL_IS_OBJECT(v2));
|
||||
CHECK_EQUAL(emptyTrapCallCount, 0);
|
||||
|
||||
// Enable debug mode
|
||||
|
@ -2696,14 +2696,18 @@ EvalInFrame(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
ShapeOf(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
ShapeOf(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JS::Value v;
|
||||
if (argc < 1 || !((v = JS_ARGV(cx, vp)[0]).isObject())) {
|
||||
jsval v;
|
||||
if (argc < 1 || !JSVAL_IS_OBJECT(v = JS_ARGV(cx, vp)[0])) {
|
||||
JS_ReportError(cx, "shapeOf: object expected");
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSObject *obj = &v.toObject();
|
||||
JSObject *obj = JSVAL_TO_OBJECT(v);
|
||||
if (!obj) {
|
||||
*vp = JSVAL_ZERO;
|
||||
return JS_TRUE;
|
||||
}
|
||||
return JS_NewNumberValue(cx, (double) ((uintptr_t)obj->lastProperty() >> 3), vp);
|
||||
}
|
||||
|
||||
@ -3852,13 +3856,13 @@ Help(JSContext *cx, unsigned argc, jsval *vp)
|
||||
jsval v;
|
||||
if (!JS_LookupPropertyById(cx, global, ida[i], &v))
|
||||
return false;
|
||||
if (!JSVAL_IS_PRIMITIVE(v) && !PrintHelp(cx, JSVAL_TO_OBJECT(v)))
|
||||
if (JSVAL_IS_OBJECT(v) && !PrintHelp(cx, JSVAL_TO_OBJECT(v)))
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
for (unsigned i = 0; i < argc; i++) {
|
||||
if (!JSVAL_IS_PRIMITIVE(argv[i]) && !PrintHelp(cx, JSVAL_TO_OBJECT(argv[i])))
|
||||
if (JSVAL_IS_OBJECT(argv[i]) && !PrintHelp(cx, JSVAL_TO_OBJECT(argv[i])))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -516,20 +516,21 @@ ReferenceFinder::addReferrer(jsval referrer, Path *path)
|
||||
Root<jsval> referrerRoot(context, &referrer);
|
||||
|
||||
/* Find the property of the results object named |pathName|. */
|
||||
JS::Value v;
|
||||
jsval v;
|
||||
if (!JS_GetProperty(context, result, pathName, &v))
|
||||
return false;
|
||||
if (v.isUndefined()) {
|
||||
if (JSVAL_IS_VOID(v)) {
|
||||
/* Create an array to accumulate referents under this path. */
|
||||
JSObject *array = JS_NewArrayObject(context, 1, &referrer);
|
||||
if (!array)
|
||||
return false;
|
||||
v.setObject(*array);
|
||||
v = OBJECT_TO_JSVAL(array);
|
||||
return !!JS_SetProperty(context, result, pathName, &v);
|
||||
}
|
||||
|
||||
/* The property's value had better be an array. */
|
||||
RootedVarObject array(context, &v.toObject());
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(v) && !JSVAL_IS_NULL(v));
|
||||
RootedVarObject array(context, JSVAL_TO_OBJECT(v));
|
||||
JS_ASSERT(JS_IsArrayObject(context, array));
|
||||
|
||||
/* Append our referrer to this array. */
|
||||
@ -560,8 +561,8 @@ FindReferences(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Value target = JS_ARGV(cx, vp)[0];
|
||||
if (!target.isObject()) {
|
||||
jsval target = JS_ARGV(cx, vp)[0];
|
||||
if (!JSVAL_IS_OBJECT(target) || JSVAL_IS_NULL(target)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
|
||||
"argument", "not an object");
|
||||
return false;
|
||||
@ -574,7 +575,7 @@ FindReferences(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
/* Given the reversed map, find the referents of target. */
|
||||
ReferenceFinder finder(cx, reverser);
|
||||
JSObject *references = finder.findReferences(RootedVarObject(cx, &target.toObject()));
|
||||
JSObject *references = finder.findReferences(RootedVarObject(cx, JSVAL_TO_OBJECT(target)));
|
||||
if (!references)
|
||||
return false;
|
||||
|
||||
|
@ -971,7 +971,7 @@ class ErrorEvent : public Event
|
||||
public:
|
||||
static ErrorEvent *create(JSContext *cx, Worker *child) {
|
||||
JSString *data = NULL;
|
||||
JS::Value exc;
|
||||
jsval exc;
|
||||
if (JS_GetPendingException(cx, &exc)) {
|
||||
AutoValueRooter tvr(cx, exc);
|
||||
JS_ClearPendingException(cx);
|
||||
@ -979,12 +979,12 @@ class ErrorEvent : public Event
|
||||
// Determine what error message to put in the error event.
|
||||
// If exc.message is a string, use that; otherwise use String(exc).
|
||||
// (This is a little different from what web workers do.)
|
||||
if (exc.isObject()) {
|
||||
JS::Value msg;
|
||||
if (!JS_GetProperty(cx, &exc.toObject(), "message", &msg))
|
||||
if (JSVAL_IS_OBJECT(exc)) {
|
||||
jsval msg;
|
||||
if (!JS_GetProperty(cx, JSVAL_TO_OBJECT(exc), "message", &msg))
|
||||
JS_ClearPendingException(cx);
|
||||
else if (msg.isString())
|
||||
data = msg.toString();
|
||||
else if (JSVAL_IS_STRING(msg))
|
||||
data = JSVAL_TO_STRING(msg);
|
||||
}
|
||||
if (!data) {
|
||||
data = JS_ValueToString(cx, exc);
|
||||
|
@ -1013,12 +1013,11 @@ mozJSComponentLoader::Import(const nsACString& registryLocation,
|
||||
|
||||
if (optionalArgc) {
|
||||
// The caller passed in the optional second argument. Get it.
|
||||
if (targetObj.isObjectOrNull()) {
|
||||
targetObject = targetObj.toObjectOrNull();
|
||||
} else {
|
||||
if (!JSVAL_IS_OBJECT(targetObj)) {
|
||||
return ReportOnCaller(cx, ERROR_SCOPE_OBJ,
|
||||
PromiseFlatCString(registryLocation).get());
|
||||
}
|
||||
targetObject = JSVAL_TO_OBJECT(targetObj);
|
||||
} else {
|
||||
// Our targetObject is the caller's global object. Find it by
|
||||
// walking the calling object's parent chain.
|
||||
@ -1172,6 +1171,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
|
||||
NS_ASSERTION(mod->global, "Import table contains entry with no global");
|
||||
*_retval = mod->global;
|
||||
|
||||
jsval symbols;
|
||||
if (targetObj) {
|
||||
JSCLContextHelper cxhelper(this);
|
||||
|
||||
@ -1179,21 +1179,20 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
|
||||
if (!ac.enter(mContext, mod->global))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JS::Value symbols;
|
||||
if (!JS_GetProperty(mContext, mod->global,
|
||||
"EXPORTED_SYMBOLS", &symbols)) {
|
||||
return ReportOnCaller(cxhelper, ERROR_NOT_PRESENT,
|
||||
PromiseFlatCString(aLocation).get());
|
||||
}
|
||||
|
||||
if (!symbols.isObject() ||
|
||||
!JS_IsArrayObject(mContext, &symbols.toObject())) {
|
||||
JSObject *symbolsObj = nsnull;
|
||||
if (!JSVAL_IS_OBJECT(symbols) ||
|
||||
!(symbolsObj = JSVAL_TO_OBJECT(symbols)) ||
|
||||
!JS_IsArrayObject(mContext, symbolsObj)) {
|
||||
return ReportOnCaller(cxhelper, ERROR_NOT_AN_ARRAY,
|
||||
PromiseFlatCString(aLocation).get());
|
||||
}
|
||||
|
||||
JSObject *symbolsObj = &symbols.toObject();
|
||||
|
||||
// Iterate over symbols array, installing symbols on targetObj:
|
||||
|
||||
uint32_t symbolCount = 0;
|
||||
|
@ -135,8 +135,8 @@ public:
|
||||
* Explicit JSObject* conversion.
|
||||
*/
|
||||
JSObject* ToJSObject() const {
|
||||
return mVal.isObject()
|
||||
? &mVal.toObject()
|
||||
return JSVAL_IS_OBJECT(mVal)
|
||||
? JSVAL_TO_OBJECT(mVal)
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
|
@ -3315,7 +3315,7 @@ nsXPCComponents_utils_Sandbox::Construct(nsIXPConnectWrappedNative *wrapper,
|
||||
nsresult
|
||||
nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * obj,
|
||||
PRUint32 argc, JS::Value * argv,
|
||||
PRUint32 argc, jsval * argv,
|
||||
jsval * vp, bool *_retval)
|
||||
{
|
||||
if (argc < 1)
|
||||
@ -3327,8 +3327,8 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsISupports *prinOrSop = nsnull;
|
||||
if (argv[0].isString()) {
|
||||
JSString *codebaseStr = argv[0].toString();
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *codebaseStr = JSVAL_TO_STRING(argv[0]);
|
||||
size_t codebaseLength;
|
||||
const jschar *codebaseChars = JS_GetStringCharsAndLength(cx, codebaseStr,
|
||||
&codebaseLength);
|
||||
@ -3356,12 +3356,12 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
|
||||
prinOrSop = principal;
|
||||
} else {
|
||||
if (argv[0].isObject()) {
|
||||
if (!JSVAL_IS_PRIMITIVE(argv[0])) {
|
||||
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
|
||||
if (!xpc)
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
xpc->GetWrappedNativeOfJSObject(cx, &argv[0].toObject(),
|
||||
xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(argv[0]),
|
||||
getter_AddRefs(wrapper));
|
||||
|
||||
if (wrapper) {
|
||||
@ -3384,10 +3384,10 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
nsCString sandboxName;
|
||||
|
||||
if (argc > 1) {
|
||||
if (!argv[1].isObject())
|
||||
if (!JSVAL_IS_OBJECT(argv[1]))
|
||||
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
|
||||
|
||||
JSObject *optionsObject = &argv[1].toObject();
|
||||
JSObject *optionsObject = JSVAL_TO_OBJECT(argv[1]);
|
||||
jsval option;
|
||||
|
||||
JSBool found;
|
||||
@ -3396,11 +3396,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
|
||||
if (found) {
|
||||
if (!JS_GetProperty(cx, optionsObject, "sandboxPrototype", &option) ||
|
||||
!option.isObject()) {
|
||||
!JSVAL_IS_OBJECT(option)) {
|
||||
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
|
||||
}
|
||||
|
||||
proto = &option.toObject();
|
||||
proto = JSVAL_TO_OBJECT(option);
|
||||
}
|
||||
|
||||
if (!JS_HasProperty(cx, optionsObject, "wantXrays", &found))
|
||||
@ -3408,11 +3408,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
|
||||
if (found) {
|
||||
if (!JS_GetProperty(cx, optionsObject, "wantXrays", &option) ||
|
||||
!option.isBoolean()) {
|
||||
!JSVAL_IS_BOOLEAN(option)) {
|
||||
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
|
||||
}
|
||||
|
||||
wantXrays = option.toBoolean();
|
||||
wantXrays = JSVAL_TO_BOOLEAN(option);
|
||||
}
|
||||
|
||||
if (!JS_HasProperty(cx, optionsObject, "sandboxName", &found))
|
||||
@ -3420,11 +3420,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
|
||||
|
||||
if (found) {
|
||||
if (!JS_GetProperty(cx, optionsObject, "sandboxName", &option) ||
|
||||
!option.isString()) {
|
||||
!JSVAL_IS_STRING(option)) {
|
||||
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
|
||||
}
|
||||
|
||||
char *tmp = JS_EncodeString(cx, option.toString());
|
||||
char *tmp = JS_EncodeString(cx, JSVAL_TO_STRING(option));
|
||||
if (!tmp) {
|
||||
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
|
||||
}
|
||||
@ -3869,18 +3869,18 @@ nsXPCComponents_Utils::SchedulePreciseShrinkingGC(ScheduledGCCallback* aCallback
|
||||
|
||||
/* [implicit_jscontext] jsval nondeterministicGetWeakMapKeys(in jsval aMap); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(const JS::Value &aMap,
|
||||
nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(const jsval &aMap,
|
||||
JSContext *aCx,
|
||||
JS::Value *aKeys)
|
||||
jsval *aKeys)
|
||||
{
|
||||
if (!aMap.isObject()) {
|
||||
aKeys->setUndefined();
|
||||
if (!JSVAL_IS_OBJECT(aMap)) {
|
||||
*aKeys = JSVAL_VOID;
|
||||
return NS_OK;
|
||||
}
|
||||
JSObject *objRet;
|
||||
if (!JS_NondeterministicGetWeakMapKeys(aCx, &aMap.toObject(), &objRet))
|
||||
if (!JS_NondeterministicGetWeakMapKeys(aCx, JSVAL_TO_OBJECT(aMap), &objRet))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aKeys = objRet ? ObjectValue(*objRet) : UndefinedValue();
|
||||
*aKeys = objRet ? OBJECT_TO_JSVAL(objRet) : JSVAL_VOID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3961,9 +3961,8 @@ nsXPCComponents_Utils::CreateObjectIn(const jsval &vobj, JSContext *cx, jsval *r
|
||||
JSBool
|
||||
FunctionWrapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
|
||||
JS::Value v = js::GetFunctionNativeReserved(callee, 0);
|
||||
NS_ASSERTION(v.isObject(), "weird function");
|
||||
jsval v = js::GetFunctionNativeReserved(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), 0);
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(v), "weird function");
|
||||
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj) {
|
||||
|
@ -529,17 +529,19 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
return false;
|
||||
case nsXPTType::T_IID:
|
||||
{
|
||||
JSObject* obj;
|
||||
const nsID* pid=nsnull;
|
||||
|
||||
// There's no good reason to pass a null IID.
|
||||
if (s.isNullOrUndefined()) {
|
||||
if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!s.isObject() ||
|
||||
(!(pid = xpc_JSObjectToID(cx, &s.toObject()))) ||
|
||||
if (!JSVAL_IS_OBJECT(s) ||
|
||||
(!(obj = JSVAL_TO_OBJECT(s))) ||
|
||||
(!(pid = xpc_JSObjectToID(cx, obj))) ||
|
||||
(!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID))))) {
|
||||
return false;
|
||||
}
|
||||
@ -794,6 +796,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
case nsXPTType::T_INTERFACE:
|
||||
case nsXPTType::T_INTERFACE_IS:
|
||||
{
|
||||
JSObject* obj;
|
||||
NS_ASSERTION(iid,"can't do interface conversions without iid");
|
||||
|
||||
if (iid->Equals(NS_GET_IID(nsIVariant))) {
|
||||
@ -822,19 +825,19 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
}
|
||||
//else ...
|
||||
|
||||
if (s.isNullOrUndefined()) {
|
||||
if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
|
||||
*((nsISupports**)d) = nsnull;
|
||||
return true;
|
||||
}
|
||||
|
||||
// only wrap JSObjects
|
||||
if (!s.isObject()) {
|
||||
if (pErr && s.isInt32() && 0 == s.toInt32())
|
||||
if (!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s))) {
|
||||
if (pErr && JSVAL_IS_INT(s) && 0 == JSVAL_TO_INT(s))
|
||||
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return JSObject2NativeInterface(ccx, (void**)d, &s.toObject(), iid,
|
||||
return JSObject2NativeInterface(ccx, (void**)d, obj, iid,
|
||||
nsnull, pErr);
|
||||
}
|
||||
default:
|
||||
@ -1740,7 +1743,7 @@ XPCConvert::JSTypedArray2Native(XPCCallContext& ccx,
|
||||
|
||||
// static
|
||||
JSBool
|
||||
XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
|
||||
XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, jsval s,
|
||||
uint32_t count, const nsXPTType& type,
|
||||
const nsID* iid, nsresult* pErr)
|
||||
{
|
||||
@ -1748,11 +1751,21 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
|
||||
|
||||
JSContext* cx = ccx.GetJSContext();
|
||||
|
||||
// No Action, FRee memory, RElease object
|
||||
enum CleanupMode {na, fr, re};
|
||||
|
||||
CleanupMode cleanupMode;
|
||||
|
||||
JSObject* jsarray = nsnull;
|
||||
void* array = nsnull;
|
||||
uint32_t initedCount;
|
||||
jsval current;
|
||||
|
||||
// XXX add support for getting chars from strings
|
||||
|
||||
// XXX add support to indicate *which* array element was not convertable
|
||||
|
||||
if (s.isNullOrUndefined()) {
|
||||
if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
|
||||
if (0 != count) {
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY;
|
||||
@ -1763,13 +1776,13 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!s.isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(s)) {
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY;
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject* jsarray = &s.toObject();
|
||||
jsarray = JSVAL_TO_OBJECT(s);
|
||||
|
||||
// If this is a typed array, then try a fast conversion with memcpy.
|
||||
if (JS_IsTypedArrayObject(jsarray, cx)) {
|
||||
@ -1810,16 +1823,9 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s,
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
// No Action, FRee memory, RElease object
|
||||
enum CleanupMode {na, fr, re};
|
||||
|
||||
CleanupMode cleanupMode;
|
||||
|
||||
void *array = nsnull;
|
||||
uint32_t initedCount;
|
||||
jsval current;
|
||||
|
||||
// XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*)
|
||||
|
||||
// XXX make extra space at end of char* and wchar* and null termintate
|
||||
|
||||
switch (type.TagPart()) {
|
||||
|
@ -79,6 +79,7 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
||||
PRInt32 lineno = 0;
|
||||
JSFunction* fun = nsnull;
|
||||
uint32_t namedArgCount = 0;
|
||||
jsval val;
|
||||
JSBool isString;
|
||||
|
||||
// get the info for this stack frame
|
||||
@ -151,11 +152,11 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp,
|
||||
}
|
||||
|
||||
// print any unnamed trailing args (found in 'arguments' object)
|
||||
JS::Value val;
|
||||
|
||||
if (JS_GetProperty(cx, callObj, "arguments", &val) &&
|
||||
val.isObject()) {
|
||||
JSVAL_IS_OBJECT(val)) {
|
||||
uint32_t argCount;
|
||||
JSObject* argsObj = &val.toObject();
|
||||
JSObject* argsObj = JSVAL_TO_OBJECT(val);
|
||||
if (JS_GetProperty(cx, argsObj, "length", &val) &&
|
||||
JS_ValueToECMAUint32(cx, val, &argCount) &&
|
||||
argCount > namedArgCount) {
|
||||
|
@ -821,24 +821,24 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
|
||||
}
|
||||
|
||||
JSObject*
|
||||
xpc_qsUnwrapObj(JS::Value v, nsISupports **ppArgRef, nsresult *rv)
|
||||
xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv)
|
||||
{
|
||||
if (v.isNullOrUndefined()) {
|
||||
if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
|
||||
*ppArgRef = nsnull;
|
||||
*rv = NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!v.isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(v)) {
|
||||
*ppArgRef = nsnull;
|
||||
*rv = ((v.isInt32() && v.toInt32() == 0)
|
||||
*rv = ((JSVAL_IS_INT(v) && JSVAL_TO_INT(v) == 0)
|
||||
? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL
|
||||
: NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
*rv = NS_OK;
|
||||
return &v.toObject();
|
||||
return JSVAL_TO_OBJECT(v);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -117,8 +117,8 @@ XPCTraceableVariant::PrintTraceName(JSTracer* trc, char *buf, size_t bufsize)
|
||||
#endif
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant)
|
||||
JS::Value val = tmp->GetJSValPreserveColor();
|
||||
if (val.isObjectOrNull()) {
|
||||
jsval val = tmp->GetJSValPreserveColor();
|
||||
if (JSVAL_IS_OBJECT(val)) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSVal");
|
||||
cb.NoteJSChild(JSVAL_TO_OBJECT(val));
|
||||
}
|
||||
@ -127,19 +127,19 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPCVariant)
|
||||
JS::Value val = tmp->GetJSValPreserveColor();
|
||||
jsval val = tmp->GetJSValPreserveColor();
|
||||
|
||||
// We're sharing val's buffer, clear the pointer to it so Cleanup() won't
|
||||
// try to delete it
|
||||
if (val.isString())
|
||||
if (JSVAL_IS_STRING(val))
|
||||
tmp->mData.u.wstr.mWStringValue = nsnull;
|
||||
nsVariant::Cleanup(&tmp->mData);
|
||||
|
||||
if (val.isMarkable()) {
|
||||
if (JSVAL_IS_TRACEABLE(val)) {
|
||||
XPCTraceableVariant *v = static_cast<XPCTraceableVariant*>(tmp);
|
||||
v->RemoveFromRootSet(nsXPConnect::GetRuntimeInstance()->GetMapLock());
|
||||
}
|
||||
tmp->mJSVal = JS::NullValue();
|
||||
tmp->mJSVal = JSVAL_NULL;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
// static
|
||||
@ -221,26 +221,26 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
|
||||
Type type;
|
||||
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JS::Value val;
|
||||
jsval val;
|
||||
if (!JS_GetElement(ccx, array, i, &val))
|
||||
return false;
|
||||
|
||||
if (val.isInt32()) {
|
||||
if (JSVAL_IS_INT(val))
|
||||
type = tInt;
|
||||
} else if (val.isDouble()) {
|
||||
else if (JSVAL_IS_DOUBLE(val))
|
||||
type = tDbl;
|
||||
} else if (val.isBoolean()) {
|
||||
else if (JSVAL_IS_BOOLEAN(val))
|
||||
type = tBool;
|
||||
} else if (val.isUndefined()) {
|
||||
else if (JSVAL_IS_VOID(val)) {
|
||||
state = tVar;
|
||||
break;
|
||||
} else if (val.isNull()) {
|
||||
} else if (JSVAL_IS_NULL(val))
|
||||
type = tNull;
|
||||
} else if (val.isString()) {
|
||||
else if (JSVAL_IS_STRING(val))
|
||||
type = tStr;
|
||||
} else {
|
||||
NS_ASSERTION(val.isObject(), "invalid type of jsval!");
|
||||
JSObject* jsobj = &val.toObject();
|
||||
else {
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!");
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(val);
|
||||
if (JS_IsArrayObject(ccx, jsobj))
|
||||
type = tArr;
|
||||
else if (xpc_JSObjectIsID(ccx, jsobj))
|
||||
@ -306,22 +306,24 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
|
||||
{
|
||||
JS_CHECK_RECURSION(ccx.GetJSContext(), return false);
|
||||
|
||||
JS::Value val = GetJSVal();
|
||||
jsval val = GetJSVal();
|
||||
|
||||
if (val.isInt32())
|
||||
return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, val.toInt32()));
|
||||
if (val.isDouble())
|
||||
return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData, val.toDouble()));
|
||||
if (val.isBoolean())
|
||||
return NS_SUCCEEDED(nsVariant::SetFromBool(&mData, val.toBoolean()));
|
||||
if (val.isUndefined())
|
||||
if (JSVAL_IS_INT(val))
|
||||
return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, JSVAL_TO_INT(val)));
|
||||
if (JSVAL_IS_DOUBLE(val))
|
||||
return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData,
|
||||
JSVAL_TO_DOUBLE(val)));
|
||||
if (JSVAL_IS_BOOLEAN(val))
|
||||
return NS_SUCCEEDED(nsVariant::SetFromBool(&mData,
|
||||
JSVAL_TO_BOOLEAN(val)));
|
||||
if (JSVAL_IS_VOID(val))
|
||||
return NS_SUCCEEDED(nsVariant::SetToVoid(&mData));
|
||||
if (val.isNull())
|
||||
if (JSVAL_IS_NULL(val))
|
||||
return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData));
|
||||
if (val.isString()) {
|
||||
if (JSVAL_IS_STRING(val)) {
|
||||
// Make our string immutable. This will also ensure null-termination,
|
||||
// which nsVariant assumes for its PRUnichar* stuff.
|
||||
JSString* str = val.toString();
|
||||
JSString* str = JSVAL_TO_STRING(val);
|
||||
if (!JS_MakeStringImmutable(ccx, str))
|
||||
return false;
|
||||
|
||||
@ -348,9 +350,9 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
|
||||
}
|
||||
|
||||
// leaving only JSObject...
|
||||
NS_ASSERTION(val.isObject(), "invalid type of jsval!");
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!");
|
||||
|
||||
JSObject* jsobj = &val.toObject();
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(val);
|
||||
|
||||
// Let's see if it is a xpcJSID.
|
||||
|
||||
|
@ -308,14 +308,14 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
||||
|
||||
if (JS_GetPendingException(cx, &jsexception)) {
|
||||
nsresult rv;
|
||||
if (jsexception.isObject()) {
|
||||
if (JSVAL_IS_OBJECT(jsexception)) {
|
||||
// XPConnect may have constructed an object to represent a
|
||||
// C++ QI failure. See if that is the case.
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
|
||||
nsXPConnect::GetXPConnect()->
|
||||
GetWrappedNativeOfJSObject(ccx,
|
||||
&jsexception.toObject(),
|
||||
JSVAL_TO_OBJECT(jsexception),
|
||||
getter_AddRefs(wrapper));
|
||||
|
||||
if (wrapper) {
|
||||
|
@ -2644,9 +2644,9 @@ CallMethodHelper::GatherAndConvertResults()
|
||||
mCallContext.SetRetVal(v);
|
||||
} else if (i < mArgc) {
|
||||
// we actually assured this before doing the invoke
|
||||
NS_ASSERTION(mArgv[i].isObject(), "out var is not object");
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(mArgv[i]), "out var is not object");
|
||||
if (!JS_SetPropertyById(mCallContext,
|
||||
&mArgv[i].toObject(),
|
||||
JSVAL_TO_OBJECT(mArgv[i]),
|
||||
mIdxValueId, &v)) {
|
||||
ThrowBadParam(NS_ERROR_XPC_CANT_SET_OUT_VAL, i, mCallContext);
|
||||
return false;
|
||||
@ -2670,14 +2670,11 @@ CallMethodHelper::QueryInterfaceFastPath() const
|
||||
Throw(NS_ERROR_XPC_NOT_ENOUGH_ARGS, mCallContext);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mArgv[0].isObject()) {
|
||||
ThrowBadParam(NS_ERROR_XPC_BAD_CONVERT_JS, 0, mCallContext);
|
||||
return false;
|
||||
}
|
||||
|
||||
const nsID* iid = xpc_JSObjectToID(mCallContext, &mArgv[0].toObject());
|
||||
if (!iid) {
|
||||
const nsID* iid;
|
||||
JSObject* obj;
|
||||
if (!JSVAL_IS_OBJECT(mArgv[0]) ||
|
||||
(!(obj = JSVAL_TO_OBJECT(mArgv[0]))) ||
|
||||
(!(iid = xpc_JSObjectToID(mCallContext, obj)))) {
|
||||
ThrowBadParam(NS_ERROR_XPC_BAD_CONVERT_JS, 0, mCallContext);
|
||||
return false;
|
||||
}
|
||||
|
@ -2890,29 +2890,30 @@ JS_EXPORT_API(void) DumpJSObject(JSObject* obj)
|
||||
xpc_DumpJSObject(obj);
|
||||
}
|
||||
|
||||
JS_EXPORT_API(void) DumpJSValue(JS::Value val)
|
||||
JS_EXPORT_API(void) DumpJSValue(jsval val)
|
||||
{
|
||||
printf("Dumping 0x%llu.\n", (long long) val.asRawBits());
|
||||
if (val.isNull()) {
|
||||
printf("Dumping 0x%llu.\n", (long long) JSVAL_TO_IMPL(val).asBits);
|
||||
if (JSVAL_IS_NULL(val)) {
|
||||
printf("Value is null\n");
|
||||
} else if (val.isObject()) {
|
||||
} else if (JSVAL_IS_OBJECT(val) || JSVAL_IS_NULL(val)) {
|
||||
printf("Value is an object\n");
|
||||
DumpJSObject(&val.toObject());
|
||||
} else if (val.isNumber()) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
DumpJSObject(obj);
|
||||
} else if (JSVAL_IS_NUMBER(val)) {
|
||||
printf("Value is a number: ");
|
||||
if (val.isInt32())
|
||||
printf("Integer %i\n", val.toInt32());
|
||||
else if (val.isDouble())
|
||||
printf("Floating-point value %f\n", val.toDouble());
|
||||
} else if (val.isString()) {
|
||||
if (JSVAL_IS_INT(val))
|
||||
printf("Integer %i\n", JSVAL_TO_INT(val));
|
||||
else if (JSVAL_IS_DOUBLE(val))
|
||||
printf("Floating-point value %f\n", JSVAL_TO_DOUBLE(val));
|
||||
} else if (JSVAL_IS_STRING(val)) {
|
||||
printf("Value is a string: ");
|
||||
putc('<', stdout);
|
||||
JS_FileEscapedString(stdout, val.toString(), 0);
|
||||
JS_FileEscapedString(stdout, JSVAL_TO_STRING(val), 0);
|
||||
fputs(">\n", stdout);
|
||||
} else if (val.isBoolean()) {
|
||||
} else if (JSVAL_IS_BOOLEAN(val)) {
|
||||
printf("Value is boolean: ");
|
||||
printf(val.isTrue() ? "true" : "false");
|
||||
} else if (val.isUndefined()) {
|
||||
printf(JSVAL_TO_BOOLEAN(val) ? "true" : "false");
|
||||
} else if (JSVAL_IS_VOID(val)) {
|
||||
printf("Value is undefined\n");
|
||||
} else {
|
||||
printf("No idea what this value is.\n");
|
||||
|
@ -533,20 +533,20 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
|
||||
return true;
|
||||
}
|
||||
|
||||
JS::Value exposedProps;
|
||||
jsval exposedProps;
|
||||
if (!JS_LookupPropertyById(cx, wrappedObject, exposedPropsId, &exposedProps))
|
||||
return false;
|
||||
|
||||
if (exposedProps.isNullOrUndefined()) {
|
||||
if (JSVAL_IS_VOID(exposedProps) || JSVAL_IS_NULL(exposedProps)) {
|
||||
return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny
|
||||
}
|
||||
|
||||
if (!exposedProps.isObject()) {
|
||||
if (!JSVAL_IS_OBJECT(exposedProps)) {
|
||||
JS_ReportError(cx, "__exposedProps__ must be undefined, null, or an Object");
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject *hallpass = &exposedProps.toObject();
|
||||
JSObject *hallpass = JSVAL_TO_OBJECT(exposedProps);
|
||||
|
||||
Access access = NO_ACCESS;
|
||||
|
||||
|
@ -147,29 +147,30 @@ checkAndLogStatementPerformance(sqlite3_stmt *aStatement)
|
||||
nsIVariant *
|
||||
convertJSValToVariant(
|
||||
JSContext *aCtx,
|
||||
JS::Value aValue)
|
||||
jsval aValue)
|
||||
{
|
||||
if (aValue.isInt32())
|
||||
return new IntegerVariant(aValue.toInt32());
|
||||
if (JSVAL_IS_INT(aValue))
|
||||
return new IntegerVariant(JSVAL_TO_INT(aValue));
|
||||
|
||||
if (aValue.isDouble())
|
||||
return new FloatVariant(aValue.toDouble());
|
||||
if (JSVAL_IS_DOUBLE(aValue))
|
||||
return new FloatVariant(JSVAL_TO_DOUBLE(aValue));
|
||||
|
||||
if (aValue.isString()) {
|
||||
if (JSVAL_IS_STRING(aValue)) {
|
||||
JSString *str = JSVAL_TO_STRING(aValue);
|
||||
nsDependentJSString value;
|
||||
if (!value.init(aCtx, aValue))
|
||||
if (!value.init(aCtx, str))
|
||||
return nsnull;
|
||||
return new TextVariant(value);
|
||||
}
|
||||
|
||||
if (aValue.isBoolean())
|
||||
return new IntegerVariant(aValue.isTrue() ? 1 : 0);
|
||||
if (JSVAL_IS_BOOLEAN(aValue))
|
||||
return new IntegerVariant((aValue == JSVAL_TRUE) ? 1 : 0);
|
||||
|
||||
if (aValue.isNull())
|
||||
if (JSVAL_IS_NULL(aValue))
|
||||
return new NullVariant();
|
||||
|
||||
if (aValue.isObject()) {
|
||||
JSObject* obj = &aValue.toObject();
|
||||
if (JSVAL_IS_OBJECT(aValue)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(aValue);
|
||||
// We only support Date instances, all others fail.
|
||||
if (!::js_DateIsValid(aCtx, obj))
|
||||
return nsnull;
|
||||
|
Loading…
Reference in New Issue
Block a user