| Index: test/inspector/inspector-test.cc
|
| diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc
|
| index 7fe6b8046862073f717e227fea94278cc86b2ff9..77310157a65298716de691212eeb51b64a25b942 100644
|
| --- a/test/inspector/inspector-test.cc
|
| +++ b/test/inspector/inspector-test.cc
|
| @@ -33,7 +33,8 @@ class UtilsExtension : public v8::Extension {
|
| : v8::Extension("v8_inspector/utils",
|
| "native function print();"
|
| "native function quit();"
|
| - "native function setlocale();") {}
|
| + "native function setlocale();"
|
| + "native function load();") {}
|
| virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
|
| v8::Isolate* isolate, v8::Local<v8::String> name) {
|
| v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
| @@ -54,6 +55,12 @@ class UtilsExtension : public v8::Extension {
|
| .ToLocalChecked())
|
| .FromJust()) {
|
| return v8::FunctionTemplate::New(isolate, UtilsExtension::SetLocale);
|
| + } else if (name->Equals(context,
|
| + v8::String::NewFromUtf8(isolate, "load",
|
| + v8::NewStringType::kNormal)
|
| + .ToLocalChecked())
|
| + .FromJust()) {
|
| + return v8::FunctionTemplate::New(isolate, UtilsExtension::Load);
|
| }
|
| return v8::Local<v8::FunctionTemplate>();
|
| }
|
| @@ -102,6 +109,29 @@ class UtilsExtension : public v8::Extension {
|
| v8::String::Utf8Value str(args[0]);
|
| setlocale(LC_NUMERIC, *str);
|
| }
|
| +
|
| + static void Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| + if (args.Length() != 1 || !args[0]->IsString()) {
|
| + fprintf(stderr, "Internal error: load gets one string argument.");
|
| + Exit();
|
| + }
|
| + v8::String::Utf8Value str(args[0]);
|
| + v8::Isolate* isolate = args.GetIsolate();
|
| + bool exists = false;
|
| + std::string filename(*str, str.length());
|
| + v8::internal::Vector<const char> chars =
|
| + v8::internal::ReadFile(filename.c_str(), &exists);
|
| + if (!exists) {
|
| + isolate->ThrowException(
|
| + v8::String::NewFromUtf8(isolate, "Error loading file",
|
| + v8::NewStringType::kNormal)
|
| + .ToLocalChecked());
|
| + return;
|
| + }
|
| + ExecuteStringTask task(chars);
|
| + v8::Global<v8::Context> context(isolate, isolate->GetCurrentContext());
|
| + task.Run(isolate, context);
|
| + }
|
| };
|
|
|
| class SetTimeoutTask : public TaskRunner::Task {
|
|
|