[Extensions] Add (temporary) CHECKs to SetPrivate in ModuleSystem
This CL adds CHECK()s to SetPrivate() calls from ModuleSystem to investigate whether setting Private succeeds or not. This would help narrow down the root cause for crbug.com/1276144. Bug: 1276144 Change-Id: I058742272c5be320744005658e15b6e0b9328bfc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646274 Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org> Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org> Cr-Commit-Position: refs/heads/main@{#1004867}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
af040e6653
commit
cfaf4056e6
@ -186,8 +186,17 @@ ModuleSystem::ModuleSystem(ScriptContext* context, const SourceMap* source_map)
|
||||
exception_handler_(new DefaultExceptionHandler(context)) {
|
||||
v8::Local<v8::Object> global(context->v8_context()->Global());
|
||||
v8::Isolate* isolate = context->isolate();
|
||||
SetPrivate(global, kModulesField, v8::Object::New(isolate));
|
||||
SetPrivate(global, kModuleSystem, v8::External::New(isolate, this));
|
||||
// Note: Ensure setting private succeeds with CHECK.
|
||||
// TODO(1276144): remove checks once investigation finished.
|
||||
CHECK(SetPrivate(global, kModulesField, v8::Object::New(isolate)));
|
||||
CHECK(SetPrivate(global, kModuleSystem, v8::External::New(isolate, this)));
|
||||
{
|
||||
// Note: Ensure privates that were set above can be read immediately.
|
||||
// TODO(1276144): remove checks once investigation finished.
|
||||
v8::Local<v8::Value> dummy_value;
|
||||
CHECK(GetPrivate(global, kModulesField, &dummy_value));
|
||||
CHECK(GetPrivate(global, kModuleSystem, &dummy_value));
|
||||
}
|
||||
|
||||
if (context_->GetRenderFrame() &&
|
||||
context_->context_type() == Feature::BLESSED_EXTENSION_CONTEXT &&
|
||||
|
@ -204,24 +204,25 @@ bool ObjectBackedNativeHandler::ContextCanAccessObject(
|
||||
return blink::WebFrame::ScriptCanAccess(other_script_context->web_frame());
|
||||
}
|
||||
|
||||
void ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Object> obj,
|
||||
bool ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Object> obj,
|
||||
const char* key,
|
||||
v8::Local<v8::Value> value) {
|
||||
SetPrivate(context_->v8_context(), obj, key, value);
|
||||
return SetPrivate(context_->v8_context(), obj, key, value);
|
||||
}
|
||||
|
||||
// static
|
||||
void ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Context> context,
|
||||
bool ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Object> obj,
|
||||
const char* key,
|
||||
v8::Local<v8::Value> value) {
|
||||
obj->SetPrivate(
|
||||
context,
|
||||
v8::Private::ForApi(context->GetIsolate(),
|
||||
v8::String::NewFromUtf8(context->GetIsolate(), key,
|
||||
v8::NewStringType::kNormal)
|
||||
.ToLocalChecked()),
|
||||
value)
|
||||
return obj
|
||||
->SetPrivate(context,
|
||||
v8::Private::ForApi(
|
||||
context->GetIsolate(),
|
||||
v8::String::NewFromUtf8(context->GetIsolate(), key,
|
||||
v8::NewStringType::kNormal)
|
||||
.ToLocalChecked()),
|
||||
value)
|
||||
.FromJust();
|
||||
}
|
||||
|
||||
|
@ -80,10 +80,11 @@ class ObjectBackedNativeHandler : public NativeHandler {
|
||||
|
||||
// The following methods are convenience wrappers for methods on v8::Object
|
||||
// with the corresponding names.
|
||||
void SetPrivate(v8::Local<v8::Object> obj,
|
||||
// Returns whether or not setting privates was successful.
|
||||
bool SetPrivate(v8::Local<v8::Object> obj,
|
||||
const char* key,
|
||||
v8::Local<v8::Value> value);
|
||||
static void SetPrivate(v8::Local<v8::Context> context,
|
||||
static bool SetPrivate(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Object> obj,
|
||||
const char* key,
|
||||
v8::Local<v8::Value> value);
|
||||
|
Reference in New Issue
Block a user