Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/renderer/loadtimes_extension_bindings_uitest.cc

Issue 8404018: chrome.loadTimes() shouldn't be affected by in-document navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/loadtimes_extension_bindings.cc ('k') | chrome/renderer/page_load_histograms.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // TODO(simonjam): There's a race on whether or not first paint is populated
20 // before we read them. We ought to test that too. Until the race is fixed,
21 // zero it out so the test is stable.
22 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
23 "window.before.firstPaintAfterLoadTime = 0;"
24 "window.before.firstPaintTime = 0;"
25 "window.after.firstPaintAfterLoadTime = 0;"
26 "window.after.firstPaintTime = 0;"));
27
28 std::wstring before;
29 std::wstring after;
30 ASSERT_TRUE(tab_proxy->ExecuteAndExtractString(
31 L"", L"window.domAutomationController.send("
32 L"JSON.stringify(before))", &before));
33 ASSERT_TRUE(tab_proxy->ExecuteAndExtractString(
34 L"", L"window.domAutomationController.send("
35 L"JSON.stringify(after))", &after));
36 EXPECT_EQ(before, after);
37 }
38
39 protected:
40 net::TestServer http_server_;
41 };
42
43 TEST_F(LoadtimesExtensionBindingsUITest,
44 LoadTimesSameAfterClientInDocNavigation) {
45 ASSERT_TRUE(http_server_.Start());
46 GURL plain_url = http_server_.GetURL("blank");
47 NavigateToURL(plain_url);
48 scoped_refptr<TabProxy> tab_proxy = GetActiveTab();
49 ASSERT_TRUE(tab_proxy.get());
50 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
51 "window.before = window.chrome.loadTimes()"));
52 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
53 "window.location.href = window.location + \"#\""));
54 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
55 "window.after = window.chrome.loadTimes()"));
56 CompareBeforeAndAfter(tab_proxy.get());
57 }
58
59 TEST_F(LoadtimesExtensionBindingsUITest,
60 LoadTimesSameAfterUserInDocNavigation) {
61 ASSERT_TRUE(http_server_.Start());
62 GURL plain_url = http_server_.GetURL("blank");
63 GURL hash_url(plain_url.spec() + "#");
64 NavigateToURL(plain_url);
65 scoped_refptr<TabProxy> tab_proxy = GetActiveTab();
66 ASSERT_TRUE(tab_proxy.get());
67 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
68 "window.before = window.chrome.loadTimes()"));
69 NavigateToURL(hash_url);
70 ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
71 "window.after = window.chrome.loadTimes()"));
72 CompareBeforeAndAfter(tab_proxy.get());
73 }
OLDNEW
« no previous file with comments | « chrome/renderer/loadtimes_extension_bindings.cc ('k') | chrome/renderer/page_load_histograms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698