mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 21:07:30 +09:00
Bug 1287677 - Add mozIntl.getDisplayNames API
This commit is contained in:
parent
cac5c5adc7
commit
5381ebe25c
9 changed files with 718 additions and 0 deletions
|
|
@ -48,6 +48,32 @@ MozIntl::AddGetCalendarInfo(JS::Handle<JS::Value> val, JSContext* cx)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MozIntl::AddGetDisplayNames(JS::Handle<JS::Value> val, JSContext* cx)
|
||||
{
|
||||
if (!val.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
|
||||
if (!realIntlObj) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, realIntlObj);
|
||||
|
||||
static const JSFunctionSpec funcs[] = {
|
||||
JS_SELF_HOSTED_FN("getDisplayNames", "Intl_getDisplayNames", 2, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
if (!JS_DefineFunctions(cx, realIntlObj, funcs)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(MozIntl)
|
||||
NS_DEFINE_NAMED_CID(MOZ_MOZINTL_CID);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@
|
|||
interface mozIMozIntl : nsISupports
|
||||
{
|
||||
[implicit_jscontext] void addGetCalendarInfo(in jsval intlObject);
|
||||
[implicit_jscontext] void addGetDisplayNames(in jsval intlObject);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ function run_test() {
|
|||
|
||||
test_this_global(mozIntl);
|
||||
test_cross_global(mozIntl);
|
||||
test_methods_presence(mozIntl);
|
||||
|
||||
ok(true);
|
||||
}
|
||||
|
|
@ -30,3 +31,16 @@ function test_cross_global(mozIntl) {
|
|||
equal(waivedX.getCalendarInfo() instanceof Object, false);
|
||||
equal(waivedX.getCalendarInfo() instanceof global.Object, true);
|
||||
}
|
||||
|
||||
function test_methods_presence(mozIntl) {
|
||||
equal(mozIntl.addGetCalendarInfo instanceof Function, true);
|
||||
equal(mozIntl.addGetDisplayNames instanceof Function, true);
|
||||
|
||||
let x = {};
|
||||
|
||||
mozIntl.addGetCalendarInfo(x);
|
||||
equal(x.getCalendarInfo instanceof Function, true);
|
||||
|
||||
mozIntl.addGetDisplayNames(x);
|
||||
equal(x.getDisplayNames instanceof Function, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue