diff options
author | dewittj <dewittj@chromium.org> | 2016-03-15 13:49:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-15 20:52:45 +0000 |
commit | 0bfd25d460a1cff98f9f0573a0d6cc072ecbe359 (patch) | |
tree | 7ab48054430a4554246176f08a4d6c4045c63240 | |
parent | 04c8fd5e7c57f75262f477e6ac94e18ca76b6371 (diff) | |
download | chromium_src-0bfd25d460a1cff98f9f0573a0d6cc072ecbe359.zip chromium_src-0bfd25d460a1cff98f9f0573a0d6cc072ecbe359.tar.gz chromium_src-0bfd25d460a1cff98f9f0573a0d6cc072ecbe359.tar.bz2 |
Revert of Remove V8RecrusionScope, cleanup call sites. (patchset #8 id:140001 of https://codereview.chromium.org/1769273004/ )
Reason for revert:
Speculative revert, this patch most likely to cause browser_tests failures for Linux (https://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29%2832%29/builds/26678) Windows (https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/46875) and Mac
Original issue's description:
> Remove V8RecrusionScope, cleanup call sites.
>
> - blink-side usages migrated to v8::MicrotasksScope;
> - clients of WebScopedMicrotaskSuppression migrated to v8::MicrotasksScope;
> - moved Microtask.{h,cpp} to bindings/core/v8;
> - removed extra wrappers from V8DebuggerClient;
> - fixed a couple of inspector tests which relied on trace event not emitted from debugger anymore.
>
> BUG=585949
>
> Committed: https://crrev.com/133a1579d2a087acdcdd4e9247062edb0bd1e5a3
> Cr-Commit-Position: refs/heads/master@{#381103}
Also reverts https://codereview.chromium.org/1807513002/,
commit 0d194e62ee499d1310e74537aecfa5c6543b8811
Author: dgozman <dgozman@chromium.org>
Also reverts https://codereview.chromium.org/1805543002
commit 974fa818537a8d00fb3537a836db79e2539a7889
Author: dgozman <dgozman@chromium.org>
R=csharp@chromium.org
TBR=jochen@chromium.org,pfeldman@chromium.org,dgozman@chromium.org
BUG=585949,594974
NOTRY=true
Review URL: https://codereview.chromium.org/1806643002
Cr-Commit-Position: refs/heads/master@{#381305}
76 files changed, 536 insertions, 264 deletions
diff --git a/chrome/test/base/v8_unit_test.cc b/chrome/test/base/v8_unit_test.cc index 80ac9fb..392ff45 100644 --- a/chrome/test/base/v8_unit_test.cc +++ b/chrome/test/base/v8_unit_test.cc @@ -11,6 +11,7 @@ #include "base/strings/stringprintf.h" #include "chrome/common/chrome_paths.h" #include "third_party/WebKit/public/web/WebKit.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" namespace { @@ -95,8 +96,7 @@ bool V8UnitTest::RunJavascriptTestF(const std::string& test_fixture, v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::Value> function_property = context->Global()->Get(v8::String::NewFromUtf8(isolate, "runTest")); @@ -211,8 +211,7 @@ void V8UnitTest::ExecuteScriptInContext(const base::StringPiece& script_source, v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, script_source.data(), @@ -261,8 +260,7 @@ void V8UnitTest::TestFunction(const std::string& function_name) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::Value> function_property = context->Global()->Get( v8::String::NewFromUtf8(isolate, function_name.c_str())); diff --git a/components/guest_view/renderer/guest_view_container.cc b/components/guest_view/renderer/guest_view_container.cc index 4d8df38..c410c6f 100644 --- a/components/guest_view/renderer/guest_view_container.cc +++ b/components/guest_view/renderer/guest_view_container.cc @@ -11,6 +11,7 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_view.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" namespace { @@ -153,7 +154,7 @@ void GuestViewContainer::HandlePendingResponseCallback( void GuestViewContainer::RunDestructionCallback(bool embedder_frame_destroyed) { // Do not attempt to run |destruction_callback_| if the embedder frame was // destroyed. Trying to invoke callback on RenderFrame destruction results in - // assertion failure when calling v8::MicrotasksScope. + // assertion failure when calling WebScopedMicrotaskSuppression. if (embedder_frame_destroyed) return; @@ -167,8 +168,7 @@ void GuestViewContainer::RunDestructionCallback(bool embedder_frame_destroyed) { return; v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - destruction_isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression suppression; callback->Call(context->Global(), 0 /* argc */, nullptr); } diff --git a/components/guest_view/renderer/guest_view_request.cc b/components/guest_view/renderer/guest_view_request.cc index fead0c5..d0aa061 100644 --- a/components/guest_view/renderer/guest_view_request.cc +++ b/components/guest_view/renderer/guest_view_request.cc @@ -13,6 +13,7 @@ #include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebRemoteFrame.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebView.h" namespace guest_view { @@ -42,8 +43,7 @@ void GuestViewRequest::ExecuteCallbackIfAvailable( return; v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression suppression; callback->Call(context->Global(), argc, argv.get()); } diff --git a/content/child/v8_value_converter_impl_unittest.cc b/content/child/v8_value_converter_impl_unittest.cc index ccb1db5..435ea30 100644 --- a/content/child/v8_value_converter_impl_unittest.cc +++ b/content/child/v8_value_converter_impl_unittest.cc @@ -14,6 +14,7 @@ #include "base/values.h" #include "content/child/v8_value_converter_impl.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "v8/include/v8.h" namespace content { @@ -287,8 +288,7 @@ TEST_F(V8ValueConverterImplTest, ObjectExceptions) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; // Set up objects to throw when reading or writing 'foo'. const char* source = @@ -331,8 +331,7 @@ TEST_F(V8ValueConverterImplTest, ArrayExceptions) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" "var arr = [];" @@ -409,8 +408,7 @@ TEST_F(V8ValueConverterImplTest, Prototype) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" "Object.prototype.foo = 'foo';" @@ -435,8 +433,7 @@ TEST_F(V8ValueConverterImplTest, StripNullFromObjects) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" "return { foo: undefined, bar: null };" @@ -495,8 +492,7 @@ TEST_F(V8ValueConverterImplTest, WeirdProperties) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" "return {" @@ -535,8 +531,7 @@ TEST_F(V8ValueConverterImplTest, ArrayGetters) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" "var a = [0];" @@ -561,8 +556,7 @@ TEST_F(V8ValueConverterImplTest, UndefinedValueBehavior) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::Object> object; { diff --git a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc index 33c3222..2178fca 100644 --- a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc +++ b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc @@ -12,6 +12,7 @@ #include "content/common/android/gin_java_bridge_value.h" #include "content/renderer/java/gin_java_bridge_value_converter.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "v8/include/v8.h" namespace content { @@ -99,8 +100,7 @@ TEST_F(GinJavaBridgeValueConverterTest, TypedArrays) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks_scope( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; scoped_ptr<GinJavaBridgeValueConverter> converter( new GinJavaBridgeValueConverter()); diff --git a/content/renderer/pepper/v8_var_converter_unittest.cc b/content/renderer/pepper/v8_var_converter_unittest.cc index 283aad6..e030ffd 100644 --- a/content/renderer/pepper/v8_var_converter_unittest.cc +++ b/content/renderer/pepper/v8_var_converter_unittest.cc @@ -29,6 +29,7 @@ #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "v8/include/v8.h" using ppapi::ArrayBufferVar; @@ -403,8 +404,7 @@ TEST_F(V8VarConverterTest, StrangeDictionaryKeyTest) { v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, context_); v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; const char* source = "(function() {" diff --git a/extensions/renderer/activity_log_converter_strategy_unittest.cc b/extensions/renderer/activity_log_converter_strategy_unittest.cc index fbb9597..aa80447 100644 --- a/extensions/renderer/activity_log_converter_strategy_unittest.cc +++ b/extensions/renderer/activity_log_converter_strategy_unittest.cc @@ -6,6 +6,7 @@ #include "base/values.h" #include "extensions/renderer/activity_log_converter_strategy.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "v8/include/v8.h" using content::V8ValueConverter; @@ -122,8 +123,7 @@ TEST_F(ActivityLogConverterStrategyTest, ConversionTest) { "};" "})();"; - v8::MicrotasksScope microtasks( - isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::Script> script( v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source))); v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>(); diff --git a/extensions/renderer/guest_view/extensions_guest_view_container.cc b/extensions/renderer/guest_view/extensions_guest_view_container.cc index ffa3580..3fa9882 100644 --- a/extensions/renderer/guest_view/extensions_guest_view_container.cc +++ b/extensions/renderer/guest_view/extensions_guest_view_container.cc @@ -5,6 +5,7 @@ #include "extensions/renderer/guest_view/extensions_guest_view_container.h" #include "content/public/renderer/render_frame.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "ui/gfx/geometry/size.h" namespace extensions { @@ -55,8 +56,7 @@ void ExtensionsGuestViewContainer::CallElementResizeCallback( v8::Integer::New(element_resize_isolate_, new_size.height())}; v8::Context::Scope context_scope(context); - v8::MicrotasksScope microtasks( - element_resize_isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression suppression; callback->Call(context->Global(), argc, argv); } diff --git a/extensions/renderer/messaging_bindings.cc b/extensions/renderer/messaging_bindings.cc index 0d87c4c..722bc72 100644 --- a/extensions/renderer/messaging_bindings.cc +++ b/extensions/renderer/messaging_bindings.cc @@ -35,6 +35,7 @@ #include "extensions/renderer/v8_helpers.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebScopedUserGesture.h" #include "third_party/WebKit/public/web/WebScopedWindowFocusAllowedIndicator.h" #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" diff --git a/extensions/renderer/module_system.cc b/extensions/renderer/module_system.cc index 692939e..4ca689a 100644 --- a/extensions/renderer/module_system.cc +++ b/extensions/renderer/module_system.cc @@ -22,6 +22,7 @@ #include "extensions/renderer/v8_helpers.h" #include "gin/modules/module_registry.h" #include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" namespace extensions { diff --git a/extensions/renderer/safe_builtins.cc b/extensions/renderer/safe_builtins.cc index fbd88bd..3a66eaf 100644 --- a/extensions/renderer/safe_builtins.cc +++ b/extensions/renderer/safe_builtins.cc @@ -9,6 +9,7 @@ #include "base/strings/stringprintf.h" #include "extensions/renderer/script_context.h" #include "extensions/renderer/v8_helpers.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" namespace extensions { @@ -200,8 +201,7 @@ class ExtensionImpl : public v8::Extension { return; } - v8::MicrotasksScope microtasks( - info.GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; v8::Local<v8::Value> return_value; if (function->Call(context, recv, argc, argv.get()).ToLocal(&return_value)) info.GetReturnValue().Set(return_value); diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc index 4bcec51..f6f47f3 100644 --- a/extensions/renderer/script_context.cc +++ b/extensions/renderer/script_context.cc @@ -29,6 +29,7 @@ #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" @@ -184,8 +185,7 @@ v8::Local<v8::Value> ScriptContext::CallFunction( v8::EscapableHandleScope handle_scope(isolate()); v8::Context::Scope scope(v8_context()); - v8::MicrotasksScope microtasks( - isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression suppression; if (!is_valid_) { return handle_scope.Escape( v8::Local<v8::Primitive>(v8::Undefined(isolate()))); @@ -434,8 +434,7 @@ v8::Local<v8::Value> ScriptContext::RunScript( return v8::Undefined(isolate()); } - v8::MicrotasksScope microtasks( - isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression suppression; v8::TryCatch try_catch(isolate()); try_catch.SetCaptureMessage(true); v8::ScriptOrigin origin( diff --git a/extensions/renderer/utils_native_handler.cc b/extensions/renderer/utils_native_handler.cc index 1ded40c..d93f2e6 100644 --- a/extensions/renderer/utils_native_handler.cc +++ b/extensions/renderer/utils_native_handler.cc @@ -7,6 +7,7 @@ #include "base/macros.h" #include "base/strings/stringprintf.h" #include "extensions/renderer/script_context.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" namespace extensions { diff --git a/extensions/renderer/v8_helpers.h b/extensions/renderer/v8_helpers.h index 0a3b2eb..b0dd17a 100644 --- a/extensions/renderer/v8_helpers.h +++ b/extensions/renderer/v8_helpers.h @@ -9,6 +9,7 @@ #include <string.h> #include "base/strings/string_number_conversions.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "v8/include/v8.h" namespace extensions { @@ -155,8 +156,7 @@ inline bool CallFunction(v8::Local<v8::Context> context, int argc, v8::Local<v8::Value> argv[], v8::Local<v8::Value>* out) { - v8::MicrotasksScope microtasks_scope( - context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + blink::WebScopedMicrotaskSuppression microtasks_scope; return function->Call(context, recv, argc, argv).ToLocal(out); } diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js index cc148cc..6b13a87 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js @@ -1,10 +1,3 @@ -function wrapCallFunctionForTimeline(f) -{ - var script = document.createElement("script"); - script.textContent = "(" + f.toString() + ")()\n//# sourceURL=wrapCallFunctionForTimeline.js"; - document.body.appendChild(script); -} - var initialize_Timeline = function() { InspectorTest.preloadPanel("timeline"); diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html index 6c11d72..4f0e1d4 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html +++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html @@ -93,6 +93,7 @@ function test() ++knownEvents[event.name]; } assertGreaterOrEqual(events.length, 10, "Too few trace events recorded"); + assertGreaterOrEqual(knownEvents["FunctionCall"], 1, "Too few FunctionCall events"); assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few UpdateLayoutTree events"); assertGreaterOrEqual(knownEvents["Layout"], 1, "Too few Layout events"); InspectorTest.log("Event sanity test done"); diff --git a/third_party/WebKit/LayoutTests/inspector/tracing.html b/third_party/WebKit/LayoutTests/inspector/tracing.html index c0fb911..c7ee50d 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing.html +++ b/third_party/WebKit/LayoutTests/inspector/tracing.html @@ -91,6 +91,7 @@ function test() ++knownEvents[event.name]; } InspectorTest.assertGreaterOrEqual(events.length, 100, "Too few trace events recorded"); + InspectorTest.assertGreaterOrEqual(knownEvents["v8.callFunction"], 1, "Too few v8.callFunction"); InspectorTest.assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few UpdateLayoutTree"); InspectorTest.assertGreaterOrEqual(knownEvents["FrameView::layout"], 1, "Too few FrameView::layout"); InspectorTest.assertGreaterOrEqual(phaseComplete, 50, "Too few begin events"); diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-bound-function-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-bound-function-expected.txt index 4151574..c8f5b5d 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-bound-function-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-bound-function-expected.txt @@ -1,5 +1,6 @@ Tests extracting information about original functions from bound ones +FunctionCall :1 FunctionCall timeline-bound-function.html:7 diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval-expected.txt index 4fa0644..63be6e9 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval-expected.txt @@ -1 +1,17 @@ -Tests the Timeline API function call is not recorded for InjectedScript.eval. +Tests the Timeline API function call record for InjectedScript.eval call feature. + +FunctionCall Properties: +{ + data : { + frame : <string> + scriptId : <string> + scriptLine : <number> + scriptName : <string> + } + endTime : <number> + frameId : <string> + startTime : <number> + type : "FunctionCall" +} +Text details for FunctionCall: undefined + diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval.html index 9fd6787..6fa62fa 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval.html +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-injected-script-eval.html @@ -19,7 +19,7 @@ function test() <body onload="runTest()"> <p> -Tests the Timeline API function call is not recorded for InjectedScript.eval. +Tests the Timeline API function call record for InjectedScript.eval call feature. </p> </body> diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout.html index 7c2ed83..bf7ebbf 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout.html +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout.html @@ -19,8 +19,8 @@ function invalidateAndForceLayout(element) function performActions() { - wrapCallFunctionForTimeline(() => invalidateAndForceLayout(document.getElementById("invalidate1"))); - wrapCallFunctionForTimeline(() => invalidateAndForceLayout(document.getElementById("invalidate2"))); + invalidateAndForceLayout(document.getElementById("invalidate1")); + invalidateAndForceLayout(document.getElementById("invalidate2")); } function test() diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles-expected.txt index e3dd2b4..dafad285 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles-expected.txt @@ -8,7 +8,7 @@ UpdateLayoutTree Properties: frame : <string> stackTrace : <object> } - elementCount : 3 + elementCount : 2 } endTime : <number> frameId : <string> @@ -16,6 +16,6 @@ UpdateLayoutTree Properties: startTime : <number> type : "UpdateLayoutTree" } -Text details for UpdateLayoutTree: wrapCallFunctionForTimeline.js:8 +Text details for UpdateLayoutTree: timeline-recalculate-styles.html:20 UpdateLayoutTree has a warning diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles.html index 1458e25..df024b8 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles.html +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-recalculate-styles.html @@ -11,7 +11,7 @@ <script> -function forceStyle() +function performActions() { var element = document.createElement("div"); element.className = "test-style"; @@ -20,11 +20,6 @@ function forceStyle() var unused = element.offsetWidth; } -function performActions() -{ - wrapCallFunctionForTimeline(forceStyle); -} - function test() { InspectorTest.performActionsAndPrint("performActions()", "UpdateLayoutTree"); diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-receive-response-event-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-receive-response-event-expected.txt index 088ca5b..c0dac66 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-receive-response-event-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-receive-response-event-expected.txt @@ -1,6 +1,6 @@ Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc. -ResourceSendRequest + ResourceSendRequest ResourceReceiveResponse ResourceReceivedData ResourceFinish diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-script-id-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-script-id-expected.txt index 54bf6b2..cb22f7f 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-script-id-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-script-id-expected.txt @@ -2,6 +2,7 @@ Test that checks location resolving mechanics for TimerInstall TimerRemove and F It expects two FunctionCall for InjectedScript, two TimerInstall events, two FunctionCall events and one TimerRemove event to be logged with performActions.js script name and some line number. +detailsTextContent for FunctionCall event: 'undefined' detailsTextContent for TimerInstall event: 'performActions.js:3' details.textContent for TimerInstall event: 'performActions.js:3' detailsTextContent for TimerInstall event: 'performActions.js:4' diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time-expected.txt index 6c78afe..0009030 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time-expected.txt @@ -2,13 +2,17 @@ Test nesting of time/timeEnd records on Timeline Running: testSimpleConsoleTime +----> Function Call Running: testNestedConsoleTime +----> Function Call Running: testUnbalancedConsoleTime +----> Function Call Running: testConsoleTimeWithoutConsoleTimeEnd -----> Timestamp: Foo -----> Timestamp: Bar -----> Timestamp: Baz +----> Function Call +--------> Timestamp: Foo +--------> Timestamp: Bar +--------> Timestamp: Baz diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-timer-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-timer-expected.txt index 58d172d..36b374a 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-timer-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-timer-expected.txt @@ -108,6 +108,19 @@ FunctionCall Properties: startTime : <number> type : "FunctionCall" } +FunctionCall Properties: +{ + data : { + frame : <string> + scriptId : <string> + scriptLine : <number> + scriptName : <string> + } + endTime : <number> + frameId : <string> + startTime : <number> + type : "FunctionCall" +} EvaluateScript Properties: { data : { diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp index 1391abf..ba889fe 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp @@ -12,6 +12,7 @@ #include "bindings/core/v8/V8BindingForTesting.h" #include "bindings/core/v8/V8BindingMacros.h" #include "bindings/core/v8/V8IteratorResultValue.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "bindings/core/v8/V8ThrowException.h" #include "core/dom/Document.h" #include "core/streams/ReadableStreamController.h" @@ -149,7 +150,7 @@ public: { v8::Local<v8::String> source; v8::Local<v8::Script> script; - v8::MicrotasksScope microtasks(isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression microtasks(isolate()); if (!v8Call(v8::String::NewFromUtf8(isolate(), s, v8::NewStringType::kNormal), source)) { ADD_FAILURE(); return ScriptValue(); diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ObjectConstructor.h b/third_party/WebKit/Source/bindings/core/v8/V8ObjectConstructor.h index 93e73c0..10b0a1f 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8ObjectConstructor.h +++ b/third_party/WebKit/Source/bindings/core/v8/V8ObjectConstructor.h @@ -32,6 +32,7 @@ #define V8ObjectConstructor_h #include "bindings/core/v8/V8PerIsolateData.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "wtf/Allocator.h" #include <v8.h> @@ -50,7 +51,7 @@ public: ConstructorMode(v8::Isolate* isolate) : m_isolate(isolate) - , m_microtaskSuppression(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks) + , m_microtaskSuppression(isolate) { V8PerIsolateData* data = V8PerIsolateData::from(m_isolate); m_previous = data->m_constructorMode; @@ -71,7 +72,7 @@ public: private: v8::Isolate* m_isolate; bool m_previous; - v8::MicrotasksScope m_microtaskSuppression; + V8RecursionScope::MicrotaskSuppression m_microtaskSuppression; }; class V8ObjectConstructor { diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h index c286e6c..2cda3f4 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h +++ b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h @@ -98,7 +98,7 @@ public: v8::Local<v8::Context> ensureScriptRegexpContext(); void clearScriptRegexpContext(); - // EndOfScopeTasks are run when control is returning + // EndOfScopeTasks are run by V8RecursionScope when control is returning // to C++ from script, after executing a script task (e.g. callback, // event) or microtasks (e.g. promise). This is explicitly needed for // Indexed DB transactions per spec, but should in general be avoided. diff --git a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp new file mode 100644 index 0000000..b4c3acf --- /dev/null +++ b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bindings/core/v8/V8RecursionScope.h" + +namespace blink { + +} // namespace blink diff --git a/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h new file mode 100644 index 0000000..8bbd26c --- /dev/null +++ b/third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8RecursionScope_h +#define V8RecursionScope_h + +#include "bindings/core/v8/V8PerIsolateData.h" +#include "core/CoreExport.h" +#include "wtf/Noncopyable.h" +#include <v8.h> + +namespace blink { + +// C++ calls into script contexts which are "owned" by WebKit (created in a +// process where WebKit.cpp initializes v8) must declare their type: +// +// 1. Calls into page/author script from a frame +// 2. Calls into page/author script from a worker +// 3. Calls into internal script (typically setup/teardown work) +// +// Debug-time checking of this is enforced via this class. +// +// Calls of type (1) should generally go through ScriptController, as inspector +// instrumentation is needed. ScriptController allocates V8RecursionScope for you. +// Calls of type (2) should always stack-allocate a V8RecursionScope in the same +// block as the call into script. Calls of type (3) should stack allocate a +// V8RecursionScope::MicrotaskSuppression -- this skips work that is spec'd to +// happen at the end of the outer-most script stack frame of calls into page script: +// +// http://www.whatwg.org/specs/web-apps/current-work/#perform-a-microtask-checkpoint +class CORE_EXPORT V8RecursionScope { + STACK_ALLOCATED(); +public: + explicit V8RecursionScope(v8::Isolate* isolate) + : m_scope(isolate, v8::MicrotasksScope::kRunMicrotasks) + { + ASSERT(isolate->GetMicrotasksPolicy() == v8::MicrotasksPolicy::kScoped); + } + + ~V8RecursionScope() + { + } + + static int recursionLevel(v8::Isolate* isolate) + { + return v8::MicrotasksScope::GetCurrentDepth(isolate); + } + + class MicrotaskSuppression { + USING_FAST_MALLOC(MicrotaskSuppression); + WTF_MAKE_NONCOPYABLE(MicrotaskSuppression); + public: + explicit MicrotaskSuppression(v8::Isolate* isolate) + : m_scope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks) + { + } + + ~MicrotaskSuppression() + { + } + + private: + v8::MicrotasksScope m_scope; + }; + +private: + v8::MicrotasksScope m_scope; +}; + +} // namespace blink + +#endif // V8RecursionScope_h diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp index de8a036..51bc05d 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp @@ -29,6 +29,7 @@ #include "bindings/core/v8/ScriptStreamer.h" #include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8GCController.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "bindings/core/v8/V8ThrowException.h" #include "core/dom/ExecutionContext.h" #include "core/fetch/CachedMetadata.h" @@ -399,7 +400,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledScript(v8::Isolate* isolate TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); TRACE_EVENT1("v8", "v8.run", "fileName", TRACE_STR_COPY(*v8::String::Utf8Value(script->GetUnboundScript()->GetScriptName()))); - if (v8::MicrotasksScope::GetCurrentDepth(isolate) >= kMaxRecursionDepth) + if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return throwStackOverflowExceptionIfNeeded(isolate); RELEASE_ASSERT(!context->isIteratingOverObservers()); @@ -411,7 +412,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledScript(v8::Isolate* isolate throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Value>(); } - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMicrotasks); + V8RecursionScope recursionScope(isolate); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willExecuteScript(context, script->GetUnboundScript()->GetId()); result = script->Run(isolate->GetCurrentContext()); InspectorInstrumentation::didExecuteScript(cookie); @@ -429,7 +430,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Local< TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext()); crashIfIsolateIsDead(isolate); return result; @@ -439,7 +440,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::runCompiledInternalScript(v8::Isolate* { TRACE_EVENT0("v8", "v8.run"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::MaybeLocal<v8::Value> result = script->Run(isolate->GetCurrentContext()); crashIfIsolateIsDead(isolate); return result; @@ -450,7 +451,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(v8::Local<v8::Function> f TRACE_EVENT1("devtools.timeline,v8", "FunctionCall", "data", devToolsTraceEventData(isolate, context, function)); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - if (v8::MicrotasksScope::GetCurrentDepth(isolate) >= kMaxRecursionDepth) + if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth) return v8::MaybeLocal<v8::Value>(throwStackOverflowExceptionIfNeeded(isolate)); RELEASE_ASSERT(!context->isIteratingOverObservers()); @@ -459,7 +460,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::callFunction(v8::Local<v8::Function> f throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Value>(); } - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMicrotasks); + V8RecursionScope recursionScope(isolate); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willExecuteScript(context, function->ScriptId()); v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext(), receiver, argc, args); crashIfIsolateIsDead(isolate); @@ -471,7 +472,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::callInternalFunction(v8::Local<v8::Fun { TRACE_EVENT0("v8", "v8.callFunction"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression recursionScope(isolate); v8::MaybeLocal<v8::Value> result = function->Call(isolate->GetCurrentContext(), receiver, argc, args); crashIfIsolateIsDead(isolate); return result; @@ -482,7 +483,7 @@ v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolat TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression scope(isolate); v8::MaybeLocal<v8::Object> result = objectTemplate->NewInstance(isolate->GetCurrentContext()); crashIfIsolateIsDead(isolate); return result; @@ -493,7 +494,7 @@ v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolat TRACE_EVENT0("v8", "v8.newInstance"); TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution"); - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression scope(isolate); v8::MaybeLocal<v8::Object> result = function->NewInstance(isolate->GetCurrentContext(), argc, argv); crashIfIsolateIsDead(isolate); return result; @@ -507,7 +508,7 @@ v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Isola throwScriptForbiddenException(isolate); return v8::MaybeLocal<v8::Object>(); } - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kRunMicrotasks); + V8RecursionScope scope(isolate); v8::MaybeLocal<v8::Object> result = function->NewInstance(isolate->GetCurrentContext(), argc, argv); crashIfIsolateIsDead(isolate); return result; diff --git a/third_party/WebKit/Source/bindings/core/v8/v8.gypi b/third_party/WebKit/Source/bindings/core/v8/v8.gypi index 2cfebfa..b11d584 100644 --- a/third_party/WebKit/Source/bindings/core/v8/v8.gypi +++ b/third_party/WebKit/Source/bindings/core/v8/v8.gypi @@ -42,8 +42,6 @@ 'JSONValuesForV8.cpp', 'JSONValuesForV8.h', 'Maplike.h', - 'Microtask.cpp', - 'Microtask.h', 'NativeValueTraits.h', 'NPV8Object.cpp', 'NPV8Object.h', @@ -161,6 +159,8 @@ 'V8PerIsolateData.cpp', 'V8PerIsolateData.h', 'V8PersistentValueVector.h', + 'V8RecursionScope.cpp', + 'V8RecursionScope.h', 'V8ScriptRunner.cpp', 'V8ScriptRunner.h', 'V8StringResource.cpp', diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi index e9c96ab..758e5f1 100644 --- a/third_party/WebKit/Source/core/core.gypi +++ b/third_party/WebKit/Source/core/core.gypi @@ -2476,6 +2476,8 @@ 'dom/MessageChannel.cpp', 'dom/MessageChannel.h', 'dom/MessagePort.cpp', + 'dom/Microtask.cpp', + 'dom/Microtask.h', 'dom/MutationCallback.h', 'dom/MutationObserver.cpp', 'dom/MutationObserver.h', diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 12c4f9f..4049c86 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp @@ -32,7 +32,6 @@ #include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/ScriptCallStack.h" #include "bindings/core/v8/ScriptController.h" #include "bindings/core/v8/UnionTypesCore.h" @@ -80,6 +79,7 @@ #include "core/dom/IntersectionObserverController.h" #include "core/dom/LayoutTreeBuilderTraversal.h" #include "core/dom/MainThreadTaskRunner.h" +#include "core/dom/Microtask.h" #include "core/dom/MutationObserver.h" #include "core/dom/NodeChildRemovalTracker.h" #include "core/dom/NodeComputedStyle.h" diff --git a/third_party/WebKit/Source/bindings/core/v8/Microtask.cpp b/third_party/WebKit/Source/core/dom/Microtask.cpp index ade8bba..344c9e0 100644 --- a/third_party/WebKit/Source/bindings/core/v8/Microtask.cpp +++ b/third_party/WebKit/Source/core/dom/Microtask.cpp @@ -28,10 +28,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "bindings/core/v8/Microtask.h" +#include "core/dom/Microtask.h" +#include "bindings/core/v8/V8PerIsolateData.h" #include "platform/ScriptForbiddenScope.h" #include "platform/Task.h" +#include "public/platform/WebTaskRunner.h" +#include <v8.h> namespace blink { diff --git a/third_party/WebKit/Source/bindings/core/v8/Microtask.h b/third_party/WebKit/Source/core/dom/Microtask.h index 89ecd0f..82ac7d1 100644 --- a/third_party/WebKit/Source/bindings/core/v8/Microtask.h +++ b/third_party/WebKit/Source/core/dom/Microtask.h @@ -31,6 +31,7 @@ #ifndef Microtask_h #define Microtask_h +#include "bindings/core/v8/ScriptState.h" #include "core/CoreExport.h" #include "public/platform/WebTaskRunner.h" #include "wtf/Allocator.h" @@ -40,25 +41,6 @@ namespace blink { -// C++ calls into script contexts which are "owned" by blink (created in a -// process where WebKit.cpp initializes v8) must declare their type: -// -// 1. Calls into page/author script from a frame -// 2. Calls into page/author script from a worker -// 3. Calls into internal script (typically setup/teardown work) -// -// Debug-time checking of this is enforced via v8::MicrotasksScope. -// -// Calls of type (1) should generally go through ScriptController, as inspector -// instrumentation is needed. ScriptController allocates V8RecursionScope for you. -// -// Calls of type (2) should always stack-allocate a v8::MicrotasksScope(kRunMicrtoasks) -// in the same block as the call into script. -// -// Calls of type (3) should stack allocate a v8::MicrotasksScope(kDoNotRunMicrotasks) -- -// this skips work that is spec'd to happen at the end of the outer-most -// script stack frame of calls into page script: -// http://www.whatwg.org/specs/web-apps/current-work/#perform-a-microtask-checkpoint class CORE_EXPORT Microtask { STATIC_ONLY(Microtask); public: diff --git a/third_party/WebKit/Source/core/dom/MutationObserver.cpp b/third_party/WebKit/Source/core/dom/MutationObserver.cpp index af9b35a..17cfe91 100644 --- a/third_party/WebKit/Source/core/dom/MutationObserver.cpp +++ b/third_party/WebKit/Source/core/dom/MutationObserver.cpp @@ -31,8 +31,8 @@ #include "core/dom/MutationObserver.h" #include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/Microtask.h" #include "core/dom/ExceptionCode.h" +#include "core/dom/Microtask.h" #include "core/dom/MutationCallback.h" #include "core/dom/MutationObserverInit.h" #include "core/dom/MutationObserverRegistration.h" diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp index 04bfecc..1e36ff9 100644 --- a/third_party/WebKit/Source/core/dom/Node.cpp +++ b/third_party/WebKit/Source/core/dom/Node.cpp @@ -26,7 +26,6 @@ #include "bindings/core/v8/DOMDataStore.h" #include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/V8DOMWrapper.h" #include "core/HTMLNames.h" #include "core/css/CSSSelector.h" @@ -45,6 +44,7 @@ #include "core/dom/ElementTraversal.h" #include "core/dom/ExceptionCode.h" #include "core/dom/LayoutTreeBuilderTraversal.h" +#include "core/dom/Microtask.h" #include "core/dom/NodeRareData.h" #include "core/dom/NodeTraversal.h" #include "core/dom/ProcessingInstruction.h" diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp index 8bacf42..2cdd768 100644 --- a/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp +++ b/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp @@ -4,7 +4,7 @@ #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" -#include "bindings/core/v8/Microtask.h" +#include "core/dom/Microtask.h" #include "core/dom/custom/CustomElementCallbackQueue.h" #include "core/dom/custom/CustomElementMicrotaskImportStep.h" #include "core/dom/custom/CustomElementProcessingStack.h" diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskRunQueue.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskRunQueue.cpp index b1e6643..660598a 100644 --- a/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskRunQueue.cpp +++ b/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskRunQueue.cpp @@ -4,7 +4,7 @@ #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" -#include "bindings/core/v8/Microtask.h" +#include "core/dom/Microtask.h" #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" #include "core/html/imports/HTMLImportLoader.h" diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp index 2779b52..ef82805 100644 --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp @@ -30,8 +30,8 @@ #include "core/html/HTMLSlotElement.h" -#include "bindings/core/v8/Microtask.h" #include "core/HTMLNames.h" +#include "core/dom/Microtask.h" #include "core/dom/NodeTraversal.h" #include "core/dom/StyleChangeReason.h" #include "core/dom/shadow/ElementShadow.h" diff --git a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp index 486d243..e7ac745 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp @@ -25,12 +25,12 @@ #include "core/html/parser/HTMLScriptRunner.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/ScriptSourceCode.h" #include "bindings/core/v8/V8PerIsolateData.h" #include "core/dom/Element.h" #include "core/events/Event.h" #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" +#include "core/dom/Microtask.h" #include "core/dom/ScriptLoader.h" #include "core/fetch/ScriptResource.h" #include "core/frame/LocalFrame.h" diff --git a/third_party/WebKit/Source/core/inspector/DevToolsHost.cpp b/third_party/WebKit/Source/core/inspector/DevToolsHost.cpp index fa123be..fc66082 100644 --- a/third_party/WebKit/Source/core/inspector/DevToolsHost.cpp +++ b/third_party/WebKit/Source/core/inspector/DevToolsHost.cpp @@ -30,6 +30,7 @@ #include "core/inspector/DevToolsHost.h" #include "bindings/core/v8/ScriptState.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "bindings/core/v8/V8ScriptRunner.h" #include "core/clipboard/Pasteboard.h" #include "core/dom/ExecutionContext.h" @@ -146,7 +147,7 @@ void DevToolsHost::evaluateScript(const String& expression) return; ScriptState::Scope scope(scriptState); UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); - v8::MicrotasksScope microtasks(scriptState->isolate(), v8::MicrotasksScope::kRunMicrotasks); + V8RecursionScope recursionScope(scriptState->isolate()); v8::Local<v8::String> source = v8AtomicString(scriptState->isolate(), expression.utf8().data()); V8ScriptRunner::compileAndRunInternalScript(source, scriptState->isolate(), String(), TextPosition()); } diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp index b885df2..cf188fa 100644 --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp @@ -11,8 +11,10 @@ #include "bindings/core/v8/V8HTMLCollection.h" #include "bindings/core/v8/V8Node.h" #include "bindings/core/v8/V8NodeList.h" +#include "bindings/core/v8/V8RecursionScope.h" +#include "bindings/core/v8/V8ScriptRunner.h" +#include "core/dom/Microtask.h" #include "core/inspector/InspectorDOMDebuggerAgent.h" -#include "platform/ScriptForbiddenScope.h" #include "wtf/CurrentTime.h" namespace blink { @@ -32,6 +34,31 @@ void ThreadDebugger::eventListeners(v8::Local<v8::Value> value, V8EventListenerI InspectorDOMDebuggerAgent::eventListenersInfoForTarget(m_isolate, value, result); } +v8::MaybeLocal<v8::Object> ThreadDebugger::instantiateObject(v8::Local<v8::Function> function) +{ + return V8ScriptRunner::instantiateObject(m_isolate, function); +} + +v8::MaybeLocal<v8::Value> ThreadDebugger::runCompiledScript(v8::Local<v8::Context> context, v8::Local<v8::Script> script) +{ + return V8ScriptRunner::runCompiledScript(m_isolate, script, toExecutionContext(context)); +} + +v8::MaybeLocal<v8::Value> ThreadDebugger::compileAndRunInternalScript(v8::Local<v8::String> script) +{ + return V8ScriptRunner::compileAndRunInternalScript(script, m_isolate); +} + +v8::MaybeLocal<v8::Value> ThreadDebugger::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) +{ + return V8ScriptRunner::callFunction(function, toExecutionContext(context), receiver, argc, info, m_isolate); +} + +v8::MaybeLocal<v8::Value> ThreadDebugger::callInternalFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) +{ + return V8ScriptRunner::callInternalFunction(function, receiver, argc, info, m_isolate); +} + String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) { if (V8Node::hasInstance(value, m_isolate)) @@ -54,12 +81,7 @@ bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value) bool ThreadDebugger::hasRecursionLevel() { - return !!v8::MicrotasksScope::GetCurrentDepth(m_isolate); -} - -bool ThreadDebugger::isExecutionAllowed() -{ - return !ScriptForbiddenScope::isScriptForbidden(); + return !!V8RecursionScope::recursionLevel(m_isolate); } double ThreadDebugger::currentTimeMS() diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.h b/third_party/WebKit/Source/core/inspector/ThreadDebugger.h index 5ae90bf..19eec3e 100644 --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.h +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.h @@ -26,10 +26,14 @@ public: void muteWarningsAndDeprecations() override { }; void unmuteWarningsAndDeprecations() override { }; void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) override; + v8::MaybeLocal<v8::Object> instantiateObject(v8::Local<v8::Function>) override; + v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Local<v8::Script>) override; + v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::String>) override; + v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) override; + v8::MaybeLocal<v8::Value> callInternalFunction(v8::Local<v8::Function>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) override; String16 valueSubtype(v8::Local<v8::Value>) override; bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; bool hasRecursionLevel() override; - bool isExecutionAllowed() override; double currentTimeMS() override; V8Debugger* debugger() const { return m_debugger.get(); } diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp index 4cb1edf..98e3431 100644 --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp @@ -21,7 +21,6 @@ #include "core/loader/ImageLoader.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/ScriptController.h" #include "bindings/core/v8/ScriptState.h" #include "bindings/core/v8/V8Binding.h" @@ -29,6 +28,7 @@ #include "core/dom/Document.h" #include "core/dom/Element.h" #include "core/dom/IncrementLoadEventDelayCount.h" +#include "core/dom/Microtask.h" #include "core/events/Event.h" #include "core/events/EventSender.h" #include "core/fetch/FetchRequest.h" diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp index c3eb7a7..9a6f109 100644 --- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp +++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp @@ -26,11 +26,11 @@ #include "core/workers/WorkerThread.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/ScriptSourceCode.h" #include "bindings/core/v8/V8GCController.h" #include "bindings/core/v8/V8IdleTaskRunner.h" #include "bindings/core/v8/V8Initializer.h" +#include "core/dom/Microtask.h" #include "core/inspector/InspectorInstrumentation.h" #include "core/inspector/InspectorTaskRunner.h" #include "core/workers/DedicatedWorkerGlobalScope.h" diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js index f198907..a69268d 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js @@ -469,13 +469,7 @@ WebInspector.TimelineUIUtils.buildDetailsTextForTraceEvent = function(event, tar function linkifyTopCallFrameAsText() { var frame = WebInspector.TimelineUIUtils.topStackFrame(event); - var text = frame ? linkifyLocationAsText(frame.scriptId, frame.lineNumber, frame.columnNumber) : null; - if (frame && !text) { - text = frame.url; - if (typeof frame.lineNumber === "number") - text += ":" + (frame.lineNumber + 1); - } - return text; + return frame ? linkifyLocationAsText(frame.scriptId, frame.lineNumber, frame.columnNumber) : null; } } diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp index 49b0d62..f15d54a 100644 --- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp +++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp @@ -12,6 +12,7 @@ #include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/V8BindingMacros.h" #include "bindings/core/v8/V8IteratorResultValue.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "bindings/core/v8/V8Uint8Array.h" #include "core/dom/DOMTypedArray.h" #include "public/platform/Platform.h" diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp index 5955359..00c3fa6 100644 --- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp @@ -8,6 +8,7 @@ #include "bindings/core/v8/ScriptState.h" #include "bindings/core/v8/V8BindingMacros.h" #include "bindings/core/v8/V8GCController.h" +#include "bindings/core/v8/V8RecursionScope.h" #include "core/dom/Document.h" #include "core/testing/DummyPageHolder.h" #include "modules/fetch/DataConsumerHandleTestUtil.h" @@ -59,7 +60,7 @@ public: { v8::Local<v8::String> source; v8::Local<v8::Script> script; - v8::MicrotasksScope microtasks(isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + V8RecursionScope::MicrotaskSuppression microtasks(isolate()); if (!v8Call(v8::String::NewFromUtf8(isolate(), s, v8::NewStringType::kNormal), source)) { ADD_FAILURE(); return v8::MaybeLocal<v8::Value>(); diff --git a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp index 88cf923..3300afa 100644 --- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp +++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp @@ -33,7 +33,6 @@ #include "bindings/core/v8/ArrayValue.h" #include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/ScriptPromiseResolver.h" #include "bindings/core/v8/ScriptState.h" @@ -44,6 +43,7 @@ #include "core/dom/Document.h" #include "core/dom/ExceptionCode.h" #include "core/dom/ExecutionContext.h" +#include "core/dom/Microtask.h" #include "core/frame/Deprecation.h" #include "core/frame/LocalFrame.h" #include "core/html/VoidCallback.h" diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp index 38a962a..aa5e01f8 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp @@ -36,7 +36,6 @@ #include "platform/v8_inspector/InjectedScriptHost.h" #include "platform/v8_inspector/InjectedScriptManager.h" #include "platform/v8_inspector/RemoteObjectId.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8FunctionCall.h" #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8Debugger.h" @@ -116,11 +115,12 @@ static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) data.GetParameter()->dispose(); } -InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Context> context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> injectedScriptNative, int contextId) +InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Context> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPtr<InjectedScriptNative> injectedScriptNative, int contextId) : m_manager(manager) , m_isolate(context->GetIsolate()) , m_context(m_isolate, context) , m_value(m_isolate, object) + , m_client(client) , m_native(injectedScriptNative) , m_contextId(contextId) { @@ -134,7 +134,7 @@ InjectedScript::~InjectedScript() void InjectedScript::evaluate(ErrorString* errorString, const String16& expression, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evaluate"); + V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); function.appendArgument(expression); function.appendArgument(objectGroup); function.appendArgument(includeCommandLineAPI); @@ -146,7 +146,7 @@ void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& objectId, const String16& expression, const String16& arguments, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "callFunctionOn"); + V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); function.appendArgument(objectId); function.appendArgument(expression); function.appendArgument(arguments); @@ -158,7 +158,7 @@ void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String16& callFrameId, const String16& expression, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evaluateOnCallFrame"); + V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame"); function.appendArgument(callFrames); function.appendArgument(callFrameId); function.appendArgument(expression); @@ -172,7 +172,7 @@ void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String16& callFrameId) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "restartFrame"); + V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); function.appendArgument(callFrames); function.appendArgument(callFrameId); OwnPtr<protocol::Value> resultValue = makeCall(function); @@ -197,7 +197,7 @@ void InjectedScript::setVariableValue(ErrorString* errorString, const String16& newValueStr) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setVariableValue"); + V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); if (callFrameIdOpt.isJust()) { function.appendArgument(callFrames); function.appendArgument(callFrameIdOpt.fromJust()); @@ -227,7 +227,7 @@ void InjectedScript::setVariableValue(ErrorString* errorString, void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16& functionId, OwnPtr<FunctionDetails>* result) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFunctionDetails"); + V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"); function.appendArgument(functionId); OwnPtr<protocol::Value> resultValue = makeCall(function); protocol::ErrorSupport errors(errorString); @@ -237,7 +237,7 @@ void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String16& objectId, OwnPtr<Array<CollectionEntry>>* result) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCollectionEntries"); + V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntries"); function.appendArgument(objectId); OwnPtr<protocol::Value> resultValue = makeCall(function); protocol::ErrorSupport errors(errorString); @@ -247,7 +247,7 @@ void InjectedScript::getCollectionEntries(ErrorString* errorString, const String void InjectedScript::getProperties(ErrorString* errorString, const String16& objectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getProperties"); + V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); function.appendArgument(objectId); function.appendArgument(ownProperties); function.appendArgument(accessorPropertiesOnly); @@ -266,7 +266,7 @@ void InjectedScript::getProperties(ErrorString* errorString, const String16& obj void InjectedScript::getInternalProperties(ErrorString* errorString, const String16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInternalProperties"); + V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperties"); function.appendArgument(objectId); OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exceptionDetails); @@ -297,14 +297,14 @@ v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPISymbol(m_isolate); v8::Local<v8::Object> global = context()->Global(); if (includeCommandLineAPI) { - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "commandLineAPI"); + V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI"); bool hadException = false; v8::Local<v8::Value> commandLineAPI = function.call(hadException, false); if (!hadException) global->Set(commandLineAPISymbolValue, commandLineAPI); } - v8::MaybeLocal<v8::Value> maybeValue = m_manager->debugger()->runCompiledScript(context(), script); + v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context(), script); if (includeCommandLineAPI) global->Delete(context(), commandLineAPISymbolValue); @@ -314,7 +314,7 @@ v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object> callFrames) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCallFrames"); + V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames"); function.appendArgument(callFrames); bool hadException = false; v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); @@ -329,7 +329,7 @@ PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local<v8::Value> value, const String16& groupName, bool generatePreview) const { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapObject"); + V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); v8::Local<v8::Value> wrappedObject; ErrorString errorString; if (!wrapValue(&errorString, value, groupName, generatePreview).ToLocal(&wrappedObject)) @@ -358,7 +358,7 @@ bool InjectedScript::wrapObjectProperty(ErrorString* error, v8::Local<v8::Object v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview) const { - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapObject"); + V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); function.appendArgument(value); function.appendArgument(groupName); function.appendArgument(canAccessInspectedWindow()); @@ -375,7 +375,7 @@ v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTable"); + V8FunctionCall function(m_client, context(), v8Value(), "wrapTable"); function.appendArgument(canAccessInspectedWindow()); function.appendArgument(table); if (columns.IsEmpty()) @@ -405,7 +405,7 @@ void InjectedScript::releaseObjectGroup(const String16& objectGroup) v8::HandleScope handles(m_isolate); m_native->releaseObjectGroup(objectGroup); if (objectGroup == "console") { - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "clearLastEvaluationResult"); + V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvaluationResult"); bool hadException = false; callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); @@ -415,7 +415,7 @@ void InjectedScript::releaseObjectGroup(const String16& objectGroup) void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) { v8::HandleScope handles(m_isolate); - V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCustomObjectFormatterEnabled"); + V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectFormatterEnabled"); function.appendArgument(enabled); makeCall(function); } @@ -425,7 +425,7 @@ bool InjectedScript::canAccessInspectedWindow() const v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); if (callingContext.IsEmpty()) return true; - return m_manager->debugger()->client()->callingContextCanAccessContext(callingContext, context()); + return m_client->callingContextCanAccessContext(callingContext, context()); } v8::Local<v8::Context> InjectedScript::context() const diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h index d2d2c2a..e94c78e 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h @@ -41,6 +41,7 @@ namespace blink { class InjectedScriptManager; class RemoteObjectId; class V8FunctionCall; +class V8DebuggerClient; namespace protocol { class DictionaryValue; @@ -113,7 +114,7 @@ public: private: friend InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context>); - InjectedScript(InjectedScriptManager*, v8::Local<v8::Context>, v8::Local<v8::Object>, PassOwnPtr<InjectedScriptNative>, int contextId); + InjectedScript(InjectedScriptManager*, v8::Local<v8::Context>, v8::Local<v8::Object>, V8DebuggerClient*, PassOwnPtr<InjectedScriptNative>, int contextId); bool canAccessInspectedWindow() const; v8::Local<v8::Value> v8Value() const; @@ -127,6 +128,7 @@ private: v8::Isolate* m_isolate; v8::Global<v8::Context> m_context; v8::Global<v8::Value> m_value; + V8DebuggerClient* m_client; OwnPtr<InjectedScriptNative> m_native; int m_contextId; String16 m_origin; diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp index e36ead0..e77b71d 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp @@ -51,7 +51,7 @@ PassOwnPtr<InjectedScriptManager> InjectedScriptManager::create(V8DebuggerImpl* InjectedScriptManager::InjectedScriptManager(V8DebuggerImpl* debugger) : m_injectedScriptHost(InjectedScriptHost::create(debugger)) , m_customObjectFormatterEnabled(false) - , m_debugger(debugger) + , m_client(debugger->client()) { } @@ -131,14 +131,14 @@ InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context> return it->second; v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingContext(); - if (!callingContext.IsEmpty() && !m_debugger->client()->callingContextCanAccessContext(callingContext, context)) + if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(callingContext, context)) return nullptr; OwnPtr<InjectedScriptNative> injectedScriptNative = adoptPtr(new InjectedScriptNative(context->GetIsolate())); String16 injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js)); v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, context, contextId, injectedScriptNative.get()); - OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, object, injectedScriptNative.release(), contextId)); + OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, object, m_client, injectedScriptNative.release(), contextId)); InjectedScript* resultPtr = result.get(); if (m_customObjectFormatterEnabled) result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); @@ -158,7 +158,7 @@ v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String16 m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate); } - v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(wrapperTemplate, context, m_injectedScriptHost.get()); + v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(m_client, wrapperTemplate, context, m_injectedScriptHost.get()); if (scriptHostWrapper.IsEmpty()) return v8::Local<v8::Object>(); @@ -170,15 +170,14 @@ v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String16 // injected script id and explicit reference to the inspected global object. The function is expected // to create and configure InjectedScript instance that is going to be used by the inspector. v8::Local<v8::Value> value; - if (!m_debugger->compileAndRunInternalScript(context, toV8String(isolate, source)).ToLocal(&value)) + if (!m_client->compileAndRunInternalScript(toV8String(isolate, source)).ToLocal(&value)) return v8::Local<v8::Object>(); ASSERT(value->IsFunction()); - v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); + v8::Local<v8::Object> windowGlobal = context->Global(); v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number::New(context->GetIsolate(), id) }; - v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local<v8::Value> injectedScriptValue; - if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) + if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) return v8::Local<v8::Object>(); if (!injectedScriptValue->IsObject()) return v8::Local<v8::Object>(); diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.h b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.h index 0d19ef2..3e5f90d 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.h +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.h @@ -52,7 +52,6 @@ public: ~InjectedScriptManager(); InjectedScriptHost* injectedScriptHost(); - V8DebuggerImpl* debugger() { return m_debugger; } InjectedScript* injectedScriptFor(v8::Local<v8::Context>); InjectedScript* findInjectedScript(int) const; @@ -72,7 +71,7 @@ private: IdToInjectedScriptMap m_idToInjectedScript; OwnPtr<InjectedScriptHost> m_injectedScriptHost; bool m_customObjectFormatterEnabled; - V8DebuggerImpl* m_debugger; + V8DebuggerClient* m_client; }; } // namespace blink diff --git a/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.cpp b/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.cpp index 7d60b12..e8277ba 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.cpp @@ -32,15 +32,14 @@ v8::Local<v8::FunctionTemplate> InspectorWrapperBase::createWrapperTemplate(v8:: return functionTemplate; } -v8::Local<v8::Object> InspectorWrapperBase::createWrapper(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context) +v8::Local<v8::Object> InspectorWrapperBase::createWrapper(V8DebuggerClient* client, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context) { - v8::MicrotasksScope microtasks(context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local<v8::Function> function; if (!constructorTemplate->GetFunction(context).ToLocal(&function)) return v8::Local<v8::Object>(); v8::Local<v8::Object> result; - if (!function->NewInstance(context).ToLocal(&result)) + if (!client->instantiateObject(function).ToLocal(&result)) return v8::Local<v8::Object>(); return result; } diff --git a/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.h b/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.h index ab393f9..f13c507 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.h +++ b/third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.h @@ -11,6 +11,8 @@ namespace blink { +class V8DebuggerClient; + class InspectorWrapperBase { public: struct V8MethodConfiguration { @@ -26,7 +28,7 @@ public: static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, const char* className, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::Vector<V8AttributeConfiguration>& attributes); protected: - static v8::Local<v8::Object> createWrapper(v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>); + static v8::Local<v8::Object> createWrapper(V8DebuggerClient*, v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>); static void* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>, const char* name); static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name); @@ -69,10 +71,10 @@ public: return InspectorWrapperBase::createWrapperTemplate(isolate, className, methods, attributes); } - static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, T* object) + static v8::Local<v8::Object> wrap(V8DebuggerClient* client, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, T* object) { v8::Context::Scope contextScope(context); - v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(constructorTemplate, context); + v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(client, constructorTemplate, context); if (result.IsEmpty()) return v8::Local<v8::Object>(); v8::Isolate* isolate = context->GetIsolate(); @@ -83,10 +85,10 @@ public: return result; } - static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr<T> object) + static v8::Local<v8::Object> wrap(V8DebuggerClient* client, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr<T> object) { v8::Context::Scope contextScope(context); - v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(constructorTemplate, context); + v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(client, constructorTemplate, context); if (result.IsEmpty()) return v8::Local<v8::Object>(); v8::Isolate* isolate = context->GetIsolate(); diff --git a/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.cpp b/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.cpp index 299b11c..6222e7d 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.cpp @@ -31,13 +31,15 @@ #include "platform/v8_inspector/JavaScriptCallFrame.h" #include "platform/v8_inspector/V8StringUtil.h" +#include "platform/v8_inspector/public/V8DebuggerClient.h" #include <v8-debug.h> namespace blink { -JavaScriptCallFrame::JavaScriptCallFrame(v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame) - : m_isolate(debuggerContext->GetIsolate()) +JavaScriptCallFrame::JavaScriptCallFrame(V8DebuggerClient* client, v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame) + : m_client(client) + , m_isolate(debuggerContext->GetIsolate()) , m_debuggerContext(m_isolate, debuggerContext) , m_callFrame(m_isolate, callFrame) { @@ -51,20 +53,21 @@ PassOwnPtr<JavaScriptCallFrame> JavaScriptCallFrame::caller() { v8::HandleScope handleScope(m_isolate); v8::Local<v8::Context> debuggerContext = v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); + v8::Context::Scope contextScope(debuggerContext); v8::Local<v8::Value> callerFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInternalized(m_isolate, "caller")); if (callerFrame.IsEmpty() || !callerFrame->IsObject()) return 0; - return JavaScriptCallFrame::create(debuggerContext, v8::Local<v8::Object>::Cast(callerFrame)); + return JavaScriptCallFrame::create(m_client, debuggerContext, v8::Local<v8::Object>::Cast(callerFrame)); } int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const { v8::HandleScope handleScope(m_isolate); - v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); + v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext)); v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, name))); v8::Local<v8::Value> result; - if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) || !result->IsInt32()) + if (!m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocal(&result) || !result->IsInt32()) return 0; return result.As<v8::Int32>()->Value(); } @@ -72,11 +75,11 @@ int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const String16 JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const { v8::HandleScope handleScope(m_isolate); - v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); + v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext)); v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, name))); v8::Local<v8::Value> result; - if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result)) + if (!m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocal(&result)) return String16(); return toProtocolStringWithTypeCheck(result); } @@ -120,7 +123,7 @@ v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const { v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "scopeChain"))); - v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocalChecked()); v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopeChain->Length()); for (uint32_t i = 0; i < scopeChain->Length(); i++) result->Set(i, scopeChain->Get(i)); @@ -131,7 +134,7 @@ int JavaScriptCallFrame::scopeType(int scopeIndex) const { v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "scopeType"))); - v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocalChecked()); return scopeType->Get(scopeIndex)->Int32Value(); } @@ -139,7 +142,7 @@ v8::Local<v8::String> JavaScriptCallFrame::scopeName(int scopeIndex) const { v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "scopeName"))); - v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocalChecked()); return scopeType->Get(scopeIndex)->ToString(); } @@ -157,7 +160,7 @@ v8::Local<v8::Value> JavaScriptCallFrame::callScopeLocationFunction(const char* { v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, name))); - v8::Local<v8::Array> locations = v8::Local<v8::Array>::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + v8::Local<v8::Array> locations = v8::Local<v8::Array>::Cast(m_client->callInternalFunction(func, callFrame, 0, nullptr).ToLocalChecked()); return locations->Get(scopeIndex); } @@ -174,6 +177,7 @@ String16 JavaScriptCallFrame::stepInPositions() const bool JavaScriptCallFrame::isAtReturn() const { v8::HandleScope handleScope(m_isolate); + v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext)); v8::Local<v8::Value> result = v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInternalized(m_isolate, "isAtReturn")); if (result.IsEmpty() || !result->IsBoolean()) return false; @@ -196,7 +200,7 @@ v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local v8::TryCatch tryCatch(m_isolate); v8::Local<v8::Object> wrappedResult = v8::Object::New(m_isolate); v8::Local<v8::Value> result; - if (evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&result)) { + if (m_client->callInternalFunction(evalFunction, callFrame, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&result)) { wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result); wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"), v8::Undefined(m_isolate)); } else { @@ -211,7 +215,7 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "restart"))); v8::Debug::SetLiveEditEnabled(m_isolate, true); - v8::MaybeLocal<v8::Value> result = restartFunction->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr); + v8::MaybeLocal<v8::Value> result = m_client->callInternalFunction(restartFunction, callFrame, 0, nullptr); v8::Debug::SetLiveEditEnabled(m_isolate, false); return result; } @@ -225,7 +229,7 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(int scopeNumber, variableName, newValue }; - return setVariableValueFunction->Call(m_isolate->GetCurrentContext(), callFrame, WTF_ARRAY_LENGTH(argv), argv); + return m_client->callInternalFunction(setVariableValueFunction, callFrame, WTF_ARRAY_LENGTH(argv), argv); } v8::Local<v8::Object> JavaScriptCallFrame::createExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) diff --git a/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.h b/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.h index bd17be7..b30ca47 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.h +++ b/third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.h @@ -38,11 +38,13 @@ namespace blink { +class V8DebuggerClient; + class JavaScriptCallFrame { public: - static PassOwnPtr<JavaScriptCallFrame> create(v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame) + static PassOwnPtr<JavaScriptCallFrame> create(V8DebuggerClient* client, v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame) { - return adoptPtr(new JavaScriptCallFrame(debuggerContext, callFrame)); + return adoptPtr(new JavaScriptCallFrame(client, debuggerContext, callFrame)); } ~JavaScriptCallFrame(); @@ -76,13 +78,16 @@ public: void setWrapperTemplate(v8::Local<v8::FunctionTemplate> wrapperTemplate, v8::Isolate* isolate) { m_wrapperTemplate.Reset(isolate, wrapperTemplate); } v8::Local<v8::FunctionTemplate> wrapperTemplate(v8::Isolate* isolate) { return v8::Local<v8::FunctionTemplate>::New(isolate, m_wrapperTemplate); } + V8DebuggerClient* client() { return m_client; } + private: - JavaScriptCallFrame(v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame); + JavaScriptCallFrame(V8DebuggerClient*, v8::Local<v8::Context> debuggerContext, v8::Local<v8::Object> callFrame); int callV8FunctionReturnInt(const char* name) const; String16 callV8FunctionReturnString(const char* name) const; v8::Local<v8::Value> callScopeLocationFunction(const char* name, int scopeIndex) const; + V8DebuggerClient* m_client; v8::Isolate* m_isolate; OwnPtr<JavaScriptCallFrame> m_caller; v8::Global<v8::Context> m_debuggerContext; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp index decabcf..ea1ab6d 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp @@ -60,11 +60,10 @@ static bool inLiveEditScope = false; v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functionName, int argc, v8::Local<v8::Value> argv[]) { - v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8InternalizedString(functionName))); ASSERT(m_isolate->InContext()); - return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv); + return m_client->callInternalFunction(function, debuggerScript, argc, argv); } PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient* client) @@ -211,13 +210,14 @@ V8RuntimeAgentImpl* V8DebuggerImpl::getRuntimeAgentForContext(v8::Local<v8::Cont void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8DebuggerParsedScript>& result) { v8::HandleScope scope(m_isolate); + v8::Context::Scope contextScope(debuggerContext()); + v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); ASSERT(!debuggerScript->IsUndefined()); v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8InternalizedString("getScripts"))); v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) }; v8::Local<v8::Value> value; - v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); - if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&value)) + if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&value)) return; ASSERT(value->IsArray()); v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); @@ -492,7 +492,7 @@ PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::wrapCallFrames() ASSERT(!currentCallFrameV8.IsEmpty()); if (!currentCallFrameV8->IsObject()) return nullptr; - return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>::Cast(currentCallFrameV8)); + return JavaScriptCallFrame::create(m_client, debuggerContext(), v8::Local<v8::Object>::Cast(currentCallFrameV8)); } v8::Local<v8::Object> V8DebuggerImpl::currentCallFrames() @@ -512,7 +512,7 @@ v8::Local<v8::Object> V8DebuggerImpl::currentCallFrames() v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemplate>::New(m_isolate, m_callFrameWrapperTemplate); v8::Local<v8::Context> context = m_pausedContext.IsEmpty() ? m_isolate->GetCurrentContext() : m_pausedContext; v8::Context::Scope scope(context); - v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(wrapperTemplate, context, currentCallFrame.release()); + v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(m_client, wrapperTemplate, context, currentCallFrame.release()); return wrapper; } @@ -533,7 +533,7 @@ PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrameNoScopes(int index) ASSERT(!currentCallFrameV8.IsEmpty()); if (!currentCallFrameV8->IsObject()) return nullptr; - return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>::Cast(currentCallFrameV8)); + return JavaScriptCallFrame::create(m_client, debuggerContext(), v8::Local<v8::Object>::Cast(currentCallFrameV8)); } static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) @@ -611,8 +611,7 @@ v8::Local<v8::Value> V8DebuggerImpl::callInternalGetterFunction(v8::Local<v8::Ob { v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(functionName)); ASSERT(!getterValue.IsEmpty() && getterValue->IsFunction()); - v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); - return v8::Local<v8::Function>::Cast(getterValue)->Call(m_isolate->GetCurrentContext(), object, 0, 0).ToLocalChecked(); + return m_client->callInternalFunction(v8::Local<v8::Function>::Cast(getterValue), object, 0, 0).ToLocalChecked(); } void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails) @@ -722,7 +721,7 @@ void V8DebuggerImpl::compileDebuggerScript() v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, DebuggerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLocalChecked(); v8::Local<v8::Value> value; - if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&value)) + if (!m_client->compileAndRunInternalScript(scriptValue).ToLocal(&value)) return; ASSERT(value->IsObject()); m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); @@ -791,54 +790,7 @@ bool V8DebuggerImpl::isPaused() return !m_pausedContext.IsEmpty(); } -v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Context> context, v8::Local<v8::Script> script) -{ - // TODO(dgozman): get rid of this check. - if (!m_client->isExecutionAllowed()) - return v8::MaybeLocal<v8::Value>(); - - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); - int groupId = getGroupId(context); - V8DebuggerAgentImpl* agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; - if (agent) - agent->willExecuteScript(script->GetUnboundScript()->GetId()); - v8::MaybeLocal<v8::Value> result = script->Run(context); - // Get agent from the map again, since it could have detached during script execution. - agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; - if (agent) - agent->didExecuteScript(); - return result; -} - -v8::MaybeLocal<v8::Value> V8DebuggerImpl::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) -{ - // TODO(dgozman): get rid of this check. - if (!m_client->isExecutionAllowed()) - return v8::MaybeLocal<v8::Value>(); - - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); - int groupId = getGroupId(context); - V8DebuggerAgentImpl* agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; - if (agent) - agent->willExecuteScript(function->ScriptId()); - v8::MaybeLocal<v8::Value> result = function->Call(context, receiver, argc, info); - // Get agent from the map again, since it could have detached during script execution. - agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; - if (agent) - agent->didExecuteScript(); - return result; -} - -v8::MaybeLocal<v8::Value> V8DebuggerImpl::compileAndRunInternalScript(v8::Local<v8::Context> context, v8::Local<v8::String> source) -{ - v8::Local<v8::Script> script = compileInternalScript(context, source, String()); - if (script.IsEmpty()) - return v8::MaybeLocal<v8::Value>(); - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); - return script->Run(context); -} - -v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Context> context, v8::Local<v8::String> code, const String16& fileName) +v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Context>, v8::Local<v8::String> code, const String16& fileName) { // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at // 1, whereas v8 starts at 0. @@ -853,7 +805,7 @@ v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex v8::True(m_isolate)); // opaqueresource v8::ScriptCompiler::Source source(code, origin); v8::Local<v8::Script> script; - if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) + if (!v8::ScriptCompiler::Compile(m_isolate->GetCurrentContext(), &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) return v8::Local<v8::Script>(); return script; } diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h index 28aafa5..185dd37 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h @@ -98,9 +98,6 @@ public: v8::Isolate* isolate() const { return m_isolate; } V8DebuggerClient* client() { return m_client; } - v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Local<v8::Script>); - v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]); - v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context>, v8::Local<v8::String>); v8::Local<v8::Script> compileInternalScript(v8::Local<v8::Context>, v8::Local<v8::String>, const String16& fileName); v8::Local<v8::Context> regexContext(); diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.cpp index 5d7c210..d6fff84 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.cpp @@ -30,7 +30,6 @@ #include "platform/v8_inspector/V8FunctionCall.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" #include "wtf/PassOwnPtr.h" @@ -39,8 +38,8 @@ namespace blink { -V8FunctionCall::V8FunctionCall(V8DebuggerImpl* debugger, v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& name) - : m_debugger(debugger) +V8FunctionCall::V8FunctionCall(V8DebuggerClient* client, v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& name) + : m_client(client) , m_context(context) , m_name(toV8String(context->GetIsolate(), name)) , m_value(value) @@ -105,7 +104,7 @@ v8::Local<v8::Value> V8FunctionCall::callWithoutExceptionHandling() } v8::Local<v8::Value> result; - if (!m_debugger->callFunction(function, m_context, thisObject, m_arguments.size(), info.get()).ToLocal(&result)) + if (!m_client->callFunction(function, m_context, thisObject, m_arguments.size(), info.get()).ToLocal(&result)) return v8::Local<v8::Value>(); return result; } diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.h b/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.h index a9230cc..a063620 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8FunctionCall.h @@ -38,11 +38,11 @@ namespace blink { -class V8DebuggerImpl; +class V8DebuggerClient; class V8FunctionCall { public: - V8FunctionCall(V8DebuggerImpl*, v8::Local<v8::Context>, v8::Local<v8::Value>, const String16& name); + V8FunctionCall(V8DebuggerClient*, v8::Local<v8::Context>, v8::Local<v8::Value>, const String16& name); void appendArgument(v8::Local<v8::Value>); void appendArgument(const String16&); @@ -57,7 +57,7 @@ public: v8::Local<v8::Context> context() { return m_context; } protected: - V8DebuggerImpl* m_debugger; + V8DebuggerClient* m_client; v8::Local<v8::Context> m_context; protocol::Vector<v8::Local<v8::Value>> m_arguments; v8::Local<v8::String> m_name; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp index 5fcaee0..11a19cc 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp @@ -280,7 +280,7 @@ void V8InjectedScriptHost::evalCallback(const v8::FunctionCallbackInfo<v8::Value InjectedScriptHost* host = V8InjectedScriptHost::unwrap(isolate->GetCurrentContext(), info.Holder()); if (!host->debugger()) return; - if (!host->debugger()->compileAndRunInternalScript(isolate->GetCurrentContext(), expression).ToLocal(&result)) { + if (!host->debugger()->client()->compileAndRunInternalScript(expression).ToLocal(&result)) { v8SetReturnValue(info, tryCatch.ReThrow()); return; } @@ -333,7 +333,7 @@ void V8InjectedScriptHost::evaluateWithExceptionDetailsCallback(const v8::Functi global->Set(commandLineAPISymbolValue, commandLineAPI); } - v8::MaybeLocal<v8::Value> result = host->debugger()->runCompiledScript(context, script); + v8::MaybeLocal<v8::Value> result = host->debugger()->client()->runCompiledScript(context, script); if (result.IsEmpty()) { global->Delete(context, commandLineAPISymbolValue); setExceptionAsReturnValue(info, wrappedResult, tryCatch); @@ -596,9 +596,9 @@ v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8:: return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, attributes); } -v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host) +v8::Local<v8::Object> V8InjectedScriptHost::wrap(V8DebuggerClient* client, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host) { - return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); + return InjectedScriptHostWrapper::wrap(client, constructorTemplate, context, host); } InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object) diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.h b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.h index 1566d1b..f16adf4 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.h @@ -14,7 +14,7 @@ class V8DebuggerClient; class V8InjectedScriptHost { public: - static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context>, InjectedScriptHost*); + static v8::Local<v8::Object> wrap(V8DebuggerClient*, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context>, InjectedScriptHost*); static InjectedScriptHost* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>); static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*); diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.cpp index 9595551a..b680100 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.cpp @@ -24,7 +24,7 @@ void callerAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallba v8::Local<v8::FunctionTemplate> wrapperTemplate = impl->wrapperTemplate(isolate); if (wrapperTemplate.IsEmpty()) return; - info.GetReturnValue().Set(V8JavaScriptCallFrame::wrap(wrapperTemplate, isolate->GetCurrentContext(), caller.release())); + info.GetReturnValue().Set(V8JavaScriptCallFrame::wrap(impl->client(), wrapperTemplate, isolate->GetCurrentContext(), caller.release())); } void sourceIDAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) @@ -203,11 +203,11 @@ v8::Local<v8::FunctionTemplate> V8JavaScriptCallFrame::createWrapperTemplate(v8: return JavaScriptCallFrameWrapper::createWrapperTemplate(isolate, methods, attributes); } -v8::Local<v8::Object> V8JavaScriptCallFrame::wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr<JavaScriptCallFrame> frame) +v8::Local<v8::Object> V8JavaScriptCallFrame::wrap(V8DebuggerClient* client, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr<JavaScriptCallFrame> frame) { // Store template for .caller callback frame->setWrapperTemplate(constructorTemplate, context->GetIsolate()); - return JavaScriptCallFrameWrapper::wrap(constructorTemplate, context, frame); + return JavaScriptCallFrameWrapper::wrap(client, constructorTemplate, context, frame); } JavaScriptCallFrame* V8JavaScriptCallFrame::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object) diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.h b/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.h index a4672b6..83edad6 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8JavaScriptCallFrame.h @@ -17,7 +17,7 @@ class V8DebuggerClient; class V8JavaScriptCallFrame { public: static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*); - static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context>, PassOwnPtr<JavaScriptCallFrame>); + static v8::Local<v8::Object> wrap(V8DebuggerClient*, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context>, PassOwnPtr<JavaScriptCallFrame>); static JavaScriptCallFrame* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>); }; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8Regex.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8Regex.cpp index 84cd04c..32053d4 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8Regex.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8Regex.cpp @@ -45,6 +45,7 @@ int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons v8::Isolate* isolate = m_debugger->isolate(); v8::HandleScope handleScope(isolate); v8::Local<v8::Context> context = m_debugger->regexContext(); + v8::Context::Scope contextScope(context); v8::TryCatch tryCatch(isolate); v8::Local<v8::RegExp> regex = m_regex.Get(isolate); @@ -53,7 +54,7 @@ int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons return -1; v8::Local<v8::Value> argv[] = { toV8String(isolate, string.substring(startFrom)) }; v8::Local<v8::Value> returnValue; - if (!exec.As<v8::Function>()->Call(context, regex, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&returnValue)) + if (!m_debugger->client()->callInternalFunction(exec.As<v8::Function>(), regex, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&returnValue)) return -1; // RegExp#exec returns null if there's no match, otherwise it returns an diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerClient.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerClient.h index 5e48345..21691ca 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerClient.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerClient.h @@ -23,10 +23,16 @@ public: virtual void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) = 0; virtual void contextsToReport(int contextGroupId, V8ContextInfoVector&) = 0; virtual bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) = 0; + + virtual v8::MaybeLocal<v8::Object> instantiateObject(v8::Local<v8::Function>) = 0; + virtual v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Local<v8::Script>) = 0; + virtual v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::String>) = 0; + virtual v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) = 0; + virtual v8::MaybeLocal<v8::Value> callInternalFunction(v8::Local<v8::Function>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) = 0; + virtual String16 valueSubtype(v8::Local<v8::Value>) = 0; virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) = 0; virtual bool hasRecursionLevel() = 0; - virtual bool isExecutionAllowed() = 0; virtual double currentTimeMS() = 0; }; diff --git a/third_party/WebKit/Source/web/WebKit.cpp b/third_party/WebKit/Source/web/WebKit.cpp index c0b0857..29cca01 100644 --- a/third_party/WebKit/Source/web/WebKit.cpp +++ b/third_party/WebKit/Source/web/WebKit.cpp @@ -30,12 +30,12 @@ #include "public/web/WebKit.h" -#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8GCController.h" #include "bindings/core/v8/V8Initializer.h" #include "core/Init.h" #include "core/animation/AnimationClock.h" +#include "core/dom/Microtask.h" #include "core/page/Page.h" #include "gin/public/v8_platform.h" #include "modules/InitModules.h" diff --git a/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp b/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp new file mode 100644 index 0000000..a719a9c --- /dev/null +++ b/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "public/web/WebScopedMicrotaskSuppression.h" + +#include "bindings/core/v8/V8RecursionScope.h" +#include "wtf/Assertions.h" +#include "wtf/OwnPtr.h" + +namespace blink { + +#if ENABLE(ASSERT) +class WebScopedMicrotaskSuppression::Impl : public V8RecursionScope::MicrotaskSuppression { +public: + Impl(v8::Isolate* isolate) + : V8RecursionScope::MicrotaskSuppression(isolate) + { + } +}; +#endif + +void WebScopedMicrotaskSuppression::initialize() +{ +#if ENABLE(ASSERT) + m_impl.reset(new Impl(v8::Isolate::GetCurrent())); +#endif +} + +void WebScopedMicrotaskSuppression::reset() +{ +#if ENABLE(ASSERT) + m_impl.reset(0); +#endif +} + +} // namespace blink diff --git a/third_party/WebKit/Source/web/web.gypi b/third_party/WebKit/Source/web/web.gypi index 1fbdecb..e31cbe8 100644 --- a/third_party/WebKit/Source/web/web.gypi +++ b/third_party/WebKit/Source/web/web.gypi @@ -198,6 +198,7 @@ 'WebRemoteFrameImpl.cpp', 'WebRemoteFrameImpl.h', 'WebRuntimeFeatures.cpp', + 'WebScopedMicrotaskSuppression.cpp', 'WebScopedUserGesture.cpp', 'WebScopedWindowFocusAllowedIndicator.cpp', 'WebScriptController.cpp', diff --git a/third_party/WebKit/public/blink_headers.gypi b/third_party/WebKit/public/blink_headers.gypi index 254ba13..0033df8 100644 --- a/third_party/WebKit/public/blink_headers.gypi +++ b/third_party/WebKit/public/blink_headers.gypi @@ -442,6 +442,7 @@ "web/WebRemoteFrameClient.h", "web/WebRuntimeFeatures.h", "web/WebSandboxFlags.h", + "web/WebScopedMicrotaskSuppression.h", "web/WebScopedUserGesture.h", "web/WebScopedWindowFocusAllowedIndicator.h", "web/WebScriptController.h", diff --git a/third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h b/third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h new file mode 100644 index 0000000..dd96fc6 --- /dev/null +++ b/third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebScopedMicrotaskSuppression_h +#define WebScopedMicrotaskSuppression_h + +#include "../platform/WebPrivateOwnPtr.h" + +namespace blink { + +// This class wraps V8RecursionScope::BypassMicrotaskCheckpoint. Please +// see V8RecursionScope.h for full usage. Short story: Embedder calls into +// script contexts which also host page script must do one of two things: +// +// 1. If the call may cause any page/author script to run, it must be +// captured for pre/post work (e.g. inspector instrumentation/microtask +// delivery) and thus be invoked through WebFrame (e.g. executeScript*, +// callFunction*). +// 2. If the call will not cause any page/author script to run, the call +// should be made directly via the v8 context, but the callsite must be +// accompanied by a stack allocated WebScopedMicrotaskSuppression, e.g.: +// +// ... +// { +// blink::WebScopedMicrotaskSuppression suppression; +// func->Call(global, argv, args); +// } +// ... +// +class WebScopedMicrotaskSuppression { +public: + WebScopedMicrotaskSuppression() { initialize(); } + ~WebScopedMicrotaskSuppression() { reset(); } + +private: + BLINK_EXPORT void initialize(); + BLINK_EXPORT void reset(); + + // Always declare this data member. When assertions are on in + // Release builds of Blink, this header may be included from + // Chromium with different preprocessor options than used when + // building Blink itself. + class Impl; + WebPrivateOwnPtr<Impl> m_impl; +}; + +} // namespace blink + +#endif |