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

Side by Side Diff: chrome/test/page_cycler/page_cycler_test.cc

Issue 6092004: Strip quotes from stringified cookie values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/page_cycler
Patch Set: Created 9 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); 239 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url));
240 240
241 // Wait for the test to finish. 241 // Wait for the test to finish.
242 ASSERT_TRUE(WaitUntilCookieValue(tab.get(), test_url, "__pc_done", 242 ASSERT_TRUE(WaitUntilCookieValue(tab.get(), test_url, "__pc_done",
243 UITest::test_timeout_ms(), "1")); 243 UITest::test_timeout_ms(), "1"));
244 244
245 std::string cookie; 245 std::string cookie;
246 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie)); 246 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie));
247 pages->assign(UTF8ToWide(cookie)); 247 pages->assign(UTF8ToWide(cookie));
248 ASSERT_FALSE(pages->empty()); 248 ASSERT_FALSE(pages->empty());
249 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie));
250 249
250 // Get the timing cookie value from the DOM automation.
251 std::wstring wcookie; 251 std::wstring wcookie;
252 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", 252 ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
253 L"window.domAutomationController.send(" 253 L"window.domAutomationController.send("
254 L"JSON.stringify(__get_timings()));", 254 L"JSON.stringify(__get_timings()));",
255 &wcookie)); 255 &wcookie));
256 cookie = base::SysWideToNativeMB(wcookie); 256 cookie = base::SysWideToNativeMB(wcookie);
257 257
258 // JSON.stringify() encapsulates the returned string in quotes, strip them.
259 std::string::size_type start_idx = cookie.find("\"");
260 std::string::size_type end_idx = cookie.find_last_of("\"");
261 if (start_idx != std::string::npos &&
262 end_idx != std::string::npos &&
263 start_idx < end_idx) {
264 cookie = cookie.substr(start_idx+1, end_idx-start_idx-1);
nsylvain 2010/12/29 21:22:14 end_idx-1 maybe?
nsylvain 2010/12/29 21:37:43 did not read correctly. LGTM
265 }
266
258 timings->assign(cookie); 267 timings->assign(cookie);
259 ASSERT_FALSE(timings->empty()); 268 ASSERT_FALSE(timings->empty());
260 } 269 }
261 270
262 // When use_http is true, the test name passed here will be used directly in 271 // When use_http is true, the test name passed here will be used directly in
263 // the path to the test data, so it must be safe for use in a URL without 272 // the path to the test data, so it must be safe for use in a URL without
264 // escaping. (No pound (#), question mark (?), semicolon (;), non-ASCII, or 273 // escaping. (No pound (#), question mark (?), semicolon (;), non-ASCII, or
265 // other funny stuff.) 274 // other funny stuff.)
266 void RunTestWithSuffix(const char* graph, const char* name, bool use_http, 275 void RunTestWithSuffix(const char* graph, const char* name, bool use_http,
267 const char* suffix) { 276 const char* suffix) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 #endif 588 #endif
580 589
581 // Indexed DB tests. 590 // Indexed DB tests.
582 // Disabled in debug builds on Windows. 591 // Disabled in debug builds on Windows.
583 // Bug http://code.google.com/p/chromium/issues/detail?id=67918 592 // Bug http://code.google.com/p/chromium/issues/detail?id=67918
584 #if !defined(OS_WIN) || defined(NDEBUG) 593 #if !defined(OS_WIN) || defined(NDEBUG)
585 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert); 594 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert);
586 #endif 595 #endif
587 596
588 } // namespace 597 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698