Commit b426c2d3 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[debug] Mark global debug-evaluate scripts as shared-cross-origin.

This way Blink will not sanitize error events coming from JavaScript
entered via the DevTools console, and instead forward the original error
event as-is, which is more likely to match the developers' expectations.

Bug: chromium:1295750
Change-Id: Id02c048e4af21d0c232d8e44d11115f6b61c0bf1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3540145
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79549}
parent 39c3a97e
......@@ -31,7 +31,7 @@ static MaybeHandle<SharedFunctionInfo> GetFunctionInfo(Isolate* isolate,
Handle<String> source,
REPLMode repl_mode) {
ScriptDetails script_details(isolate->factory()->empty_string(),
ScriptOriginOptions(false, true));
ScriptOriginOptions(true, true));
script_details.repl_mode = repl_mode;
return Compiler::GetSharedFunctionInfoForScript(
isolate, source, script_details, ScriptCompiler::kNoCompileOptions,
......
......@@ -7,6 +7,7 @@
#include <vector>
#include "src/base/macros.h"
#include "src/common/globals.h"
#include "src/debug/debug-frames.h"
#include "src/debug/debug-scopes.h"
......@@ -23,9 +24,9 @@ class FrameInspector;
class DebugEvaluate : public AllStatic {
public:
static MaybeHandle<Object> Global(Isolate* isolate, Handle<String> source,
debug::EvaluateGlobalMode mode,
REPLMode repl_mode = REPLMode::kNo);
static V8_EXPORT_PRIVATE MaybeHandle<Object> Global(
Isolate* isolate, Handle<String> source, debug::EvaluateGlobalMode mode,
REPLMode repl_mode = REPLMode::kNo);
static V8_EXPORT_PRIVATE MaybeHandle<Object> Global(
Isolate* isolate, Handle<JSFunction> function,
......
......@@ -34,6 +34,7 @@
#include "src/api/api-inl.h"
#include "src/base/strings.h"
#include "src/codegen/compilation-cache.h"
#include "src/debug/debug-evaluate.h"
#include "src/debug/debug-interface.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
......@@ -4565,6 +4566,21 @@ TEST(DebugEvaluateNoSideEffect) {
DisableDebugger(env->GetIsolate());
}
TEST(DebugEvaluateSharedCrossOrigin) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
i::Isolate* isolate = CcTest::i_isolate();
v8::TryCatch tryCatch(env->GetIsolate());
tryCatch.SetCaptureMessage(true);
i::MaybeHandle<i::Object> result = i::DebugEvaluate::Global(
isolate,
isolate->factory()->NewStringFromStaticChars("throw new Error()"),
v8::debug::EvaluateGlobalMode::kDefault);
CHECK(result.is_null());
CHECK(tryCatch.HasCaught());
CHECK(tryCatch.Message()->IsSharedCrossOrigin());
}
namespace {
i::MaybeHandle<i::Script> FindScript(
i::Isolate* isolate, const std::vector<i::Handle<i::Script>>& scripts,
......
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