OLD | NEW |
---|---|
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 Loading... | |
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 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 Loading... | |
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 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 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)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 } | 260 } |
270 | 261 |
271 void SetExpectedValue(const content::SerializedScriptValue& expected_value) { | 262 void SetExpectedValue(const content::SerializedScriptValue& expected_value) { |
272 key_path_helper_->SetExpectedValue(expected_value); | 263 key_path_helper_->SetExpectedValue(expected_value); |
273 } | 264 } |
274 | 265 |
275 void CheckValuesForKeyPath( | 266 void CheckValuesForKeyPath( |
276 int id, | 267 int id, |
277 const std::vector<content::SerializedScriptValue>& | 268 const std::vector<content::SerializedScriptValue>& |
278 serialized_script_values, | 269 serialized_script_values, |
279 const string16& key_path) { | 270 const IndexedDBKeyPath& key_path) { |
280 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values, | 271 key_path_helper_->CheckValuesForKeyPath(id, serialized_script_values, |
281 key_path); | 272 key_path); |
282 ui_test_utils::RunMessageLoop(); | 273 ui_test_utils::RunMessageLoop(); |
283 } | 274 } |
284 | 275 |
285 void CheckInjectValue(const IndexedDBKey& key, | 276 void CheckInjectValue(const IndexedDBKey& key, |
286 const content::SerializedScriptValue& value, | 277 const content::SerializedScriptValue& value, |
287 const string16& key_path) { | 278 const IndexedDBKeyPath& key_path) { |
288 key_path_helper_->CheckInjectValue(key, value, key_path); | 279 key_path_helper_->CheckInjectValue(key, value, key_path); |
289 ui_test_utils::RunMessageLoop(); | 280 ui_test_utils::RunMessageLoop(); |
290 } | 281 } |
291 | 282 |
292 private: | 283 private: |
293 scoped_refptr<IDBKeyPathHelper> key_path_helper_; | 284 scoped_refptr<IDBKeyPathHelper> key_path_helper_; |
294 }; | 285 }; |
295 | 286 |
296 // Cases: | 287 // Cases: |
297 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) { | 288 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) { |
(...skipping 26 matching lines...) Expand all Loading... | |
324 serialized_values.push_back(content::SerializedScriptValue( | 315 serialized_values.push_back(content::SerializedScriptValue( |
325 false, false, string16(data_object, arraysize(data_object)))); | 316 false, false, string16(data_object, arraysize(data_object)))); |
326 expected_keys.push_back(null_key); | 317 expected_keys.push_back(null_key); |
327 | 318 |
328 // keypath: "foo", value: null, expected: null | 319 // keypath: "foo", value: null, expected: null |
329 serialized_values.push_back( | 320 serialized_values.push_back( |
330 content::SerializedScriptValue(true, false, string16())); | 321 content::SerializedScriptValue(true, false, string16())); |
331 expected_keys.push_back(null_key); | 322 expected_keys.push_back(null_key); |
332 | 323 |
333 scoped_helper.SetExpectedKeys(kId, expected_keys, false); | 324 scoped_helper.SetExpectedKeys(kId, expected_keys, false); |
325 | |
326 IndexedDBKeyPath key_path; | |
327 key_path.SetString(UTF8ToUTF16("foo")); | |
334 scoped_helper.CheckValuesForKeyPath( | 328 scoped_helper.CheckValuesForKeyPath( |
335 kId, serialized_values, UTF8ToUTF16("foo")); | 329 kId, serialized_values, key_path); |
336 } | 330 } |
337 | 331 |
338 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) { | 332 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) { |
339 ScopedIDBKeyPathHelper scoped_helper; | 333 ScopedIDBKeyPathHelper scoped_helper; |
340 const int kId = 7; | 334 const int kId = 7; |
341 std::vector<IndexedDBKey> expected_keys; | 335 std::vector<IndexedDBKey> expected_keys; |
342 IndexedDBKey null_value; | 336 IndexedDBKey null_value; |
343 null_value.SetNull(); | 337 null_value.SetNull(); |
344 expected_keys.push_back(null_value); | 338 expected_keys.push_back(null_value); |
345 expected_keys.push_back(null_value); | 339 expected_keys.push_back(null_value); |
346 | 340 |
347 scoped_helper.SetExpectedKeys(kId, expected_keys, false); | 341 scoped_helper.SetExpectedKeys(kId, expected_keys, false); |
348 | 342 |
349 std::vector<content::SerializedScriptValue> serialized_values; | 343 std::vector<content::SerializedScriptValue> serialized_values; |
350 // {foo: "zoo", bar: null} | 344 // {foo: "zoo", bar: null} |
351 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, | 345 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, |
352 0x3072, 0x027b}; | 346 0x3072, 0x027b}; |
353 serialized_values.push_back(content::SerializedScriptValue( | 347 serialized_values.push_back(content::SerializedScriptValue( |
354 false, false, string16(data, arraysize(data)))); | 348 false, false, string16(data, arraysize(data)))); |
355 | 349 |
356 // null | 350 // null |
357 serialized_values.push_back( | 351 serialized_values.push_back( |
358 content::SerializedScriptValue(true, false, string16())); | 352 content::SerializedScriptValue(true, false, string16())); |
359 | 353 |
360 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, | 354 IndexedDBKeyPath key_path; |
361 UTF8ToUTF16("PropertyNotAvailable")); | 355 key_path.SetString(UTF8ToUTF16("PropertyNotAvailable")); |
356 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, key_path); | |
362 } | 357 } |
363 | 358 |
364 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) { | 359 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) { |
365 ScopedIDBKeyPathHelper scoped_helper; | 360 ScopedIDBKeyPathHelper scoped_helper; |
366 const int kId = 7; | 361 const int kId = 7; |
367 std::vector<IndexedDBKey> expected_keys; | 362 std::vector<IndexedDBKey> expected_keys; |
368 | 363 |
369 IndexedDBKey null_value; | 364 IndexedDBKey null_value; |
370 null_value.SetNull(); | 365 null_value.SetNull(); |
371 expected_keys.push_back(null_value); | 366 expected_keys.push_back(null_value); |
372 expected_keys.push_back(null_value); | 367 expected_keys.push_back(null_value); |
373 scoped_helper.SetExpectedKeys(kId, expected_keys, true); | 368 scoped_helper.SetExpectedKeys(kId, expected_keys, false); |
374 | 369 |
375 std::vector<content::SerializedScriptValue> serialized_values; | 370 std::vector<content::SerializedScriptValue> serialized_values; |
376 | 371 |
377 // {foo: "zoo", bar: null} | 372 // {foo: "zoo", bar: null} |
378 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, | 373 char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, |
379 0x3072, 0x027b}; | 374 0x3072, 0x027b}; |
380 serialized_values.push_back(content::SerializedScriptValue( | 375 serialized_values.push_back(content::SerializedScriptValue( |
381 false, false, string16(data, arraysize(data)))); | 376 false, false, string16(data, arraysize(data)))); |
382 | 377 |
383 // null | 378 // null |
384 serialized_values.push_back( | 379 serialized_values.push_back( |
385 content::SerializedScriptValue(true, false, string16())); | 380 content::SerializedScriptValue(true, false, string16())); |
386 | 381 |
387 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, | 382 IndexedDBKeyPath key_path; |
388 UTF8ToUTF16("!+Invalid[KeyPath[[[")); | 383 key_path.SetString(UTF8ToUTF16("PropertyNotAvailable")); |
384 scoped_helper.CheckValuesForKeyPath(kId, serialized_values, key_path); | |
michaeln
2012/04/24 21:08:53
I don't follow the purpose of the change from !+In
jsbell
2012/04/24 22:17:47
It's a great question. Since invalid key paths are
| |
389 | 385 |
390 // 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. |
391 expected_keys.clear(); | 387 expected_keys.clear(); |
392 IndexedDBKey value; | 388 IndexedDBKey value; |
393 value.SetString(UTF8ToUTF16("zoo")); | 389 value.SetString(UTF8ToUTF16("zoo")); |
394 expected_keys.push_back(value); | 390 expected_keys.push_back(value); |
395 expected_keys.push_back(null_value); | 391 expected_keys.push_back(null_value); |
396 scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false); | 392 scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false); |
397 scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values, | 393 key_path.SetString(UTF8ToUTF16("foo")); |
398 UTF8ToUTF16("foo")); | 394 scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values, key_path); |
399 } | 395 } |
400 | 396 |
401 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, InjectIDBKey) { | 397 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, InjectIDBKey) { |
402 // {foo: 'zoo'} | 398 // {foo: 'zoo'} |
403 const char16 initial_data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; | 399 const char16 initial_data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; |
404 content::SerializedScriptValue value( | 400 content::SerializedScriptValue value( |
405 false, false, string16(initial_data, arraysize(initial_data))); | 401 false, false, string16(initial_data, arraysize(initial_data))); |
406 IndexedDBKey key; | 402 IndexedDBKey key; |
407 key.SetString(UTF8ToUTF16("myNewKey")); | 403 key.SetString(UTF8ToUTF16("myNewKey")); |
408 | 404 |
409 ScopedIDBKeyPathHelper scoped_helper; | 405 ScopedIDBKeyPathHelper scoped_helper; |
410 | 406 |
411 // {foo: 'zoo', bar: 'myNewKey'} | 407 // {foo: 'zoo', bar: 'myNewKey'} |
412 const char16 expected_data[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, | 408 const char16 expected_data[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, |
413 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, | 409 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, |
414 0x5301, 0x6203, 0x7261, 0x013f, 0x0853, | 410 0x5301, 0x6203, 0x7261, 0x013f, 0x0853, |
415 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b}; | 411 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b}; |
416 content::SerializedScriptValue expected_value( | 412 content::SerializedScriptValue expected_value( |
417 false, false, string16(expected_data, arraysize(expected_data))); | 413 false, false, string16(expected_data, arraysize(expected_data))); |
418 scoped_helper.SetExpectedValue(expected_value); | 414 scoped_helper.SetExpectedValue(expected_value); |
419 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar")); | 415 IndexedDBKeyPath key_path; |
416 key_path.SetString(UTF8ToUTF16("bar")); | |
417 scoped_helper.CheckInjectValue(key, value, key_path); | |
420 | 418 |
421 // 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 |
422 const content::SerializedScriptValue failure_value; | 420 const content::SerializedScriptValue failure_value; |
423 scoped_helper.SetExpectedValue(failure_value); | 421 scoped_helper.SetExpectedValue(failure_value); |
424 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); | |
425 | 424 |
426 // {foo: 'zoo', bar: {baz: 'myNewKey'}} | 425 // {foo: 'zoo', bar: {baz: 'myNewKey'}} |
427 const char16 expected_data2[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, | 426 const char16 expected_data2[] = {0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6603, |
428 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, | 427 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, |
429 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f, | 428 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f, |
430 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853, | 429 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853, |
431 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b, | 430 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b, |
432 0x027b}; | 431 0x027b}; |
433 content::SerializedScriptValue expected_value2( | 432 content::SerializedScriptValue expected_value2( |
434 false, false, string16(expected_data2, arraysize(expected_data2))); | 433 false, false, string16(expected_data2, arraysize(expected_data2))); |
435 scoped_helper.SetExpectedValue(expected_value2); | 434 scoped_helper.SetExpectedValue(expected_value2); |
436 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar.baz")); | 435 key_path.SetString(UTF8ToUTF16("bar.baz")); |
436 scoped_helper.CheckInjectValue(key, value, key_path); | |
437 } | 437 } |
OLD | NEW |