зеркало из https://github.com/mozilla/gecko-dev.git
Bug 821633 - Alarm API - .getAll() need to wrap the objects respecting to the content window (part 1, ObjectWrapper.jsm and Cu.createDateIn()). r=sicking, a=blocking-basecamp
This commit is contained in:
Родитель
647303548c
Коммит
045e02747a
|
@ -22,6 +22,8 @@ this.ObjectWrapper = {
|
|||
return "file";
|
||||
} else if (aObject instanceof Ci.nsIDOMBlob) {
|
||||
return "blob";
|
||||
} else if (aObject instanceof Date) {
|
||||
return "date";
|
||||
} else if (typeof aObject == "object") {
|
||||
return "object";
|
||||
} else {
|
||||
|
@ -44,6 +46,8 @@ this.ObjectWrapper = {
|
|||
type: aObject.type });
|
||||
} else if (kind == "blob") {
|
||||
return new aCtxt.Blob([aObject], { type: aObject.type });
|
||||
} else if (kind == "date") {
|
||||
return Cu.createDateIn(aCtxt, aObject.getTime());
|
||||
} else if (kind == "primitive") {
|
||||
return aObject;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ interface ScheduledGCCallback : nsISupports
|
|||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(36c19d92-d4a9-4ad1-bee3-945f60c6c991)]
|
||||
[scriptable, uuid(33c33992-6ace-4e15-9bed-c9b232d44723)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
|
@ -300,6 +300,14 @@ interface nsIXPCComponents_Utils : nsISupports
|
|||
[implicit_jscontext]
|
||||
jsval createArrayIn(in jsval vobj);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
* Returns a date given timestamp |msec| created in |vobj|'s compartment.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
jsval createDateIn(in jsval vobj, in long long msec);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
|
|
|
@ -4203,6 +4203,34 @@ nsXPCComponents_Utils::CreateArrayIn(const jsval &vobj, JSContext *cx, jsval *rv
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* jsval createDateIn(in jsval vobj, in long long msec); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::CreateDateIn(const jsval &vobj,
|
||||
int64_t msec,
|
||||
JSContext *cx, jsval *rval)
|
||||
{
|
||||
if (!cx)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// first argument must be an object
|
||||
if (JSVAL_IS_PRIMITIVE(vobj))
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
|
||||
JSObject *scope = js::UnwrapObject(JSVAL_TO_OBJECT(vobj));
|
||||
JSObject *obj;
|
||||
{
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
obj = JS_NewDateObjectMsec(cx, msec);
|
||||
if (!obj)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(cx, &obj))
|
||||
return NS_ERROR_FAILURE;
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSBool
|
||||
FunctionWrapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче