OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/test/automation/tab_proxy.h" |
| 6 #include "chrome/test/ui/ui_test.h" |
| 7 #include "googleurl/src/gurl.h" |
| 8 #include "net/test/test_server.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 class LoadTimingObserverUITest : public UITest { |
| 12 public: |
| 13 LoadTimingObserverUITest() |
| 14 : http_server_(net::TestServer::TYPE_HTTP, FilePath()) { |
| 15 dom_automation_enabled_ = true; |
| 16 } |
| 17 |
| 18 protected: |
| 19 net::TestServer http_server_; |
| 20 }; |
| 21 |
| 22 TEST_F(LoadTimingObserverUITest, CacheHitAfterRedirect) { |
| 23 ASSERT_TRUE(http_server_.Start()); |
| 24 GURL cached_page = http_server_.GetURL("cachetime"); |
| 25 std::string redirect = "server-redirect?" + cached_page.spec(); |
| 26 NavigateToURL(cached_page); |
| 27 NavigateToURL(http_server_.GetURL(redirect)); |
| 28 scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); |
| 29 int response_start = 0; |
| 30 int response_end = 0; |
| 31 ASSERT_TRUE(tab_proxy->ExecuteAndExtractInt( |
| 32 L"", L"window.domAutomationController.send(" |
| 33 L"window.performance.timing.responseStart - " |
| 34 L"window.performance.timing.navigationStart)", &response_start)); |
| 35 ASSERT_TRUE(tab_proxy->ExecuteAndExtractInt( |
| 36 L"", L"window.domAutomationController.send(" |
| 37 L"window.performance.timing.responseEnd - " |
| 38 L"window.performance.timing.navigationStart)", &response_end)); |
| 39 EXPECT_LE(response_start, response_end); |
| 40 } |
OLD | NEW |