Preload doesn't load in sandboxed render if preload path contains special chars (#12037)

* Adding missing headers

* adding ut

* Removing the file path exists check

* fixing test

* exposing window.require in UT
This commit is contained in:
Hari Juturu 2018-03-07 08:40:00 -08:00 committed by Shelley Vohr
parent 69e7afee26
commit 2f4fd3324b
3 changed files with 28 additions and 4 deletions

View file

@ -16,6 +16,7 @@
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "chrome/renderer/printing/print_web_view_helper.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
@ -163,9 +164,9 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
return;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string preload_script = command_line->GetSwitchValueASCII(
base::FilePath preload_script_path = command_line->GetSwitchValuePath(
switches::kPreloadScript);
if (preload_script.empty())
if (preload_script_path.empty())
return;
auto isolate = context->GetIsolate();
@ -191,7 +192,7 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
AddRenderBindings(isolate, binding);
v8::Local<v8::Value> args[] = {
binding,
mate::ConvertToV8(isolate, preload_script)
mate::ConvertToV8(isolate, preload_script_path.value())
};
// Execute the function with proper arguments
ignore_result(func->Call(context, v8::Null(isolate), 2, args));