Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/V8ErrorHandler.h" | 31 #include "bindings/core/v8/V8ErrorHandler.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "bindings/core/v8/V8ErrorEvent.h" | 35 #include "bindings/core/v8/V8ErrorEvent.h" |
| 36 #include "bindings/core/v8/V8PrivateProperty.h" | 36 #include "bindings/core/v8/V8PrivateProperty.h" |
| 37 #include "bindings/core/v8/V8ScriptRunner.h" | 37 #include "bindings/core/v8/V8ScriptRunner.h" |
| 38 #include "core/dom/Document.h" | |
| 38 #include "core/dom/ExecutionContext.h" | 39 #include "core/dom/ExecutionContext.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 V8ErrorHandler::V8ErrorHandler(bool isInline, ScriptState* scriptState) | 43 V8ErrorHandler::V8ErrorHandler(bool isInline, ScriptState* scriptState) |
| 43 : V8EventListener(isInline, scriptState) {} | 44 : V8EventListener(isInline, scriptState) {} |
| 44 | 45 |
| 45 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction( | 46 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction( |
| 46 ScriptState* scriptState, | 47 ScriptState* scriptState, |
| 47 v8::Local<v8::Value> jsEvent, | 48 v8::Local<v8::Value> jsEvent, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 78 v8::Integer::New(isolate(), errorEvent->lineno()), | 79 v8::Integer::New(isolate(), errorEvent->lineno()), |
| 79 v8::Integer::New(isolate(), errorEvent->colno()), error}; | 80 v8::Integer::New(isolate(), errorEvent->colno()), error}; |
| 80 v8::TryCatch tryCatch(isolate()); | 81 v8::TryCatch tryCatch(isolate()); |
| 81 tryCatch.SetVerbose(true); | 82 tryCatch.SetVerbose(true); |
| 82 v8::MaybeLocal<v8::Value> result; | 83 v8::MaybeLocal<v8::Value> result; |
| 83 if (scriptState->getExecutionContext()->isWorkerGlobalScope()) { | 84 if (scriptState->getExecutionContext()->isWorkerGlobalScope()) { |
| 84 result = V8ScriptRunner::callFunction( | 85 result = V8ScriptRunner::callFunction( |
| 85 callFunction, scriptState->getExecutionContext(), thisValue, | 86 callFunction, scriptState->getExecutionContext(), thisValue, |
| 86 WTF_ARRAY_LENGTH(parameters), parameters, isolate()); | 87 WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| 87 } else { | 88 } else { |
| 89 LocalFrame* frame = toDocument(scriptState->getExecutionContext())->frame(); | |
| 90 if (frame && world().isMainWorld()) { | |
| 91 CHECK(BindingSecurity::shouldAllowAccessToFrame( | |
| 92 toDOMWindow(callFunction->CreationContext())->toLocalDOMWindow(), | |
|
dcheng
2017/02/20 10:07:42
Hmm... I guess I should fix this to return a Local
| |
| 93 frame, BindingSecurity::ErrorReportOption::DoNotReport)); | |
| 94 } | |
| 95 | |
| 88 result = V8ScriptRunner::callFunction( | 96 result = V8ScriptRunner::callFunction( |
| 89 callFunction, scriptState->getExecutionContext(), thisValue, | 97 callFunction, scriptState->getExecutionContext(), thisValue, |
| 90 WTF_ARRAY_LENGTH(parameters), parameters, isolate()); | 98 WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| 91 } | 99 } |
| 92 v8::Local<v8::Value> returnValue; | 100 v8::Local<v8::Value> returnValue; |
| 93 if (!result.ToLocal(&returnValue)) | 101 if (!result.ToLocal(&returnValue)) |
| 94 return v8::Null(isolate()); | 102 return v8::Null(isolate()); |
| 95 | 103 |
| 96 return returnValue; | 104 return returnValue; |
| 97 } | 105 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 if (error->IsUndefined()) | 139 if (error->IsUndefined()) |
| 132 return v8::Local<v8::Value>(); | 140 return v8::Local<v8::Value>(); |
| 133 return error; | 141 return error; |
| 134 } | 142 } |
| 135 | 143 |
| 136 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) { | 144 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) { |
| 137 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); | 145 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); |
| 138 } | 146 } |
| 139 | 147 |
| 140 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |