Chromium Code Reviews| Index: Source/bindings/core/v8/V8ScriptRunner.cpp |
| diff --git a/Source/bindings/core/v8/V8ScriptRunner.cpp b/Source/bindings/core/v8/V8ScriptRunner.cpp |
| index 4bffe58068596dec34b9fbcd24f276be7341af11..937c3fec8b9c8d04e88406ae456e3cc3eb0c0b3d 100644 |
| --- a/Source/bindings/core/v8/V8ScriptRunner.cpp |
| +++ b/Source/bindings/core/v8/V8ScriptRunner.cpp |
| @@ -355,11 +355,26 @@ PassOwnPtr<CompileFn> selectCompileFunction(ScriptResource* resource, ScriptStre |
| ASSERT(!streamer->streamingSuppressed()); |
| return WTF::bind<v8::Isolate*, v8::Handle<v8::String>, v8::ScriptOrigin>(postStreamCompile, resource->cacheHandler(), streamer); |
| } |
| + |
| +void throwSourceTooLargeException(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + V8ThrowException::throwGeneralError(info.GetIsolate(), "Source file too large."); |
| +} |
| + |
| } // namespace |
| v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& source, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOptions) |
| { |
| - return compileScript(v8String(isolate, source.source()), source.url(), source.sourceMapUrl(), source.startPosition(), isolate, source.resource(), source.streamer(), source.resource() ? source.resource()->cacheHandler() : nullptr, corsStatus, cacheOptions); |
| + v8::Handle<v8::String> sourceAsV8String(v8String(isolate, source.source())); |
| + if (sourceAsV8String.IsEmpty()) { |
| + // String conversion fails when the source size exceeds the V8 string |
| + // length of (currently) 256MB. |
| + V8RecursionScope scope(isolate); |
| + v8::Function::New(isolate, throwSourceTooLargeException)->Call(v8::Undefined(isolate), 0, 0); |
|
haraken
2015/03/09 23:21:56
Can we use a (already existing) helper function in
|
| + return v8::Local<v8::Script>(); |
| + } |
| + |
| + return compileScript(sourceAsV8String, source.url(), source.sourceMapUrl(), source.startPosition(), isolate, source.resource(), source.streamer(), source.resource() ? source.resource()->cacheHandler() : nullptr, corsStatus, cacheOptions); |
| } |
| v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, const String& fileName, const String& sourceMapUrl, const TextPosition& scriptStartPosition, v8::Isolate* isolate, ScriptResource* resource, ScriptStreamer* streamer, CachedMetadataHandler* cacheHandler, AccessControlStatus corsStatus, V8CacheOptions cacheOptions, bool isInternalScript) |