@@ -279,17 +279,20 @@ void ShellContentRendererClient::InstallNodeSymbols(
279
279
}
280
280
281
281
if (use_node) {
282
- v8::Local<v8::Script> script = v8::Script::New (v8::String::New (
282
+ RenderViewImpl* rv = RenderViewImpl::FromWebView (frame->view ());
283
+ v8::Local<v8::Script> script = v8::Script::New (v8::String::New ((
283
284
// Make node's relative modules work
284
285
" if (!process.mainModule.filename) {"
286
+ " var root = '" + rv->renderer_preferences_ .nw_app_root_path .AsUTF8Unsafe () + " ';"
285
287
#if defined(OS_WIN)
286
288
" process.mainModule.filename = decodeURIComponent(window.location.pathname.substr(1));"
287
289
#else
288
290
" process.mainModule.filename = decodeURIComponent(window.location.pathname);"
289
291
#endif
292
+ " if (window.location.href.indexOf('app://') === 0) {process.mainModule.filename = root + '/' + process.mainModule.filename}"
290
293
" process.mainModule.paths = global.require('module')._nodeModulePaths(process.cwd());"
291
294
" process.mainModule.loaded = true;"
292
- " }"
295
+ " }" ). c_str ()
293
296
));
294
297
script->Run ();
295
298
}
@@ -318,7 +321,7 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
318
321
// Do nothing if user is listening to uncaughtException.
319
322
v8::Local<v8::Value> listeners_v =
320
323
node::process->Get (v8::String::New (" listeners" ));
321
- v8::Local<v8::Function> listeners =
324
+ v8::Local<v8::Function> listeners =
322
325
v8::Local<v8::Function>::Cast (listeners_v);
323
326
324
327
v8::Local<v8::Value> argv[1 ] = { v8::String::New (" uncaughtException" ) };
@@ -327,7 +330,7 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
327
330
328
331
uint32_t length = listener_array->Length ();
329
332
if (length > 1 )
330
- return v8::Undefined ();
333
+ return v8::Undefined ();
331
334
332
335
// Print stacktrace.
333
336
v8::Local<v8::String> stack_symbol = v8::String::New (" stack" );
@@ -341,13 +344,13 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
341
344
342
345
RenderView* render_view = GetCurrentRenderView ();
343
346
if (!render_view)
344
- return v8::Undefined ();
347
+ return v8::Undefined ();
345
348
346
349
render_view->Send (new ShellViewHostMsg_UncaughtException (
347
350
render_view->GetRoutingID (),
348
351
error));
349
352
350
- return v8::Undefined ();
353
+ return v8::Undefined ();
351
354
}
352
355
353
356
void ShellContentRendererClient::UninstallNodeSymbols (
0 commit comments