Bug 1003336 - OS.Constants.Sys.Name should not be "Android" for Firefox OS. r=yoric

This commit is contained in:
Lynn Tran 2014-07-04 18:20:49 -04:00
parent 21c969cd34
commit 38642f30c7
5 changed files with 22 additions and 6 deletions

View File

@ -857,6 +857,16 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
return false;
}
#if defined(MOZ_WIDGET_GONK)
JSString* strVersion = JS_NewStringCopyZ(cx, "Gonk");
if (!strVersion){
return false;
}
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
return false;
}
#else
nsCOMPtr<nsIXULRuntime> runtime = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
if (runtime) {
nsAutoCString os;
@ -873,6 +883,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
return false;
}
}
#endif // defined(MOZ_WIDGET_GONK)
#if defined(DEBUG)
JS::Rooted<JS::Value> valDebug(cx, JSVAL_TRUE);

View File

@ -784,8 +784,8 @@ File.prototype = {
};
if (SharedAll.Constants.Sys.Name != "Android") {
/**
if (SharedAll.Constants.Sys.Name != "Android" && SharedAll.Constants.Sys.Name != "Gonk") {
/**
* Set the last access and modification date of the file.
* The time stamp resolution is 1 second at best, but might be worse
* depending on the platform.

View File

@ -15,7 +15,12 @@ add_task(function* check_definition() {
do_check_true(OS.Constants.Path!=null);
do_check_true(OS.Constants.Sys!=null);
//check system name
do_check_eq(OS.Constants.Sys.Name, Services.appinfo.OS);
if (OS.Constants.Sys.Name == "Gonk") {
// Services.appinfo.OS doesn't know the difference between Gonk and Android
do_check_eq(Services.appinfo.OS, "Android");
} else {
do_check_eq(Services.appinfo.OS, OS.Constants.Sys.Name);
}
//check if using DEBUG build
if (Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).isDebugBuild == true) {
@ -23,4 +28,4 @@ add_task(function* check_definition() {
} else {
do_check_true(typeof(OS.Constants.Sys.DEBUG) == 'undefined');
}
});
});

View File

@ -97,7 +97,7 @@ add_task(function* test_nonproto() {
// Prototypical tests, operating on |File| handles.
add_task(function* test_proto() {
if (OS.Constants.Sys.Name == "Android") {
if (OS.Constants.Sys.Name == "Android" || OS.Constants.Sys.Name == "Gonk") {
do_print("File.prototype.setDates is not implemented for Android/B2G");
do_check_eq(OS.File.prototype.setDates, undefined);
return;

View File

@ -58,7 +58,7 @@ add_task(function* test_simple_paths() {
// Test presence of paths that only exist on Desktop platforms
add_task(function* test_desktop_paths() {
if (OS.Constants.Sys.Name == "Android") {
if (OS.Constants.Sys.Name == "Android" || OS.Constants.Sys.Name == "Gonk") {
return;
}
do_check_true(!!OS.Constants.Path.desktopDir);