X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2FWebKit%2FSource%2Fbindings%2Fv8%2FIDBBindingUtilitiesTest.cpp;h=928c89d589d557e9cf941a39fbd0e78df0db058d;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=28c853ab290343d0007697dbe695ab59c6d083f2;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/WebKit/Source/bindings/v8/IDBBindingUtilitiesTest.cpp b/src/third_party/WebKit/Source/bindings/v8/IDBBindingUtilitiesTest.cpp index 28c853a..928c89d 100644 --- a/src/third_party/WebKit/Source/bindings/v8/IDBBindingUtilitiesTest.cpp +++ b/src/third_party/WebKit/Source/bindings/v8/IDBBindingUtilitiesTest.cpp @@ -37,53 +37,53 @@ using namespace WebCore; namespace { -PassRefPtr checkKeyFromValueAndKeyPathInternal(const ScriptValue& value, const String& keyPath) +PassRefPtrWillBeRawPtr checkKeyFromValueAndKeyPathInternal(v8::Isolate* isolate, const ScriptValue& value, const String& keyPath) { IDBKeyPath idbKeyPath(keyPath); EXPECT_TRUE(idbKeyPath.isValid()); - return createIDBKeyFromScriptValueAndKeyPath(0, value, idbKeyPath); + return createIDBKeyFromScriptValueAndKeyPath(isolate, value, idbKeyPath); } -void checkKeyPathNullValue(const ScriptValue& value, const String& keyPath) +void checkKeyPathNullValue(v8::Isolate* isolate, const ScriptValue& value, const String& keyPath) { - RefPtr idbKey = checkKeyFromValueAndKeyPathInternal(value, keyPath); + RefPtrWillBeRawPtr idbKey = checkKeyFromValueAndKeyPathInternal(isolate, value, keyPath); ASSERT_FALSE(idbKey.get()); } -bool injectKey(PassRefPtr key, ScriptValue& value, const String& keyPath) +bool injectKey(ScriptState* scriptState, PassRefPtrWillBeRawPtr key, ScriptValue& value, const String& keyPath) { IDBKeyPath idbKeyPath(keyPath); EXPECT_TRUE(idbKeyPath.isValid()); - ScriptValue keyValue = idbKeyToScriptValue(0, key); - return injectV8KeyIntoV8Value(keyValue.v8Value(), value.v8Value(), idbKeyPath, v8::Isolate::GetCurrent()); + ScriptValue keyValue = idbKeyToScriptValue(scriptState, key); + return injectV8KeyIntoV8Value(scriptState->isolate(), keyValue.v8Value(), value.v8Value(), idbKeyPath); } -void checkInjection(PassRefPtr prpKey, ScriptValue& value, const String& keyPath) +void checkInjection(ScriptState* scriptState, PassRefPtrWillBeRawPtr prpKey, ScriptValue& value, const String& keyPath) { - RefPtr key = prpKey; - bool result = injectKey(key, value, keyPath); + RefPtrWillBeRawPtr key = prpKey; + bool result = injectKey(scriptState, key, value, keyPath); ASSERT_TRUE(result); - RefPtr extractedKey = checkKeyFromValueAndKeyPathInternal(value, keyPath); + RefPtrWillBeRawPtr extractedKey = checkKeyFromValueAndKeyPathInternal(scriptState->isolate(), value, keyPath); EXPECT_TRUE(key->isEqual(extractedKey.get())); } -void checkInjectionFails(PassRefPtr key, ScriptValue& value, const String& keyPath) +void checkInjectionFails(ScriptState* scriptState, PassRefPtrWillBeRawPtr key, ScriptValue& value, const String& keyPath) { - EXPECT_FALSE(injectKey(key, value, keyPath)); + EXPECT_FALSE(injectKey(scriptState, key, value, keyPath)); } -void checkKeyPathStringValue(const ScriptValue& value, const String& keyPath, const String& expected) +void checkKeyPathStringValue(v8::Isolate* isolate, const ScriptValue& value, const String& keyPath, const String& expected) { - RefPtr idbKey = checkKeyFromValueAndKeyPathInternal(value, keyPath); + RefPtrWillBeRawPtr idbKey = checkKeyFromValueAndKeyPathInternal(isolate, value, keyPath); ASSERT_TRUE(idbKey.get()); ASSERT_EQ(IDBKey::StringType, idbKey->type()); ASSERT_TRUE(expected == idbKey->string()); } -void checkKeyPathNumberValue(const ScriptValue& value, const String& keyPath, int expected) +void checkKeyPathNumberValue(v8::Isolate* isolate, const ScriptValue& value, const String& keyPath, int expected) { - RefPtr idbKey = checkKeyFromValueAndKeyPathInternal(value, keyPath); + RefPtrWillBeRawPtr idbKey = checkKeyFromValueAndKeyPathInternal(isolate, value, keyPath); ASSERT_TRUE(idbKey.get()); ASSERT_EQ(IDBKey::NumberType, idbKey->type()); ASSERT_TRUE(expected == idbKey->number()); @@ -105,10 +105,10 @@ TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) v8::Local object = v8::Object::New(isolate); object->Set(v8AtomicString(isolate, "foo"), v8AtomicString(isolate, "zoo")); - ScriptValue scriptValue(object, isolate); + ScriptValue scriptValue(ScriptState::current(isolate), object); - checkKeyPathStringValue(scriptValue, "foo", "zoo"); - checkKeyPathNullValue(scriptValue, "bar"); + checkKeyPathStringValue(isolate, scriptValue, "foo", "zoo"); + checkKeyPathNullValue(isolate, scriptValue, "bar"); } TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) @@ -117,10 +117,10 @@ TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) v8::Local object = v8::Object::New(isolate); object->Set(v8AtomicString(isolate, "foo"), v8::Number::New(isolate, 456)); - ScriptValue scriptValue(object, isolate); + ScriptValue scriptValue(ScriptState::current(isolate), object); - checkKeyPathNumberValue(scriptValue, "foo", 456); - checkKeyPathNullValue(scriptValue, "bar"); + checkKeyPathNumberValue(isolate, scriptValue, "foo", 456); + checkKeyPathNullValue(isolate, scriptValue, "bar"); } TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) @@ -131,10 +131,10 @@ TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) subProperty->Set(v8AtomicString(isolate, "bar"), v8AtomicString(isolate, "zee")); object->Set(v8AtomicString(isolate, "foo"), subProperty); - ScriptValue scriptValue(object, isolate); + ScriptValue scriptValue(ScriptState::current(isolate), object); - checkKeyPathStringValue(scriptValue, "foo.bar", "zee"); - checkKeyPathNullValue(scriptValue, "bar"); + checkKeyPathStringValue(isolate, scriptValue, "foo.bar", "zee"); + checkKeyPathNullValue(isolate, scriptValue, "bar"); } class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { @@ -143,34 +143,36 @@ class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + ScriptState* scriptState = ScriptState::current(isolate); v8::Local object = v8::Object::New(isolate); object->Set(v8AtomicString(isolate, "foo"), v8AtomicString(isolate, "zoo")); ScriptValue foozoo(object, isolate); - checkInjection(IDBKey::createString("myNewKey"), foozoo, "bar"); - checkInjection(IDBKey::createNumber(1234), foozoo, "bar"); + checkInjection(scriptState, IDBKey::createString("myNewKey"), foozoo, "bar"); + checkInjection(scriptState, IDBKey::createNumber(1234), foozoo, "bar"); - checkInjectionFails(IDBKey::createString("key"), foozoo, "foo.bar"); + checkInjectionFails(scriptState, IDBKey::createString("key"), foozoo, "foo.bar"); } TEST_F(InjectIDBKeyTest, SubProperty) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + ScriptState* scriptState = ScriptState::current(isolate); v8::Local object = v8::Object::New(isolate); v8::Local subProperty = v8::Object::New(isolate); subProperty->Set(v8AtomicString(isolate, "bar"), v8AtomicString(isolate, "zee")); object->Set(v8AtomicString(isolate, "foo"), subProperty); ScriptValue scriptObject(object, isolate); - checkInjection(IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); - checkInjection(IDBKey::createNumber(789), scriptObject, "foo.baz"); - checkInjection(IDBKey::createDate(4567), scriptObject, "foo.baz"); - checkInjection(IDBKey::createDate(4567), scriptObject, "bar"); - checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.baz"); - checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar"); - - checkInjectionFails(IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"); - checkInjection(IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); + checkInjection(scriptState, IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); + checkInjection(scriptState, IDBKey::createNumber(789), scriptObject, "foo.baz"); + checkInjection(scriptState, IDBKey::createDate(4567), scriptObject, "foo.baz"); + checkInjection(scriptState, IDBKey::createDate(4567), scriptObject, "bar"); + checkInjection(scriptState, IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.baz"); + checkInjection(scriptState, IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar"); + + checkInjectionFails(scriptState, IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"); + checkInjection(scriptState, IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); } } // namespace