OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "bindings/core/v8/V8ScriptRunner.h" | 26 #include "bindings/core/v8/V8ScriptRunner.h" |
27 | 27 |
| 28 #include "bindings/core/v8/BindingSecurity.h" |
28 #include "bindings/core/v8/ScriptSourceCode.h" | 29 #include "bindings/core/v8/ScriptSourceCode.h" |
29 #include "bindings/core/v8/ScriptStreamer.h" | 30 #include "bindings/core/v8/ScriptStreamer.h" |
30 #include "bindings/core/v8/V8Binding.h" | 31 #include "bindings/core/v8/V8Binding.h" |
31 #include "bindings/core/v8/V8GCController.h" | 32 #include "bindings/core/v8/V8GCController.h" |
32 #include "bindings/core/v8/V8ThrowException.h" | 33 #include "bindings/core/v8/V8ThrowException.h" |
33 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
34 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/frame/LocalDOMWindow.h" |
35 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/PerformanceMonitor.h" | 38 #include "core/frame/PerformanceMonitor.h" |
37 #include "core/inspector/InspectorTraceEvents.h" | 39 #include "core/inspector/InspectorTraceEvents.h" |
38 #include "core/inspector/ThreadDebugger.h" | 40 #include "core/inspector/ThreadDebugger.h" |
39 #include "core/loader/resource/ScriptResource.h" | 41 #include "core/loader/resource/ScriptResource.h" |
40 #include "platform/Histogram.h" | 42 #include "platform/Histogram.h" |
41 #include "platform/ScriptForbiddenScope.h" | 43 #include "platform/ScriptForbiddenScope.h" |
42 #include "platform/instrumentation/tracing/TraceEvent.h" | 44 #include "platform/instrumentation/tracing/TraceEvent.h" |
43 #include "platform/loader/fetch/CachedMetadata.h" | 45 #include "platform/loader/fetch/CachedMetadata.h" |
44 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 return result; | 625 return result; |
624 } | 626 } |
625 | 627 |
626 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction( | 628 v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction( |
627 v8::Local<v8::Function> function, | 629 v8::Local<v8::Function> function, |
628 ExecutionContext* context, | 630 ExecutionContext* context, |
629 v8::Local<v8::Value> receiver, | 631 v8::Local<v8::Value> receiver, |
630 int argc, | 632 int argc, |
631 v8::Local<v8::Value> args[], | 633 v8::Local<v8::Value> args[], |
632 v8::Isolate* isolate) { | 634 v8::Isolate* isolate) { |
633 ScopedFrameBlamer frameBlamer( | 635 LocalFrame* frame = |
634 context->isDocument() ? toDocument(context)->frame() : nullptr); | 636 context->isDocument() ? toDocument(context)->frame() : nullptr; |
| 637 ScopedFrameBlamer frameBlamer(frame); |
635 TRACE_EVENT0("v8", "v8.callFunction"); | 638 TRACE_EVENT0("v8", "v8.callFunction"); |
636 | 639 |
637 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); | 640 int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); |
638 if (depth >= kMaxRecursionDepth) | 641 if (depth >= kMaxRecursionDepth) |
639 return v8::MaybeLocal<v8::Value>( | 642 return v8::MaybeLocal<v8::Value>( |
640 throwStackOverflowExceptionIfNeeded(isolate)); | 643 throwStackOverflowExceptionIfNeeded(isolate)); |
641 | 644 |
642 RELEASE_ASSERT(!context->isIteratingOverObservers()); | 645 RELEASE_ASSERT(!context->isIteratingOverObservers()); |
643 | 646 |
644 if (ScriptForbiddenScope::isScriptForbidden()) { | 647 if (ScriptForbiddenScope::isScriptForbidden()) { |
645 throwScriptForbiddenException(isolate); | 648 throwScriptForbiddenException(isolate); |
646 return v8::MaybeLocal<v8::Value>(); | 649 return v8::MaybeLocal<v8::Value>(); |
647 } | 650 } |
648 if (!depth) | 651 if (!depth) |
649 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", | 652 TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", |
650 InspectorFunctionCallEvent::data(context, function)); | 653 InspectorFunctionCallEvent::data(context, function)); |
651 | 654 |
| 655 if (frame) { |
| 656 CHECK(BindingSecurity::shouldAllowAccessToFrame( |
| 657 toDOMWindow(function->CreationContext())->toLocalDOMWindow(), frame, |
| 658 BindingSecurity::ErrorReportOption::DoNotReport)); |
| 659 } |
652 CHECK(!ThreadState::current()->isWrapperTracingForbidden()); | 660 CHECK(!ThreadState::current()->isWrapperTracingForbidden()); |
653 v8::MicrotasksScope microtasksScope(isolate, | 661 v8::MicrotasksScope microtasksScope(isolate, |
654 v8::MicrotasksScope::kRunMicrotasks); | 662 v8::MicrotasksScope::kRunMicrotasks); |
655 PerformanceMonitor::willCallFunction(context); | 663 PerformanceMonitor::willCallFunction(context); |
656 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); | 664 ThreadDebugger::willExecuteScript(isolate, function->ScriptId()); |
657 v8::MaybeLocal<v8::Value> result = | 665 v8::MaybeLocal<v8::Value> result = |
658 function->Call(isolate->GetCurrentContext(), receiver, argc, args); | 666 function->Call(isolate->GetCurrentContext(), receiver, argc, args); |
659 crashIfIsolateIsDead(isolate); | 667 crashIfIsolateIsDead(isolate); |
660 ThreadDebugger::didExecuteScript(isolate); | 668 ThreadDebugger::didExecuteScript(isolate); |
661 PerformanceMonitor::didCallFunction(context, function); | 669 PerformanceMonitor::didCallFunction(context, function); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 v8AtomicString(isolate, "((e) => { throw e; })"), origin) | 783 v8AtomicString(isolate, "((e) => { throw e; })"), origin) |
776 .ToLocalChecked(); | 784 .ToLocalChecked(); |
777 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script) | 785 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script) |
778 .ToLocalChecked() | 786 .ToLocalChecked() |
779 .As<v8::Function>(); | 787 .As<v8::Function>(); |
780 v8::Local<v8::Value> args[] = {exception}; | 788 v8::Local<v8::Value> args[] = {exception}; |
781 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate); | 789 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate); |
782 } | 790 } |
783 | 791 |
784 } // namespace blink | 792 } // namespace blink |
OLD | NEW |