fix: add native function to create preload script (#13032)

* add native function to create preload script

* add tests

* fix formatting

* fix tests

* rerun CI
This commit is contained in:
PalmerAL 2018-07-12 21:17:11 -05:00 committed by Cheng Zhao
parent e922b1733b
commit ffc15e02a6
4 changed files with 36 additions and 4 deletions

View file

@ -81,11 +81,19 @@ base::CommandLine::StringVector GetArgv() {
return base::CommandLine::ForCurrentProcess()->argv();
}
v8::Local<v8::Value> CreatePreloadScript(v8::Isolate* isolate,
v8::Local<v8::String> preloadSrc) {
auto script = v8::Script::Compile(preloadSrc);
auto func = script->Run();
return func;
}
void InitializeBindings(v8::Local<v8::Object> binding,
v8::Local<v8::Context> context) {
auto* isolate = context->GetIsolate();
mate::Dictionary b(isolate, binding);
b.SetMethod("get", GetBinding);
b.SetMethod("createPreloadScript", CreatePreloadScript);
b.SetMethod("crash", AtomBindings::Crash);
b.SetMethod("hang", AtomBindings::Hang);
b.SetMethod("getArgv", GetArgv);