Chromium Code Reviews| 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 LoadtimesExtensionBindingsUITest : public UITest { | |
| 12 public: | |
| 13 LoadtimesExtensionBindingsUITest() | |
| 14 : http_server_(net::TestServer::TYPE_HTTP, FilePath()) { | |
| 15 dom_automation_enabled_ = true; | |
| 16 } | |
| 17 | |
| 18 void CompareBeforeAndAfter(TabProxy* tab_proxy) { | |
| 19 std::wstring before; | |
| 20 std::wstring after; | |
| 21 ASSERT_TRUE(tab_proxy->ExecuteAndExtractString( | |
| 22 L"", L"window.domAutomationController.send(" | |
| 23 L"JSON.stringify(before))", &before)); | |
| 24 ASSERT_TRUE(tab_proxy->ExecuteAndExtractString( | |
| 25 L"", L"window.domAutomationController.send(" | |
| 26 L"JSON.stringify(after))", &after)); | |
| 27 EXPECT_EQ(before, after); | |
| 28 } | |
| 29 | |
| 30 protected: | |
| 31 net::TestServer http_server_; | |
| 32 }; | |
| 33 | |
| 34 TEST_F(LoadtimesExtensionBindingsUITest, | |
| 35 LoadTimesSameAfterClientInDocNavigation) { | |
| 36 ASSERT_TRUE(http_server_.Start()); | |
| 37 GURL plain_url = http_server_.GetURL("blank"); | |
| 38 NavigateToURL(plain_url); | |
| 39 scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); | |
|
Paweł Hajdan Jr.
2011/10/28 08:29:34
ASSERT_TRUE on this or you'll crash randomly.
| |
| 40 ASSERT_TRUE(tab_proxy->ExecuteJavaScript( | |
| 41 "window.before = window.chrome.loadTimes()")); | |
| 42 ASSERT_TRUE(tab_proxy->ExecuteJavaScript( | |
| 43 "window.location.href = window.location + \"#\"")); | |
| 44 ASSERT_TRUE(tab_proxy->ExecuteJavaScript( | |
| 45 "window.after = window.chrome.loadTimes()")); | |
| 46 CompareBeforeAndAfter(tab_proxy.get()); | |
| 47 } | |
| 48 | |
| 49 TEST_F(LoadtimesExtensionBindingsUITest, | |
| 50 LoadTimesSameAfterUserInDocNavigation) { | |
| 51 ASSERT_TRUE(http_server_.Start()); | |
| 52 GURL plain_url = http_server_.GetURL("blank"); | |
| 53 GURL hash_url(plain_url.spec() + "#"); | |
| 54 NavigateToURL(plain_url); | |
| 55 scoped_refptr<TabProxy> tab_proxy = GetActiveTab(); | |
|
Paweł Hajdan Jr.
2011/10/28 08:29:34
Same here.
| |
| 56 ASSERT_TRUE(tab_proxy->ExecuteJavaScript( | |
| 57 "window.before = window.chrome.loadTimes()")); | |
| 58 NavigateToURL(hash_url); | |
| 59 ASSERT_TRUE(tab_proxy->ExecuteJavaScript( | |
| 60 "window.after = window.chrome.loadTimes()")); | |
| 61 CompareBeforeAndAfter(tab_proxy.get()); | |
| 62 } | |
| OLD | NEW |