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

Side by Side Diff: content/browser/indexed_db/idbbindingutilities_browsertest.cc

Issue 10204003: Use WebIDBKeyPath type in WebKit API, implement IndexedDBKeyPath type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move IndexedDBKeyPath to content namespace, formatting nits. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/test/base/in_process_browser_test.h" 7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "chrome/test/base/ui_test_utils.h" 8 #include "chrome/test/base/ui_test_utils.h"
9 #include "content/browser/utility_process_host_impl.h" 9 #include "content/browser/utility_process_host_impl.h"
10 #include "content/public/browser/utility_process_host_client.h" 10 #include "content/public/browser/utility_process_host_client.h"
11 #include "content/common/indexed_db/indexed_db_key.h" 11 #include "content/common/indexed_db/indexed_db_key.h"
12 #include "content/common/indexed_db/indexed_db_key_path.h"
12 #include "content/common/utility_messages.h" 13 #include "content/common/utility_messages.h"
13 #include "content/common/webkitplatformsupport_impl.h" 14 #include "content/common/webkitplatformsupport_impl.h"
14 #include "content/public/common/serialized_script_value.h" 15 #include "content/public/common/serialized_script_value.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
19 #include "webkit/glue/idb_bindings.h" 20 #include "webkit/glue/idb_bindings.h"
20 #include "webkit/glue/web_io_operators.h" 21 #include "webkit/glue/web_io_operators.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 using content::UtilityProcessHost; 24 using content::UtilityProcessHost;
24 using content::UtilityProcessHostClient; 25 using content::UtilityProcessHostClient;
25 using WebKit::WebSerializedScriptValue; 26 using WebKit::WebSerializedScriptValue;
27 using WebKit::WebIDBKeyPath;
26 28
27 // Enables calling WebKit::shutdown no matter where a "return" happens. 29 // Enables calling WebKit::shutdown no matter where a "return" happens.
28 class ScopedShutdownWebKit { 30 class ScopedShutdownWebKit {
29 public: 31 public:
30 ScopedShutdownWebKit() { 32 ScopedShutdownWebKit() {
31 } 33 }
32 34
33 ~ScopedShutdownWebKit() { 35 ~ScopedShutdownWebKit() {
34 WebKit::shutdown(); 36 WebKit::shutdown();
35 } 37 }
(...skipping 23 matching lines...) Expand all
59 // {} 61 // {}
60 char16 data_object[] = {0x017b}; 62 char16 data_object[] = {0x017b};
61 serialized_values.push_back(content::SerializedScriptValue( 63 serialized_values.push_back(content::SerializedScriptValue(
62 false, false, string16(data_object, arraysize(data_object)))); 64 false, false, string16(data_object, arraysize(data_object))));
63 65
64 // null 66 // null
65 serialized_values.push_back( 67 serialized_values.push_back(
66 WebSerializedScriptValue::fromString(string16())); 68 WebSerializedScriptValue::fromString(string16()));
67 69
68 std::vector<WebKit::WebIDBKey> values; 70 std::vector<WebKit::WebIDBKey> values;
69 string16 key_path; 71 content::IndexedDBKeyPath key_path;
70 bool error;
71 72
72 key_path = UTF8ToUTF16("foo"); 73 key_path.SetString(UTF8ToUTF16("foo"));
73 error = webkit_glue::IDBKeysFromValuesAndKeyPath( 74 webkit_glue::IDBKeysFromValuesAndKeyPath(
74 serialized_values, key_path, &values); 75 serialized_values, key_path, &values);
75 76
76 ASSERT_EQ(size_t(4), values.size()); 77 ASSERT_EQ(size_t(4), values.size());
77 ASSERT_EQ(WebKit::WebIDBKey::StringType, values[0].type()); 78 ASSERT_EQ(WebKit::WebIDBKey::StringType, values[0].type());
78 ASSERT_EQ(UTF8ToUTF16("zoo"), values[0].string()); 79 ASSERT_EQ(UTF8ToUTF16("zoo"), values[0].string());
79 ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[1].type()); 80 ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[1].type());
80 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type()); 81 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type());
81 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type()); 82 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type());
82 ASSERT_FALSE(error);
83 83
84 values.clear(); 84 values.clear();
85 key_path = UTF8ToUTF16("PropertyNotAvailable"); 85 key_path.SetString(UTF8ToUTF16("PropertyNotAvailable"));
86 error = webkit_glue::IDBKeysFromValuesAndKeyPath( 86 webkit_glue::IDBKeysFromValuesAndKeyPath(
87 serialized_values, key_path, &values); 87 serialized_values, key_path, &values);
88 88
89 ASSERT_EQ(size_t(4), values.size()); 89 ASSERT_EQ(size_t(4), values.size());
90 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[0].type()); 90 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[0].type());
91 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[1].type()); 91 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[1].type());
92 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type()); 92 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type());
93 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type()); 93 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type());
94 ASSERT_FALSE(error);
95 94
96 values.clear(); 95 values.clear();
97 key_path = UTF8ToUTF16("!+Invalid[KeyPath[[["); 96 key_path.SetString(UTF8ToUTF16("!+Invalid[KeyPath[[["));
98 error = webkit_glue::IDBKeysFromValuesAndKeyPath( 97 ASSERT_FALSE(key_path.IsValid());
99 serialized_values, key_path, &values);
100
101 ASSERT_TRUE(error);
102 ASSERT_EQ(size_t(4), values.size());
103 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[0].type());
104 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[1].type());
105 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type());
106 ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type());
107 } 98 }
108 99
109 class IDBKeyPathHelper : public UtilityProcessHostClient { 100 class IDBKeyPathHelper : public UtilityProcessHostClient {
110 public: 101 public:
111 IDBKeyPathHelper() 102 IDBKeyPathHelper()
112 : expected_id_(0), 103 : expected_id_(0),
113 value_for_key_path_failed_(false) { 104 value_for_key_path_failed_(false) {
114 } 105 }
115 106
116 void CreateUtilityProcess() { 107 void CreateUtilityProcess() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 value_for_key_path_failed_ = failed; 142 value_for_key_path_failed_ = failed;
152 } 143 }
153 144
154 void SetExpectedValue(const content::SerializedScriptValue& expected_value) { 145 void SetExpectedValue(const content::SerializedScriptValue& expected_value) {
155 expected_value_ = expected_value; 146 expected_value_ = expected_value;
156 } 147 }
157 148
158 void CheckValuesForKeyPath( 149 void CheckValuesForKeyPath(
159 int id, 150 int id,
160 const std::vector<content::SerializedScriptValue>& serialized_values, 151 const std::vector<content::SerializedScriptValue>& serialized_values,
161 const string16& key_path) { 152 const content::IndexedDBKeyPath& key_path) {
162 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 153 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
163 BrowserThread::PostTask( 154 BrowserThread::PostTask(
164 BrowserThread::IO, FROM_HERE, 155 BrowserThread::IO, FROM_HERE,
165 base::Bind(&IDBKeyPathHelper::CheckValuesForKeyPath, this, id, 156 base::Bind(&IDBKeyPathHelper::CheckValuesForKeyPath, this, id,
166 serialized_values, key_path)); 157 serialized_values, key_path));
167 return; 158 return;
168 } 159 }
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
170 bool ret = utility_process_host_->Send( 161 bool ret = utility_process_host_->Send(
171 new UtilityMsg_IDBKeysFromValuesAndKeyPath( 162 new UtilityMsg_IDBKeysFromValuesAndKeyPath(
172 id, serialized_values, key_path)); 163 id, serialized_values, key_path));
173 ASSERT_TRUE(ret); 164 ASSERT_TRUE(ret);
174 } 165 }
175 166
176 void CheckInjectValue(const IndexedDBKey& key, 167 void CheckInjectValue(const IndexedDBKey& key,
177 const content::SerializedScriptValue& value, 168 const content::SerializedScriptValue& value,
178 const string16& key_path) { 169 const content::IndexedDBKeyPath& key_path) {
179 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 170 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
180 BrowserThread::PostTask( 171 BrowserThread::PostTask(
181 BrowserThread::IO, FROM_HERE, 172 BrowserThread::IO, FROM_HERE,
182 base::Bind(&IDBKeyPathHelper::CheckInjectValue, this, key, value, 173 base::Bind(&IDBKeyPathHelper::CheckInjectValue, this, key, value,
183 key_path)); 174 key_path));
184 return; 175 return;
185 } 176 }
186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
187 bool ret = utility_process_host_->Send(new UtilityMsg_InjectIDBKey( 178 bool ret = utility_process_host_->Send(new UtilityMsg_InjectIDBKey(
188 key, value, key_path)); 179 key, value, key_path));
189 ASSERT_TRUE(ret); 180 ASSERT_TRUE(ret);
190 } 181 }
191 182
192 // UtilityProcessHostClient 183 // UtilityProcessHostClient
193 bool OnMessageReceived(const IPC::Message& message) { 184 bool OnMessageReceived(const IPC::Message& message) {
194 bool msg_is_ok = true; 185 bool msg_is_ok = true;
195 bool handled = true; 186 bool handled = true;
196 IPC_BEGIN_MESSAGE_MAP_EX(IDBKeyPathHelper, message, msg_is_ok) 187 IPC_BEGIN_MESSAGE_MAP_EX(IDBKeyPathHelper, message, msg_is_ok)
197 IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded, 188 IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded,
198 OnIDBKeysFromValuesAndKeyPathSucceeded) 189 OnIDBKeysFromValuesAndKeyPathSucceeded)
199 IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed,
200 OnIDBKeysFromValuesAndKeyPathFailed)
201 IPC_MESSAGE_HANDLER(UtilityHostMsg_InjectIDBKey_Finished, 190 IPC_MESSAGE_HANDLER(UtilityHostMsg_InjectIDBKey_Finished,
202 OnInjectIDBKeyFinished) 191 OnInjectIDBKeyFinished)
203 IPC_MESSAGE_UNHANDLED(handled = false) 192 IPC_MESSAGE_UNHANDLED(handled = false)
204 IPC_END_MESSAGE_MAP_EX() 193 IPC_END_MESSAGE_MAP_EX()
205 return handled; 194 return handled;
206 } 195 }
207 196
208 void OnIDBKeysFromValuesAndKeyPathSucceeded( 197 void OnIDBKeysFromValuesAndKeyPathSucceeded(
209 int id, const std::vector<IndexedDBKey>& values) { 198 int id, const std::vector<IndexedDBKey>& values) {
210 EXPECT_EQ(expected_id_, id); 199 EXPECT_EQ(expected_id_, id);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 260 }
272 261
273 void SetExpectedValue(const content::SerializedScriptValue& expected_value) { 262 void SetExpectedValue(const content::SerializedScriptValue& expected_value) {
274 key_path_helper_->SetExpectedValue(expected_value); 263 key_path_helper_->SetExpectedValue(expected_value);
275 } 264 }
276 265
277 void CheckValuesForKeyPath( 266 void CheckValuesForKeyPath(
278 int id, 267 int id,
279 const std::vector<content::SerializedScriptValue>& 268 const std::vector<content::SerializedScriptValue>&
280 serialized_script_values, 269 serialized_script_values,
281 const string16& key_path) { 270 const content::IndexedDBKeyPath& key_path) {
282 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values, 271 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values,
283 key_path); 272 key_path);
284 ui_test_utils::RunMessageLoop(); 273 ui_test_utils::RunMessageLoop();
285 } 274 }
286 275
287 void CheckInjectValue(const IndexedDBKey& key, 276 void CheckInjectValue(const IndexedDBKey& key,
288 const content::SerializedScriptValue& value, 277 const content::SerializedScriptValue& value,
289 const string16& key_path) { 278 const content::IndexedDBKeyPath& key_path) {
290 key_path_helper_->CheckInjectValue(key, value, key_path); 279 key_path_helper_->CheckInjectValue(key, value, key_path);
291 ui_test_utils::RunMessageLoop(); 280 ui_test_utils::RunMessageLoop();
292 } 281 }
293 282
294 private: 283 private:
295 scoped_refptr<IDBKeyPathHelper> key_path_helper_; 284 scoped_refptr<IDBKeyPathHelper> key_path_helper_;
296 }; 285 };
297 286
298 // Cases: 287 // Cases:
299 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) { 288 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) {
(...skipping 26 matching lines...) Expand all
326 serialized_values.push_back(content::SerializedScriptValue( 315 serialized_values.push_back(content::SerializedScriptValue(
327 false, false, string16(data_object, arraysize(data_object)))); 316 false, false, string16(data_object, arraysize(data_object))));
328 expected_keys.push_back(null_key); 317 expected_keys.push_back(null_key);
329 318
330 // keypath: "foo", value: null, expected: null 319 // keypath: "foo", value: null, expected: null
331 serialized_values.push_back( 320 serialized_values.push_back(
332 content::SerializedScriptValue(true, false, string16())); 321 content::SerializedScriptValue(true, false, string16()));
333 expected_keys.push_back(null_key); 322 expected_keys.push_back(null_key);
334 323
335 scoped_helper.SetExpectedKeys(kId, expected_keys, false); 324 scoped_helper.SetExpectedKeys(kId, expected_keys, false);
325
326 content::IndexedDBKeyPath key_path;
327 key_path.SetString(UTF8ToUTF16("foo"));
336 scoped_helper.CheckValuesForKeyPath( 328 scoped_helper.CheckValuesForKeyPath(
337 kId, serialized_values, UTF8ToUTF16("foo")); 329 kId, serialized_values, key_path);
338 } 330 }
339 331
340 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) { 332 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) {
341 ScopedIDBKeyPathHelper scoped_helper; 333 ScopedIDBKeyPathHelper scoped_helper;
342 const int kId = 7; 334 const int kId = 7;
343 std::vector<IndexedDBKey> expected_keys; 335 std::vector<IndexedDBKey> expected_keys;
344 IndexedDBKey null_value; 336 IndexedDBKey null_value;
345 null_value.SetNull(); 337 null_value.SetNull();
346 expected_keys.push_back(null_value); 338 expected_keys.push_back(null_value);
347 expected_keys.push_back(null_value); 339 expected_keys.push_back(null_value);
348 340
349 scoped_helper.SetExpectedKeys(kId, expected_keys, false); 341 scoped_helper.SetExpectedKeys(kId, expected_keys, false);
350 342
351 std::vector<content::SerializedScriptValue> serialized_values; 343 std::vector<content::SerializedScriptValue> serialized_values;
352 // {foo: "zoo", bar: null} 344 // {foo: "zoo", bar: null}
353 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, 345 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162,
354 0x3072, 0x027b}; 346 0x3072, 0x027b};
355 serialized_values.push_back(content::SerializedScriptValue( 347 serialized_values.push_back(content::SerializedScriptValue(
356 false, false, string16(data, arraysize(data)))); 348 false, false, string16(data, arraysize(data))));
357 349
358 // null 350 // null
359 serialized_values.push_back( 351 serialized_values.push_back(
360 content::SerializedScriptValue(true, false, string16())); 352 content::SerializedScriptValue(true, false, string16()));
361 353
362 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, 354 content::IndexedDBKeyPath key_path;
363 UTF8ToUTF16("PropertyNotAvailable")); 355 key_path.SetString(UTF8ToUTF16("PropertyNotAvailable"));
356 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, key_path);
364 } 357 }
365 358
366 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) { 359 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) {
367 ScopedIDBKeyPathHelper scoped_helper; 360 ScopedIDBKeyPathHelper scoped_helper;
368 const int kId = 7; 361 const int kId = 7;
369 std::vector<IndexedDBKey> expected_keys; 362 std::vector<IndexedDBKey> expected_keys;
370 363
371 IndexedDBKey null_value; 364 IndexedDBKey null_value;
372 null_value.SetNull(); 365 null_value.SetNull();
373 expected_keys.push_back(null_value); 366 expected_keys.push_back(null_value);
374 expected_keys.push_back(null_value); 367 expected_keys.push_back(null_value);
375 scoped_helper.SetExpectedKeys(kId, expected_keys, true); 368 scoped_helper.SetExpectedKeys(kId, expected_keys, false);
376 369
377 std::vector<content::SerializedScriptValue> serialized_values; 370 std::vector<content::SerializedScriptValue> serialized_values;
378 371
379 // {foo: "zoo", bar: null} 372 // {foo: "zoo", bar: null}
380 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, 373 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162,
381 0x3072, 0x027b}; 374 0x3072, 0x027b};
382 serialized_values.push_back(content::SerializedScriptValue( 375 serialized_values.push_back(content::SerializedScriptValue(
383 false, false, string16(data, arraysize(data)))); 376 false, false, string16(data, arraysize(data))));
384 377
385 // null 378 // null
386 serialized_values.push_back( 379 serialized_values.push_back(
387 content::SerializedScriptValue(true, false, string16())); 380 content::SerializedScriptValue(true, false, string16()));
388 381
389 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, 382 content::IndexedDBKeyPath key_path;
390 UTF8ToUTF16("!+Invalid[KeyPath[[[")); 383 key_path.SetString(UTF8ToUTF16("PropertyNotAvailable"));
384 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, key_path);
391 385
392 // Call again with the Utility process in batch mode and with valid keys. 386 // Call again with the Utility process in batch mode and with valid keys.
393 expected_keys.clear(); 387 expected_keys.clear();
394 IndexedDBKey value; 388 IndexedDBKey value;
395 value.SetString(UTF8ToUTF16("zoo")); 389 value.SetString(UTF8ToUTF16("zoo"));
396 expected_keys.push_back(value); 390 expected_keys.push_back(value);
397 expected_keys.push_back(null_value); 391 expected_keys.push_back(null_value);
398 scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false); 392 scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false);
399 scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values, 393 key_path.SetString(UTF8ToUTF16("foo"));
400 UTF8ToUTF16("foo")); 394 scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values, key_path);
401 } 395 }
402 396
403 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, InjectIDBKey) { 397 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, InjectIDBKey) {
404 // {foo: 'zoo'} 398 // {foo: 'zoo'}
405 const char16 initial_data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; 399 const char16 initial_data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b};
406 content::SerializedScriptValue value( 400 content::SerializedScriptValue value(
407 false, false, string16(initial_data, arraysize(initial_data))); 401 false, false, string16(initial_data, arraysize(initial_data)));
408 IndexedDBKey key; 402 IndexedDBKey key;
409 key.SetString(UTF8ToUTF16("myNewKey")); 403 key.SetString(UTF8ToUTF16("myNewKey"));
410 404
411 ScopedIDBKeyPathHelper scoped_helper; 405 ScopedIDBKeyPathHelper scoped_helper;
412 406
413 // {foo: 'zoo', bar: 'myNewKey'} 407 // {foo: 'zoo', bar: 'myNewKey'}
414 const char16 expected_data[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 408 const char16 expected_data[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603,
415 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, 409 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f,
416 0x5301, 0x6203, 0x7261, 0x013f, 0x0853, 410 0x5301, 0x6203, 0x7261, 0x013f, 0x0853,
417 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b}; 411 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b};
418 content::SerializedScriptValue expected_value( 412 content::SerializedScriptValue expected_value(
419 false, false, string16(expected_data, arraysize(expected_data))); 413 false, false, string16(expected_data, arraysize(expected_data)));
420 scoped_helper.SetExpectedValue(expected_value); 414 scoped_helper.SetExpectedValue(expected_value);
421 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar")); 415 content::IndexedDBKeyPath key_path;
416 key_path.SetString(UTF8ToUTF16("bar"));
417 scoped_helper.CheckInjectValue(key, value, key_path);
422 418
423 // Should fail - can't apply properties to string value of key foo 419 // Should fail - can't apply properties to string value of key foo
424 const content::SerializedScriptValue failure_value; 420 const content::SerializedScriptValue failure_value;
425 scoped_helper.SetExpectedValue(failure_value); 421 scoped_helper.SetExpectedValue(failure_value);
426 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("foo.bad.path")); 422 key_path.SetString(UTF8ToUTF16("foo.bad.path"));
423 scoped_helper.CheckInjectValue(key, value, key_path);
427 424
428 // {foo: 'zoo', bar: {baz: 'myNewKey'}} 425 // {foo: 'zoo', bar: {baz: 'myNewKey'}}
429 const char16 expected_data2[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 426 const char16 expected_data2[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603,
430 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, 427 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f,
431 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f, 428 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f,
432 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853, 429 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853,
433 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b, 430 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b,
434 0x027b}; 431 0x027b};
435 content::SerializedScriptValue expected_value2( 432 content::SerializedScriptValue expected_value2(
436 false, false, string16(expected_data2, arraysize(expected_data2))); 433 false, false, string16(expected_data2, arraysize(expected_data2)));
437 scoped_helper.SetExpectedValue(expected_value2); 434 scoped_helper.SetExpectedValue(expected_value2);
438 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar.baz")); 435 key_path.SetString(UTF8ToUTF16("bar.baz"));
436 scoped_helper.CheckInjectValue(key, value, key_path);
439 } 437 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_key_utility_client.cc ('k') | content/common/indexed_db/indexed_db_key_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698