From 38642f30c7a65466678bc95074ca8e6c3905c7c8 Mon Sep 17 00:00:00 2001 From: Lynn Tran Date: Fri, 4 Jul 2014 18:20:49 -0400 Subject: [PATCH] Bug 1003336 - OS.Constants.Sys.Name should not be "Android" for Firefox OS. r=yoric --- dom/system/OSFileConstants.cpp | 11 +++++++++++ .../components/osfile/modules/osfile_async_front.jsm | 4 ++-- .../osfile/tests/xpcshell/test_constants.js | 9 +++++++-- .../tests/xpcshell/test_osfile_async_setDates.js | 2 +- .../osfile/tests/xpcshell/test_path_constants.js | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index 4190fc9a4c7..0c779f8fddf 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -857,6 +857,16 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) return false; } +#if defined(MOZ_WIDGET_GONK) + JSString* strVersion = JS_NewStringCopyZ(cx, "Gonk"); + if (!strVersion){ + return false; + } + JS::Rooted valVersion(cx, STRING_TO_JSVAL(strVersion)); + if (!JS_SetProperty(cx, objSys, "Name", valVersion)) { + return false; + } +#else nsCOMPtr runtime = do_GetService(XULRUNTIME_SERVICE_CONTRACTID); if (runtime) { nsAutoCString os; @@ -873,6 +883,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) return false; } } +#endif // defined(MOZ_WIDGET_GONK) #if defined(DEBUG) JS::Rooted valDebug(cx, JSVAL_TRUE); diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm index ac5b1ec5a6a..98f5a02773f 100644 --- a/toolkit/components/osfile/modules/osfile_async_front.jsm +++ b/toolkit/components/osfile/modules/osfile_async_front.jsm @@ -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. diff --git a/toolkit/components/osfile/tests/xpcshell/test_constants.js b/toolkit/components/osfile/tests/xpcshell/test_constants.js index 129a131fa19..e92f33ab834 100644 --- a/toolkit/components/osfile/tests/xpcshell/test_constants.js +++ b/toolkit/components/osfile/tests/xpcshell/test_constants.js @@ -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'); } -}); \ No newline at end of file +}); diff --git a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js index 9d18ce795e1..155f8d48a81 100644 --- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js +++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js @@ -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; diff --git a/toolkit/components/osfile/tests/xpcshell/test_path_constants.js b/toolkit/components/osfile/tests/xpcshell/test_path_constants.js index b219ca686ab..3edf94d33c1 100644 --- a/toolkit/components/osfile/tests/xpcshell/test_path_constants.js +++ b/toolkit/components/osfile/tests/xpcshell/test_path_constants.js @@ -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);