Commit b2cd7834 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Use ClassicScript around DevTools

This CL doesn't change the behavior.

Bug: 1111134
Change-Id: Icf1bba68f665b44864614f724072719bac9b3b96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2331418Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794565}
parent 938ce281
......@@ -30,7 +30,6 @@
#include "third_party/blink/renderer/controller/dev_tools_frontend_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dev_tools_host.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
......@@ -39,6 +38,7 @@
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/inspector/dev_tools_host.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
namespace blink {
......@@ -98,8 +98,8 @@ void DevToolsFrontendImpl::DidClearWindowObject() {
}
if (!api_script_.IsEmpty()) {
GetSupplementable()->GetScriptController().ExecuteScriptInMainWorld(
api_script_);
ClassicScript::CreateUnspecifiedScript(ScriptSourceCode(api_script_))
->RunScript(GetSupplementable());
}
}
......
......@@ -40,8 +40,6 @@
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/public/resources/grit/inspector_overlay_resources_map.h"
#include "third_party/blink/public/web/web_widget_client.h"
#include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_inspector_overlay_host.h"
......@@ -73,6 +71,7 @@
#include "third_party/blink/renderer/core/loader/frame_load_request.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
......@@ -1167,14 +1166,14 @@ void InspectorOverlayAgent::EvaluateInOverlay(const String& method,
command->pushValue(protocol::StringValue::create(argument));
std::vector<uint8_t> json;
ConvertCBORToJSON(SpanFrom(command->Serialize()), &json);
To<LocalFrame>(OverlayMainFrame())
->GetScriptController()
.ExecuteScriptInMainWorld(
ClassicScript::CreateUnspecifiedScript(
ScriptSourceCode(
"dispatch(" +
String(reinterpret_cast<const char*>(json.data()), json.size()) +
")",
ScriptSourceLocationType::kInspector,
ScriptController::kExecuteScriptWhenScriptsDisabled);
ScriptSourceLocationType::kInspector))
->RunScript(To<LocalFrame>(OverlayMainFrame()),
ScriptController::kExecuteScriptWhenScriptsDisabled);
}
void InspectorOverlayAgent::EvaluateInOverlay(
......@@ -1186,25 +1185,24 @@ void InspectorOverlayAgent::EvaluateInOverlay(
command->pushValue(std::move(argument));
std::vector<uint8_t> json;
ConvertCBORToJSON(SpanFrom(command->Serialize()), &json);
To<LocalFrame>(OverlayMainFrame())
->GetScriptController()
.ExecuteScriptInMainWorld(
ClassicScript::CreateUnspecifiedScript(
ScriptSourceCode(
"dispatch(" +
String(reinterpret_cast<const char*>(json.data()), json.size()) +
")",
ScriptSourceLocationType::kInspector,
ScriptController::kExecuteScriptWhenScriptsDisabled);
ScriptSourceLocationType::kInspector))
->RunScript(To<LocalFrame>(OverlayMainFrame()),
ScriptController::kExecuteScriptWhenScriptsDisabled);
}
String InspectorOverlayAgent::EvaluateInOverlayForTest(const String& script) {
ScriptForbiddenScope::AllowUserAgentScript allow_script;
v8::HandleScope handle_scope(ToIsolate(OverlayMainFrame()));
v8::Local<v8::Value> string =
To<LocalFrame>(OverlayMainFrame())
->GetScriptController()
.ExecuteScriptInMainWorldAndReturnValue(
ScriptSourceCode(script, ScriptSourceLocationType::kInspector),
KURL(), SanitizeScriptErrors::kSanitize, ScriptFetchOptions(),
ClassicScript::CreateUnspecifiedScript(
ScriptSourceCode(script, ScriptSourceLocationType::kInspector))
->RunScriptAndReturnValue(
To<LocalFrame>(OverlayMainFrame()),
ScriptController::kExecuteScriptWhenScriptsDisabled);
return ToCoreStringWithUndefinedOrNullCheck(string);
}
......
......@@ -70,6 +70,7 @@
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
......@@ -882,9 +883,9 @@ void InspectorPageAgent::DidClearDocumentOfWindowObject(LocalFrame* frame) {
const String source = scripts_to_evaluate_on_load_.Get(key);
const String world_name = worlds_to_evaluate_on_load_.Get(key);
if (world_name.IsEmpty()) {
frame->GetScriptController().ExecuteScriptInMainWorld(
source, ScriptSourceLocationType::kUnknown,
ScriptController::kExecuteScriptWhenScriptsDisabled);
ClassicScript::CreateUnspecifiedScript(ScriptSourceCode(source))
->RunScript(frame,
ScriptController::kExecuteScriptWhenScriptsDisabled);
continue;
}
......@@ -896,14 +897,14 @@ void InspectorPageAgent::DidClearDocumentOfWindowObject(LocalFrame* frame) {
// Note: An error event in an isolated world will never be dispatched to
// a foreign world.
v8::HandleScope handle_scope(V8PerIsolateData::MainThreadIsolate());
frame->GetScriptController().ExecuteScriptInIsolatedWorld(
world->GetWorldId(), source, KURL(), SanitizeScriptErrors::kSanitize);
ClassicScript::CreateUnspecifiedScript(ScriptSourceCode(source))
->RunScriptInIsolatedWorldAndReturnValue(frame, world->GetWorldId());
}
if (!script_to_evaluate_on_load_once_.IsEmpty()) {
frame->GetScriptController().ExecuteScriptInMainWorld(
script_to_evaluate_on_load_once_, ScriptSourceLocationType::kUnknown,
ScriptController::kExecuteScriptWhenScriptsDisabled);
ClassicScript::CreateUnspecifiedScript(
ScriptSourceCode(script_to_evaluate_on_load_once_))
->RunScript(frame, ScriptController::kExecuteScriptWhenScriptsDisabled);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment