diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 5c42d9986908..85e76257767c 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -121,7 +121,8 @@ Dump(JSContext *cx, unsigned argc, jsval *vp) if (!chars) return false; - NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast(chars)); + NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast(chars), + length); #ifdef ANDROID __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get()); #endif diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index d4599d2f41b5..f9cd1050baf8 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -287,14 +287,22 @@ Dump(JSContext *cx, unsigned argc, jsval *vp) if (!str) return false; - JSAutoByteString bytes(cx, str); - if (!bytes) + size_t length; + const jschar *chars = JS_GetStringCharsAndLength(cx, str, &length); + if (!chars) return false; + NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast(chars), + length); #ifdef ANDROID - __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", bytes.ptr()); + __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get()); #endif - fputs(bytes.ptr(), gOutFile); +#ifdef XP_WIN + if (IsDebuggerPresent()) { + OutputDebugStringW(reinterpret_cast(chars)); + } +#endif + fputs(utf8str.get(), gOutFile); fflush(gOutFile); return true; } diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 000968d43cbe..98fc996df618 100644 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -71,14 +71,6 @@ import manifestparser import mozcrash import mozinfo -# --------------------------------------------------------------- -#TODO: replace this with json.loads when Python 2.6 is required. -def parse_json(j): - """ - Awful hack to parse a restricted subset of JSON strings into Python dicts. - """ - return eval(j, {'true':True,'false':False,'null':None}) - """ Control-C handling """ gotSIGINT = False def markGotSIGINT(signum, stackFrame): @@ -448,6 +440,9 @@ class XPCShellTestThread(Thread): human-readable log message. """ message = self.message_from_line(line) + if isinstance(message, unicode): + message = message.encode("utf-8") + if message.endswith('\n'): # A new line is always added by head.js to delimit messages, # however consumers will want to supply their own. @@ -1251,7 +1246,7 @@ class XPCShellTests(object): if not os.path.isfile(mozInfoFile): self.log.error("Error: couldn't find mozinfo.json at '%s'. Perhaps you need to use --build-info-json?" % mozInfoFile) return False - self.mozInfo = parse_json(open(mozInfoFile).read()) + self.mozInfo = json.loads(open(mozInfoFile).read()) mozinfo.update(self.mozInfo) # The appDirKey is a optional entry in either the default or individual test