| 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/test/automation/tab_proxy.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 #include "chrome/test/ui/ui_test.h" | 6 #include "chrome/test/base/in_process_browser_test.h" |
| 7 #include "chrome/test/base/ui_test_utils.h" |
| 8 #include "content/public/browser/web_contents.h" |
| 7 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 8 #include "net/test/test_server.h" | 10 #include "net/test/test_server.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | 11 |
| 11 class LoadTimingObserverUITest : public UITest { | 12 class LoadTimingObserverTest : public InProcessBrowserTest { |
| 12 public: | 13 public: |
| 13 LoadTimingObserverUITest() | 14 LoadTimingObserverTest() { |
| 14 : http_server_(net::TestServer::TYPE_HTTP, | 15 EnableDOMAutomation(); |
| 15 net::TestServer::kLocalhost, | |
| 16 FilePath()) { | |
| 17 dom_automation_enabled_ = true; | |
| 18 } | 16 } |
| 19 | 17 |
| 20 protected: | 18 protected: |
| 21 net::TestServer http_server_; | |
| 22 }; | 19 }; |
| 23 | 20 |
| 24 // http://crbug.com/102030 | 21 // http://crbug.com/102030 |
| 25 // http://crbug.com/114390 | 22 IN_PROC_BROWSER_TEST_F(LoadTimingObserverTest, CacheHitAfterRedirect) { |
| 26 TEST_F(LoadTimingObserverUITest, DISABLED_CacheHitAfterRedirect) { | 23 ASSERT_TRUE(test_server()->Start()); |
| 27 ASSERT_TRUE(http_server_.Start()); | 24 GURL cached_page = test_server()->GetURL("cachetime"); |
| 28 GURL cached_page = http_server_.GetURL("cachetime"); | |
| 29 std::string redirect = "server-redirect?" + cached_page.spec(); | 25 std::string redirect = "server-redirect?" + cached_page.spec(); |
| 30 NavigateToURL(cached_page); | 26 ui_test_utils::NavigateToURL(browser(), cached_page); |
| 31 NavigateToURL(http_server_.GetURL(redirect)); | 27 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(redirect)); |
| 32 scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); | 28 |
| 33 int response_start = 0; | 29 int response_start = 0; |
| 34 int response_end = 0; | 30 int response_end = 0; |
| 35 ASSERT_TRUE(tab_proxy->ExecuteAndExtractInt( | 31 content::RenderViewHost* render_view_host = |
| 36 L"", L"window.domAutomationController.send(" | 32 browser()->GetSelectedWebContents()->GetRenderViewHost(); |
| 33 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
| 34 render_view_host, L"", |
| 35 L"window.domAutomationController.send(" |
| 37 L"window.performance.timing.responseStart - " | 36 L"window.performance.timing.responseStart - " |
| 38 L"window.performance.timing.navigationStart)", &response_start)); | 37 L"window.performance.timing.navigationStart)", &response_start)); |
| 39 ASSERT_TRUE(tab_proxy->ExecuteAndExtractInt( | 38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
| 40 L"", L"window.domAutomationController.send(" | 39 render_view_host, L"", |
| 40 L"window.domAutomationController.send(" |
| 41 L"window.performance.timing.responseEnd - " | 41 L"window.performance.timing.responseEnd - " |
| 42 L"window.performance.timing.navigationStart)", &response_end)); | 42 L"window.performance.timing.navigationStart)", &response_end)); |
| 43 EXPECT_LE(response_start, response_end); | 43 EXPECT_LE(response_start, response_end); |
| 44 } | 44 } |
| OLD | NEW |