Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: test/inspector/inspector-test.cc

Issue 2410933002: [inspector] fix timestamp formatting with non C locales (Closed)
Patch Set: a Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/v8-console-message.cc ('k') | test/inspector/runtime/protocol-works-with-different-locale.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/inspector-test.cc
diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc
index b7165acc2a57293bd96ef644bfdd139f32e351a4..7fe6b8046862073f717e227fea94278cc86b2ff9 100644
--- a/test/inspector/inspector-test.cc
+++ b/test/inspector/inspector-test.cc
@@ -6,6 +6,8 @@
#include <unistd.h> // NOLINT
#endif // !defined(_WIN32) && !defined(_WIN64)
+#include <locale.h>
+
#include "include/libplatform/libplatform.h"
#include "include/v8.h"
@@ -29,7 +31,9 @@ class UtilsExtension : public v8::Extension {
public:
UtilsExtension()
: v8::Extension("v8_inspector/utils",
- "native function print(); native function quit();") {}
+ "native function print();"
+ "native function quit();"
+ "native function setlocale();") {}
virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<v8::String> name) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
@@ -44,6 +48,12 @@ class UtilsExtension : public v8::Extension {
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, UtilsExtension::Quit);
+ } else if (name->Equals(context,
+ v8::String::NewFromUtf8(isolate, "setlocale",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .FromJust()) {
+ return v8::FunctionTemplate::New(isolate, UtilsExtension::SetLocale);
}
return v8::Local<v8::FunctionTemplate>();
}
@@ -83,6 +93,15 @@ class UtilsExtension : public v8::Extension {
}
static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { Exit(); }
+
+ static void SetLocale(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsString()) {
+ fprintf(stderr, "Internal error: setlocale get one string argument.");
+ Exit();
+ }
+ v8::String::Utf8Value str(args[0]);
+ setlocale(LC_NUMERIC, *str);
+ }
};
class SetTimeoutTask : public TaskRunner::Task {
« no previous file with comments | « src/inspector/v8-console-message.cc ('k') | test/inspector/runtime/protocol-works-with-different-locale.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698