Index: extensions/renderer/native_extension_bindings_system_unittest.cc |
diff --git a/extensions/renderer/native_extension_bindings_system_unittest.cc b/extensions/renderer/native_extension_bindings_system_unittest.cc |
index a7708e6c285f246235bd7eb73184cd6241eb16f5..b9f2ba7f9b2d0f4aa782d8ea8b8a08848319987a 100644 |
--- a/extensions/renderer/native_extension_bindings_system_unittest.cc |
+++ b/extensions/renderer/native_extension_bindings_system_unittest.cc |
@@ -653,4 +653,38 @@ TEST_F(NativeExtensionBindingsSystemUnittest, TestLastError) { |
"lastErrorMessage")); |
} |
+TEST_F(NativeExtensionBindingsSystemUnittest, TestCustomProperties) { |
+ scoped_refptr<Extension> extension = |
+ CreateExtension("storage extension", ItemType::EXTENSION, {"storage"}); |
+ RegisterExtension(extension->id()); |
+ |
+ v8::HandleScope handle_scope(isolate()); |
+ v8::Local<v8::Context> context = ContextLocal(); |
+ |
+ ScriptContext* script_context = CreateScriptContext( |
+ context, extension.get(), Feature::BLESSED_EXTENSION_CONTEXT); |
+ script_context->set_url(extension->url()); |
+ |
+ bindings_system()->UpdateBindingsForContext(script_context); |
+ |
+ v8::Local<v8::Value> storage = |
+ V8ValueFromScriptSource(context, "chrome.storage"); |
+ ASSERT_FALSE(storage.IsEmpty()); |
+ ASSERT_TRUE(storage->IsObject()); |
+ |
+ v8::Local<v8::Value> local = |
+ GetPropertyFromObject(storage.As<v8::Object>(), context, "local"); |
+ ASSERT_FALSE(local.IsEmpty()); |
+ ASSERT_TRUE(local->IsObject()); |
+ |
+ v8::Local<v8::Object> local_object = local.As<v8::Object>(); |
+ const std::vector<std::string> kKeys = {"get", "set", "remove", "clear", |
+ "getBytesInUse"}; |
+ for (const auto& key : kKeys) { |
+ v8::Local<v8::String> v8_key = gin::StringToV8(isolate(), key); |
+ EXPECT_TRUE(local_object->HasOwnProperty(context, v8_key).FromJust()) |
+ << key; |
+ } |
+} |
+ |
} // namespace extensions |