feat: add support for Blob's going over the ctx bridge (#29247)

This commit is contained in:
Samuel Attard 2021-05-26 10:34:29 -07:00 committed by GitHub
parent d0b9a931cc
commit f01e35f4ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 2 deletions

View file

@ -24,6 +24,7 @@
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
#include "shell/common/world_ids.h"
#include "third_party/blink/public/web/web_blob.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_local_frame.h"
@ -346,6 +347,14 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
destination_context->Global(), destination_context->GetIsolate()));
}
// Custom logic to "clone" Blob references
blink::WebBlob blob = blink::WebBlob::FromV8Value(value);
if (!blob.IsNull()) {
v8::Context::Scope destination_context_scope(destination_context);
return v8::MaybeLocal<v8::Value>(blob.ToV8Value(
destination_context->Global(), destination_context->GetIsolate()));
}
// Proxy all objects
if (IsPlainObject(value)) {
auto object_value = value.As<v8::Object>();