| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 private: | 100 private: |
| 101 v8::HandleScope m_handleScope; | 101 v8::HandleScope m_handleScope; |
| 102 v8::Context::Scope m_scope; | 102 v8::Context::Scope m_scope; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) | 105 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) |
| 106 { | 106 { |
| 107 v8::Local<v8::Object> object = v8::Object::New(); | 107 v8::Local<v8::Object> object = v8::Object::New(); |
| 108 object->Set(v8::String::New("foo"), v8::String::New("zoo")); | 108 object->Set(v8::String::New("foo"), v8::String::New("zoo")); |
| 109 | 109 |
| 110 ScriptValue scriptValue(object); | 110 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
| 111 | 111 |
| 112 checkKeyPathStringValue(scriptValue, "foo", "zoo"); | 112 checkKeyPathStringValue(scriptValue, "foo", "zoo"); |
| 113 checkKeyPathNullValue(scriptValue, "bar"); | 113 checkKeyPathNullValue(scriptValue, "bar"); |
| 114 } | 114 } |
| 115 | 115 |
| 116 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) | 116 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) |
| 117 { | 117 { |
| 118 v8::Local<v8::Object> object = v8::Object::New(); | 118 v8::Local<v8::Object> object = v8::Object::New(); |
| 119 object->Set(v8::String::New("foo"), v8::Number::New(456)); | 119 object->Set(v8::String::New("foo"), v8::Number::New(456)); |
| 120 | 120 |
| 121 ScriptValue scriptValue(object); | 121 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
| 122 | 122 |
| 123 checkKeyPathNumberValue(scriptValue, "foo", 456); | 123 checkKeyPathNumberValue(scriptValue, "foo", 456); |
| 124 checkKeyPathNullValue(scriptValue, "bar"); | 124 checkKeyPathNullValue(scriptValue, "bar"); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) | 127 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) |
| 128 { | 128 { |
| 129 v8::Local<v8::Object> object = v8::Object::New(); | 129 v8::Local<v8::Object> object = v8::Object::New(); |
| 130 v8::Local<v8::Object> subProperty = v8::Object::New(); | 130 v8::Local<v8::Object> subProperty = v8::Object::New(); |
| 131 subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); | 131 subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); |
| 132 object->Set(v8::String::New("foo"), subProperty); | 132 object->Set(v8::String::New("foo"), subProperty); |
| 133 | 133 |
| 134 ScriptValue scriptValue(object); | 134 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
| 135 | 135 |
| 136 checkKeyPathStringValue(scriptValue, "foo.bar", "zee"); | 136 checkKeyPathStringValue(scriptValue, "foo.bar", "zee"); |
| 137 checkKeyPathNullValue(scriptValue, "bar"); | 137 checkKeyPathNullValue(scriptValue, "bar"); |
| 138 } | 138 } |
| 139 | 139 |
| 140 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { | 140 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) | 143 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) |
| 144 { | 144 { |
| 145 v8::Local<v8::Object> object = v8::Object::New(); | 145 v8::Local<v8::Object> object = v8::Object::New(); |
| 146 object->Set(v8::String::New("foo"), v8::String::New("zoo")); | 146 object->Set(v8::String::New("foo"), v8::String::New("zoo")); |
| 147 | 147 |
| 148 ScriptValue foozoo(object); | 148 ScriptValue foozoo(object, v8::Isolate::GetCurrent()); |
| 149 checkInjection(IDBKey::createString("myNewKey"), foozoo, "bar"); | 149 checkInjection(IDBKey::createString("myNewKey"), foozoo, "bar"); |
| 150 checkInjection(IDBKey::createNumber(1234), foozoo, "bar"); | 150 checkInjection(IDBKey::createNumber(1234), foozoo, "bar"); |
| 151 | 151 |
| 152 checkInjectionFails(IDBKey::createString("key"), foozoo, "foo.bar"); | 152 checkInjectionFails(IDBKey::createString("key"), foozoo, "foo.bar"); |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST_F(InjectIDBKeyTest, SubProperty) | 155 TEST_F(InjectIDBKeyTest, SubProperty) |
| 156 { | 156 { |
| 157 v8::Local<v8::Object> object = v8::Object::New(); | 157 v8::Local<v8::Object> object = v8::Object::New(); |
| 158 v8::Local<v8::Object> subProperty = v8::Object::New(); | 158 v8::Local<v8::Object> subProperty = v8::Object::New(); |
| 159 subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); | 159 subProperty->Set(v8::String::New("bar"), v8::String::New("zee")); |
| 160 object->Set(v8::String::New("foo"), subProperty); | 160 object->Set(v8::String::New("foo"), subProperty); |
| 161 | 161 |
| 162 ScriptValue scriptObject(object); | 162 ScriptValue scriptObject(object, v8::Isolate::GetCurrent()); |
| 163 checkInjection(IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); | 163 checkInjection(IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); |
| 164 checkInjection(IDBKey::createNumber(789), scriptObject, "foo.baz"); | 164 checkInjection(IDBKey::createNumber(789), scriptObject, "foo.baz"); |
| 165 checkInjection(IDBKey::createDate(4567), scriptObject, "foo.baz"); | 165 checkInjection(IDBKey::createDate(4567), scriptObject, "foo.baz"); |
| 166 checkInjection(IDBKey::createDate(4567), scriptObject, "bar"); | 166 checkInjection(IDBKey::createDate(4567), scriptObject, "bar"); |
| 167 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.b
az"); | 167 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.b
az"); |
| 168 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar")
; | 168 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar")
; |
| 169 | 169 |
| 170 checkInjectionFails(IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"
); | 170 checkInjectionFails(IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"
); |
| 171 checkInjection(IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); | 171 checkInjection(IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace | 174 } // namespace |
| OLD | NEW |