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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/loadtimes_extension_bindings.cc ('k') | chrome/renderer/page_load_histograms.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a47ca9d129659a5ad504a51396dee0dffc61fa9e
--- /dev/null
+++ b/chrome/renderer/loadtimes_extension_bindings_uitest.cc
@@ -0,0 +1,73 @@
+// 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) {
+ // TODO(simonjam): There's a race on whether or not first paint is populated
+ // before we read them. We ought to test that too. Until the race is fixed,
+ // zero it out so the test is stable.
+ ASSERT_TRUE(tab_proxy->ExecuteJavaScript(
+ "window.before.firstPaintAfterLoadTime = 0;"
+ "window.before.firstPaintTime = 0;"
+ "window.after.firstPaintAfterLoadTime = 0;"
+ "window.after.firstPaintTime = 0;"));
+
+ 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();
+ ASSERT_TRUE(tab_proxy.get());
+ 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();
+ ASSERT_TRUE(tab_proxy.get());
+ 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());
+}
« 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