Chromium Code Reviews| Index: chrome/renderer/loadtimes_extension_bindings_uitest.cc |
| diff --git a/chrome/renderer/loadtimes_extension_bindings_uitest.cc b/chrome/renderer/loadtimes_extension_bindings_uitest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2add6b508d04148aa85b5c02e6bbec83fae9fef3 |
| --- /dev/null |
| +++ b/chrome/renderer/loadtimes_extension_bindings_uitest.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/test/automation/tab_proxy.h" |
| +#include "chrome/test/ui/ui_test.h" |
| +#include "googleurl/src/gurl.h" |
| +#include "net/test/test_server.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +class LoadtimesExtensionBindingsUITest : public UITest { |
| + public: |
| + LoadtimesExtensionBindingsUITest() |
| + : http_server_(net::TestServer::TYPE_HTTP, FilePath()) { |
| + dom_automation_enabled_ = true; |
| + } |
| + |
| + void CompareBeforeAndAfter(TabProxy* tab_proxy) { |
| + std::wstring before; |
| + std::wstring after; |
| + ASSERT_TRUE(tab_proxy->ExecuteAndExtractString( |
| + L"", L"window.domAutomationController.send(" |
| + L"JSON.stringify(before))", &before)); |
| + ASSERT_TRUE(tab_proxy->ExecuteAndExtractString( |
| + L"", L"window.domAutomationController.send(" |
| + L"JSON.stringify(after))", &after)); |
| + EXPECT_EQ(before, after); |
| + } |
| + |
| + protected: |
| + net::TestServer http_server_; |
| +}; |
| + |
| +TEST_F(LoadtimesExtensionBindingsUITest, |
| + LoadTimesSameAfterClientInDocNavigation) { |
| + ASSERT_TRUE(http_server_.Start()); |
| + GURL plain_url = http_server_.GetURL("blank"); |
| + NavigateToURL(plain_url); |
| + scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); |
|
Paweł Hajdan Jr.
2011/10/28 08:29:34
ASSERT_TRUE on this or you'll crash randomly.
|
| + ASSERT_TRUE(tab_proxy->ExecuteJavaScript( |
| + "window.before = window.chrome.loadTimes()")); |
| + ASSERT_TRUE(tab_proxy->ExecuteJavaScript( |
| + "window.location.href = window.location + \"#\"")); |
| + ASSERT_TRUE(tab_proxy->ExecuteJavaScript( |
| + "window.after = window.chrome.loadTimes()")); |
| + CompareBeforeAndAfter(tab_proxy.get()); |
| +} |
| + |
| +TEST_F(LoadtimesExtensionBindingsUITest, |
| + LoadTimesSameAfterUserInDocNavigation) { |
| + ASSERT_TRUE(http_server_.Start()); |
| + GURL plain_url = http_server_.GetURL("blank"); |
| + GURL hash_url(plain_url.spec() + "#"); |
| + NavigateToURL(plain_url); |
| + scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); |
|
Paweł Hajdan Jr.
2011/10/28 08:29:34
Same here.
|
| + ASSERT_TRUE(tab_proxy->ExecuteJavaScript( |
| + "window.before = window.chrome.loadTimes()")); |
| + NavigateToURL(hash_url); |
| + ASSERT_TRUE(tab_proxy->ExecuteJavaScript( |
| + "window.after = window.chrome.loadTimes()")); |
| + CompareBeforeAndAfter(tab_proxy.get()); |
| +} |