Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Unified Diff: extensions/renderer/native_extension_bindings_system_unittest.cc

Issue 2704823002: [Extensions Bindings] Add support for custom property types (Closed)
Patch Set: jbroman's Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698