@@ -279,17 +279,20 @@ void ShellContentRendererClient::InstallNodeSymbols(
279279 }
280280
281281 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 ((
283284 // Make node's relative modules work
284285 " if (!process.mainModule.filename) {"
286+ " var root = '" + rv->renderer_preferences_ .nw_app_root_path .AsUTF8Unsafe () + " ';"
285287#if defined(OS_WIN)
286288 " process.mainModule.filename = decodeURIComponent(window.location.pathname.substr(1));"
287289#else
288290 " process.mainModule.filename = decodeURIComponent(window.location.pathname);"
289291#endif
292+ " if (window.location.href.indexOf('app://') === 0) {process.mainModule.filename = root + '/' + process.mainModule.filename}"
290293 " process.mainModule.paths = global.require('module')._nodeModulePaths(process.cwd());"
291294 " process.mainModule.loaded = true;"
292- " }"
295+ " }" ). c_str ()
293296 ));
294297 script->Run ();
295298 }
@@ -318,7 +321,7 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
318321 // Do nothing if user is listening to uncaughtException.
319322 v8::Local<v8::Value> listeners_v =
320323 node::process->Get (v8::String::New (" listeners" ));
321- v8::Local<v8::Function> listeners =
324+ v8::Local<v8::Function> listeners =
322325 v8::Local<v8::Function>::Cast (listeners_v);
323326
324327 v8::Local<v8::Value> argv[1 ] = { v8::String::New (" uncaughtException" ) };
@@ -327,7 +330,7 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
327330
328331 uint32_t length = listener_array->Length ();
329332 if (length > 1 )
330- return v8::Undefined ();
333+ return v8::Undefined ();
331334
332335 // Print stacktrace.
333336 v8::Local<v8::String> stack_symbol = v8::String::New (" stack" );
@@ -341,13 +344,13 @@ v8::Handle<v8::Value> ShellContentRendererClient::ReportException(
341344
342345 RenderView* render_view = GetCurrentRenderView ();
343346 if (!render_view)
344- return v8::Undefined ();
347+ return v8::Undefined ();
345348
346349 render_view->Send (new ShellViewHostMsg_UncaughtException (
347350 render_view->GetRoutingID (),
348351 error));
349352
350- return v8::Undefined ();
353+ return v8::Undefined ();
351354}
352355
353356void ShellContentRendererClient::UninstallNodeSymbols (
0 commit comments