summaryrefslogtreecommitdiffstats
path: root/webkit/glue/cpp_bound_class_unittest.cc
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 22:59:08 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 22:59:08 +0000
commit2ce5d948eb4ac06b30fc411d276eb6fd70ad1721 (patch)
tree29fd79df759a3c663ba5522bba7d4f4cf38dec1c /webkit/glue/cpp_bound_class_unittest.cc
parent659d0e8f1c3e9336fe4637fef3db2e3e6ab0ee0f (diff)
downloadchromium_src-2ce5d948eb4ac06b30fc411d276eb6fd70ad1721.zip
chromium_src-2ce5d948eb4ac06b30fc411d276eb6fd70ad1721.tar.gz
chromium_src-2ce5d948eb4ac06b30fc411d276eb6fd70ad1721.tar.bz2
Refactor CppBoundClass to allow binding one class as a property of another.
Also cached the NPObject we create for a CppBoundClass, so we only create one each time we bind it to a frame. This will be useful for extensions. Review URL: http://codereview.chromium.org/21337 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/cpp_bound_class_unittest.cc')
-rw-r--r--webkit/glue/cpp_bound_class_unittest.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/webkit/glue/cpp_bound_class_unittest.cc b/webkit/glue/cpp_bound_class_unittest.cc
index b080478..1f412cc 100644
--- a/webkit/glue/cpp_bound_class_unittest.cc
+++ b/webkit/glue/cpp_bound_class_unittest.cc
@@ -17,9 +17,21 @@
namespace {
+class CppBindingExampleSubObject : public CppBindingExample {
+ public:
+ CppBindingExampleSubObject() {
+ sub_value_.Set("sub!");
+ BindProperty("sub_value", &sub_value_);
+ }
+ private:
+ CppVariant sub_value_;
+};
+
+
class CppBindingExampleWithOptionalFallback : public CppBindingExample {
public:
CppBindingExampleWithOptionalFallback() {
+ BindProperty("sub_object", sub_object_.GetAsCppVariant());
}
void set_fallback_method_enabled(bool state) {
@@ -30,9 +42,11 @@ class CppBindingExampleWithOptionalFallback : public CppBindingExample {
// The fallback method does nothing, but because of it the JavaScript keeps
// running when a nonexistent method is called on an object.
- void fallbackMethod(const CppArgumentList& args,
- CppVariant* result) {
+ void fallbackMethod(const CppArgumentList& args, CppVariant* result) {
}
+
+ private:
+ CppBindingExampleSubObject sub_object_;
};
class ExampleTestShell : public TestShell {
@@ -158,6 +172,15 @@ TEST_F(CppBoundClassTest, PropertiesAreInitialized) {
CheckJavaScriptSuccess(js);
}
+TEST_F(CppBoundClassTest, SubOject) {
+ std::string js = BuildJSCondition("typeof window.example.sub_object",
+ "'object'");
+ CheckJavaScriptSuccess(js);
+
+ js = BuildJSCondition("example.sub_object.sub_value", "'sub!'");
+ CheckJavaScriptSuccess(js);
+}
+
TEST_F(CppBoundClassTest, SetAndGetProperties) {
// The property on the left will be set to the value on the right, then
// checked to make sure it holds that same value.