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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 99 } |
100 | 100 |
101 private: | 101 private: |
102 v8::HandleScope m_handleScope; | 102 v8::HandleScope m_handleScope; |
103 v8::Context::Scope m_scope; | 103 v8::Context::Scope m_scope; |
104 }; | 104 }; |
105 | 105 |
106 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) | 106 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) |
107 { | 107 { |
108 v8::Local<v8::Object> object = v8::Object::New(); | 108 v8::Local<v8::Object> object = v8::Object::New(); |
109 object->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "foo"), v8::S
tring::NewFromUtf8(v8::Isolate::GetCurrent(), "zoo")); | 109 object->Set(v8AtomicString(v8::Isolate::GetCurrent(), "foo"), v8AtomicString
(v8::Isolate::GetCurrent(), "zoo")); |
110 | 110 |
111 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); | 111 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
112 | 112 |
113 checkKeyPathStringValue(scriptValue, "foo", "zoo"); | 113 checkKeyPathStringValue(scriptValue, "foo", "zoo"); |
114 checkKeyPathNullValue(scriptValue, "bar"); | 114 checkKeyPathNullValue(scriptValue, "bar"); |
115 } | 115 } |
116 | 116 |
117 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) | 117 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) |
118 { | 118 { |
119 v8::Local<v8::Object> object = v8::Object::New(); | 119 v8::Local<v8::Object> object = v8::Object::New(); |
120 object->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "foo"), v8::N
umber::New(456)); | 120 object->Set(v8AtomicString(v8::Isolate::GetCurrent(), "foo"), v8::Number::Ne
w(456)); |
121 | 121 |
122 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); | 122 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
123 | 123 |
124 checkKeyPathNumberValue(scriptValue, "foo", 456); | 124 checkKeyPathNumberValue(scriptValue, "foo", 456); |
125 checkKeyPathNullValue(scriptValue, "bar"); | 125 checkKeyPathNullValue(scriptValue, "bar"); |
126 } | 126 } |
127 | 127 |
128 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) | 128 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) |
129 { | 129 { |
130 v8::Local<v8::Object> object = v8::Object::New(); | 130 v8::Local<v8::Object> object = v8::Object::New(); |
131 v8::Local<v8::Object> subProperty = v8::Object::New(); | 131 v8::Local<v8::Object> subProperty = v8::Object::New(); |
132 subProperty->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "bar"),
v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "zee")); | 132 subProperty->Set(v8AtomicString(v8::Isolate::GetCurrent(), "bar"), v8AtomicS
tring(v8::Isolate::GetCurrent(), "zee")); |
133 object->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "foo"), subPr
operty); | 133 object->Set(v8AtomicString(v8::Isolate::GetCurrent(), "foo"), subProperty); |
134 | 134 |
135 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); | 135 ScriptValue scriptValue(object, v8::Isolate::GetCurrent()); |
136 | 136 |
137 checkKeyPathStringValue(scriptValue, "foo.bar", "zee"); | 137 checkKeyPathStringValue(scriptValue, "foo.bar", "zee"); |
138 checkKeyPathNullValue(scriptValue, "bar"); | 138 checkKeyPathNullValue(scriptValue, "bar"); |
139 } | 139 } |
140 | 140 |
141 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { | 141 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { |
142 }; | 142 }; |
143 | 143 |
144 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) | 144 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) |
145 { | 145 { |
146 v8::Local<v8::Object> object = v8::Object::New(); | 146 v8::Local<v8::Object> object = v8::Object::New(); |
147 object->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "foo"), v8::S
tring::NewFromUtf8(v8::Isolate::GetCurrent(), "zoo")); | 147 object->Set(v8AtomicString(v8::Isolate::GetCurrent(), "foo"), v8AtomicString
(v8::Isolate::GetCurrent(), "zoo")); |
148 | 148 |
149 ScriptValue foozoo(object, v8::Isolate::GetCurrent()); | 149 ScriptValue foozoo(object, v8::Isolate::GetCurrent()); |
150 checkInjection(IDBKey::createString("myNewKey"), foozoo, "bar"); | 150 checkInjection(IDBKey::createString("myNewKey"), foozoo, "bar"); |
151 checkInjection(IDBKey::createNumber(1234), foozoo, "bar"); | 151 checkInjection(IDBKey::createNumber(1234), foozoo, "bar"); |
152 | 152 |
153 checkInjectionFails(IDBKey::createString("key"), foozoo, "foo.bar"); | 153 checkInjectionFails(IDBKey::createString("key"), foozoo, "foo.bar"); |
154 } | 154 } |
155 | 155 |
156 TEST_F(InjectIDBKeyTest, SubProperty) | 156 TEST_F(InjectIDBKeyTest, SubProperty) |
157 { | 157 { |
158 v8::Local<v8::Object> object = v8::Object::New(); | 158 v8::Local<v8::Object> object = v8::Object::New(); |
159 v8::Local<v8::Object> subProperty = v8::Object::New(); | 159 v8::Local<v8::Object> subProperty = v8::Object::New(); |
160 subProperty->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "bar"),
v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "zee")); | 160 subProperty->Set(v8AtomicString(v8::Isolate::GetCurrent(), "bar"), v8AtomicS
tring(v8::Isolate::GetCurrent(), "zee")); |
161 object->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "foo"), subPr
operty); | 161 object->Set(v8AtomicString(v8::Isolate::GetCurrent(), "foo"), subProperty); |
162 | 162 |
163 ScriptValue scriptObject(object, v8::Isolate::GetCurrent()); | 163 ScriptValue scriptObject(object, v8::Isolate::GetCurrent()); |
164 checkInjection(IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); | 164 checkInjection(IDBKey::createString("myNewKey"), scriptObject, "foo.baz"); |
165 checkInjection(IDBKey::createNumber(789), scriptObject, "foo.baz"); | 165 checkInjection(IDBKey::createNumber(789), scriptObject, "foo.baz"); |
166 checkInjection(IDBKey::createDate(4567), scriptObject, "foo.baz"); | 166 checkInjection(IDBKey::createDate(4567), scriptObject, "foo.baz"); |
167 checkInjection(IDBKey::createDate(4567), scriptObject, "bar"); | 167 checkInjection(IDBKey::createDate(4567), scriptObject, "bar"); |
168 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.b
az"); | 168 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "foo.b
az"); |
169 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar")
; | 169 checkInjection(IDBKey::createArray(IDBKey::KeyArray()), scriptObject, "bar")
; |
170 | 170 |
171 checkInjectionFails(IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"
); | 171 checkInjectionFails(IDBKey::createString("zoo"), scriptObject, "foo.bar.baz"
); |
172 checkInjection(IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); | 172 checkInjection(IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo"); |
173 } | 173 } |
174 | 174 |
175 } // namespace | 175 } // namespace |
OLD | NEW |