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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 #include "chrome/browser/ui/browser_tabstrip.h" | 6 #include "chrome/browser/ui/browser_tabstrip.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/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 #include "net/test/test_server.h" | 11 #include "net/test/test_server.h" |
12 | 12 |
13 class LoadTimingObserverTest : public InProcessBrowserTest { | 13 class LoadTimingObserverTest : public InProcessBrowserTest { |
14 public: | 14 public: |
15 LoadTimingObserverTest() { | 15 LoadTimingObserverTest() {} |
16 EnableDOMAutomation(); | |
17 } | |
18 | |
19 protected: | |
20 }; | 16 }; |
21 | 17 |
22 // http://crbug.com/102030 | 18 // http://crbug.com/102030 |
23 IN_PROC_BROWSER_TEST_F(LoadTimingObserverTest, FLAKY_CacheHitAfterRedirect) { | 19 IN_PROC_BROWSER_TEST_F(LoadTimingObserverTest, FLAKY_CacheHitAfterRedirect) { |
24 ASSERT_TRUE(test_server()->Start()); | 20 ASSERT_TRUE(test_server()->Start()); |
25 GURL cached_page = test_server()->GetURL("cachetime"); | 21 GURL cached_page = test_server()->GetURL("cachetime"); |
26 std::string redirect = "server-redirect?" + cached_page.spec(); | 22 std::string redirect = "server-redirect?" + cached_page.spec(); |
27 ui_test_utils::NavigateToURL(browser(), cached_page); | 23 ui_test_utils::NavigateToURL(browser(), cached_page); |
28 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(redirect)); | 24 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(redirect)); |
29 | 25 |
30 int response_start = 0; | 26 int response_start = 0; |
31 int response_end = 0; | 27 int response_end = 0; |
32 content::RenderViewHost* render_view_host = | 28 content::RenderViewHost* render_view_host = |
33 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); | 29 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); |
34 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 30 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
35 render_view_host, L"", | 31 render_view_host, L"", |
36 L"window.domAutomationController.send(" | 32 L"window.domAutomationController.send(" |
37 L"window.performance.timing.responseStart - " | 33 L"window.performance.timing.responseStart - " |
38 L"window.performance.timing.navigationStart)", &response_start)); | 34 L"window.performance.timing.navigationStart)", &response_start)); |
39 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 35 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
40 render_view_host, L"", | 36 render_view_host, L"", |
41 L"window.domAutomationController.send(" | 37 L"window.domAutomationController.send(" |
42 L"window.performance.timing.responseEnd - " | 38 L"window.performance.timing.responseEnd - " |
43 L"window.performance.timing.navigationStart)", &response_end)); | 39 L"window.performance.timing.navigationStart)", &response_end)); |
44 EXPECT_LE(response_start, response_end); | 40 EXPECT_LE(response_start, response_end); |
45 } | 41 } |
OLD | NEW |