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

Unified 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 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/page_cycler/page_cycler_test.cc
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 63d507f433f3b3a69c20b25a68942590875e083b..7f46c7d7742913d0f417707a2641f4e1e722a0d7 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -246,8 +246,8 @@ class PageCyclerTest : public UIPerfTest {
ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie));
pages->assign(UTF8ToWide(cookie));
ASSERT_FALSE(pages->empty());
- ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie));
+ // Get the timing cookie value from the DOM automation.
std::wstring wcookie;
ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
L"window.domAutomationController.send("
@@ -255,6 +255,15 @@ class PageCyclerTest : public UIPerfTest {
&wcookie));
cookie = base::SysWideToNativeMB(wcookie);
+ // JSON.stringify() encapsulates the returned string in quotes, strip them.
+ std::string::size_type start_idx = cookie.find("\"");
+ std::string::size_type end_idx = cookie.find_last_of("\"");
+ if (start_idx != std::string::npos &&
+ end_idx != std::string::npos &&
+ start_idx < end_idx) {
+ 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
+ }
+
timings->assign(cookie);
ASSERT_FALSE(timings->empty());
}
« 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