Bug 1003336 - OS.Constants.Sys.Name should not be "Android" for Firefox OS. r=yoric
authorLynn Tran <lynn_tran@outlook.com>
Fri, 04 Jul 2014 18:20:49 -0400
changeset 193131 3042cb4e521eb5d0b0fd5be321d10a21b5ef6995
parent 193130 21423398898b5762c88ca006dad6e580514765c9
child 193132 d8f5695199eff971d891c138d45bb8dcacbb3b10
push id27109
push userryanvm@gmail.com
push dateWed, 09 Jul 2014 20:12:42 +0000
treeherdermozilla-central@fc35681b0a87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs1003336
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1003336 - OS.Constants.Sys.Name should not be "Android" for Firefox OS. r=yoric
dom/system/OSFileConstants.cpp
toolkit/components/osfile/modules/osfile_async_front.jsm
toolkit/components/osfile/tests/xpcshell/test_constants.js
toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js
toolkit/components/osfile/tests/xpcshell/test_path_constants.js
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -852,32 +852,43 @@ bool DefineOSFileConstants(JSContext *cx
 
   // Build OS.Constants.Sys
 
   JS::Rooted<JSObject*> objSys(cx);
   if (!(objSys = GetOrCreateObjectProperty(cx, objConstants, "Sys"))) {
     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;
     DebugOnly<nsresult> rv = runtime->GetOS(os);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
 
     JSString* strVersion = JS_NewStringCopyZ(cx, os.get());
     if (!strVersion) {
       return false;
     }
 
     JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
     if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
       return false;
     }
   }
+#endif // defined(MOZ_WIDGET_GONK)
 
 #if defined(DEBUG)
   JS::Rooted<JS::Value> valDebug(cx, JSVAL_TRUE);
   if (!JS_SetProperty(cx, objSys, "DEBUG", valDebug)) {
     return false;
   }
 #endif
 
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -779,18 +779,18 @@ File.prototype = {
    */
   setPermissions: function setPermissions(options = {}) {
     return Scheduler.post("File_prototype_setPermissions",
                           [this._fdmsg, options]);
   }
 };
 
 
-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.
    *
    * WARNING: This method is not implemented on Android/B2G. On Android/B2G,
    * you should use File.setDates instead.
    *
    * @return {promise}
--- a/toolkit/components/osfile/tests/xpcshell/test_constants.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_constants.js
@@ -10,17 +10,22 @@ function run_test() {
 
 // Test that OS.Constants is defined correctly.
 add_task(function* check_definition() {
   do_check_true(OS.Constants!=null);
   do_check_true(!!OS.Constants.Win || !!OS.Constants.libc);
   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) {
     do_check_true(OS.Constants.Sys.DEBUG);
   } else {
     do_check_true(typeof(OS.Constants.Sys.DEBUG) == 'undefined');
   }
-});
\ No newline at end of file
+});
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js
@@ -92,17 +92,17 @@ add_task(function* test_nonproto() {
   } finally {
     // Remove the temp file again
     yield OS.File.remove(path);
   }
 });
 
 // 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;
   }
 
   // First, create a file we can mess with.
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                               "test_osfile_async_setDates_proto.tmp");
--- a/toolkit/components/osfile/tests/xpcshell/test_path_constants.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_path_constants.js
@@ -53,17 +53,17 @@ add_task(function* test_before_after_pro
 add_task(function* test_simple_paths() {
   do_check_true(!!OS.Constants.Path.tmpDir);
   compare_paths(OS.Constants.Path.tmpDir, "TmpD");
 
 });
 
 // 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);
   do_check_true(!!OS.Constants.Path.homeDir);
 
   compare_paths(OS.Constants.Path.homeDir, "Home");
   compare_paths(OS.Constants.Path.desktopDir, "Desk");
   compare_paths(OS.Constants.Path.userApplicationDataDir, "UAppData");