@@ -248,40 +248,40 @@ void ContextCreationHook(blink::WebLocalFrame* frame, ScriptContext* context) {
248
248
std::string flavor = " normal" ;
249
249
#endif
250
250
v8::Local<v8::Script> script =
251
- v8::Script::Compile (v8::String::NewFromUtf8 (isolate,
251
+ v8::Script::Compile (dom_context, v8::String::NewFromUtf8 (isolate,
252
252
(std::string (" process.versions['nw'] = '" NW_VERSION_STRING " ';" ) +
253
253
" process.versions['node-webkit'] = '" NW_VERSION_STRING " ';"
254
254
" process.versions['nw-commit-id'] = '" NW_COMMIT_HASH " ';"
255
255
" process.versions['nw-flavor'] = '" + flavor + " ';"
256
256
" process.versions['chromium'] = '" + GetChromiumVersion () + " ';" ).c_str ()
257
- ) );
258
- script->Run ();
257
+ )). ToLocalChecked ( );
258
+ ignore_result ( script->Run (dom_context) );
259
259
}
260
260
261
261
if (extension && extension->manifest ()->GetString (manifest_keys::kNWJSInternalMainFilename , &main_fn)) {
262
- v8::Local<v8::Script> script = v8::Script::Compile (v8::String::NewFromUtf8 (isolate,
263
- (" global.__filename = '" + main_fn + " ';" ).c_str ()));
264
- script->Run ();
262
+ v8::Local<v8::Script> script = v8::Script::Compile (dom_context, v8::String::NewFromUtf8 (isolate,
263
+ (" global.__filename = '" + main_fn + " ';" ).c_str ())). ToLocalChecked ( );
264
+ ignore_result ( script->Run (dom_context) );
265
265
}
266
266
{
267
267
std::string root_path = extension_root;
268
268
#if defined(OS_WIN)
269
269
base::ReplaceChars (root_path, " \\ " , " \\\\ " , &root_path);
270
270
#endif
271
271
base::ReplaceChars (root_path, " '" , " \\ '" , &root_path);
272
- v8::Local<v8::Script> script = v8::Script::Compile (v8::String::NewFromUtf8 (isolate,
273
- (" global.__dirname = '" + root_path + " ';" ).c_str ()));
274
- script->Run ();
272
+ v8::Local<v8::Script> script = v8::Script::Compile (dom_context, v8::String::NewFromUtf8 (isolate,
273
+ (" global.__dirname = '" + root_path + " ';" ).c_str ())). ToLocalChecked ( );
274
+ ignore_result ( script->Run (dom_context) );
275
275
}
276
276
bool content_verification = false ;
277
277
if (extension && extension->manifest ()->GetBoolean (manifest_keys::kNWJSContentVerifyFlag ,
278
278
&content_verification) && content_verification) {
279
279
v8::Local<v8::Script> script =
280
- v8::Script::Compile (v8::String::NewFromUtf8 (isolate,
280
+ v8::Script::Compile (dom_context, v8::String::NewFromUtf8 (isolate,
281
281
(std::string (" global.__nwjs_cv = true;" ) +
282
- " global.__nwjs_ext_id = '" + extension->id () + " ';" ).c_str ()));
282
+ " global.__nwjs_ext_id = '" + extension->id () + " ';" ).c_str ())). ToLocalChecked () ;
283
283
284
- script->Run ();
284
+ ignore_result ( script->Run (dom_context) );
285
285
}
286
286
287
287
dom_context->Exit ();
@@ -334,7 +334,8 @@ void ContextCreationHook(blink::WebLocalFrame* frame, ScriptContext* context) {
334
334
base::ReplaceChars (root_path, " \\ " , " \\\\ " , &root_path);
335
335
#endif
336
336
base::ReplaceChars (root_path, " '" , " \\ '" , &root_path);
337
- v8::Local<v8::Script> script = v8::Script::Compile (v8::String::NewFromUtf8 (isolate, (
337
+ v8::ScriptOrigin origin (v8::String::NewFromUtf8 (isolate, " process_main" ));
338
+ v8::Local<v8::Script> script = v8::Script::Compile (context->v8_context (), v8::String::NewFromUtf8 (isolate, (
338
339
set_nw_script +
339
340
// Make node's relative modules work
340
341
" if (typeof nw.process != 'undefined' && "
@@ -345,10 +346,9 @@ void ContextCreationHook(blink::WebLocalFrame* frame, ScriptContext* context) {
345
346
" nw.process.mainModule.filename = root + p;"
346
347
" nw.process.mainModule.paths = nw.global.require('module')._nodeModulePaths(nw.process.cwd());"
347
348
" nw.process.mainModule.loaded = true;"
348
- " }" ).c_str ()),
349
- v8::String::NewFromUtf8 (isolate, " process_main" ));
349
+ " }" ).c_str ()), &origin).ToLocalChecked ();
350
350
CHECK (*script);
351
- script->Run ();
351
+ ignore_result ( script->Run (context-> v8_context ()) );
352
352
}
353
353
}
354
354
@@ -473,17 +473,17 @@ void DocumentElementHook(blink::WebLocalFrame* frame,
473
473
#endif
474
474
base::ReplaceChars (root_path, " '" , " \\ '" , &root_path);
475
475
476
- v8::Local<v8::Script> script2 = v8::Script::Compile (v8::String::NewFromUtf8 (isolate, (
476
+ v8::ScriptOrigin origin (v8::String::NewFromUtf8 (isolate, " process_main2" ));
477
+ v8::Local<v8::Script> script2 = v8::Script::Compile (v8_context, v8::String::NewFromUtf8 (isolate, (
477
478
" 'use strict';"
478
479
" if (typeof nw != 'undefined' && typeof __filename == 'undefined') {"
479
480
" let root = '" + root_path + " ';"
480
481
" let path = '" + path + " ';"
481
482
" nw.__filename = root + path;"
482
483
" nw.__dirname = root;"
483
- " }" ).c_str ()),
484
- v8::String::NewFromUtf8 (isolate, " process_main2" ));
484
+ " }" ).c_str ()), &origin).ToLocalChecked ();
485
485
CHECK (*script2);
486
- script2->Run ();
486
+ ignore_result ( script2->Run (v8_context) );
487
487
}
488
488
RenderViewImpl* rv = RenderViewImpl::FromWebView (frame->View ());
489
489
if (!rv)
0 commit comments