[M85 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / chrome / browser / loadtimes_extension_bindings_browsertest.cc
1 // Copyright (c) 2012 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/browser/ui/browser.h"
6 #include "chrome/browser/ui/tabs/tab_strip_model.h"
7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "chrome/test/base/ui_test_utils.h"
9 #include "content/public/browser/web_contents.h"
10 #include "content/public/test/browser_test.h"
11 #include "content/public/test/browser_test_utils.h"
12 #include "net/test/embedded_test_server/embedded_test_server.h"
13
14 class LoadtimesExtensionBindingsTest : public InProcessBrowserTest {
15  public:
16   LoadtimesExtensionBindingsTest() {}
17
18   void CompareBeforeAndAfter() {
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     content::WebContents* contents =
23         browser()->tab_strip_model()->GetActiveWebContents();
24     ASSERT_TRUE(content::ExecuteScript(
25         contents,
26         "window.before.firstPaintAfterLoadTime = 0;"
27         "window.before.firstPaintTime = 0;"
28         "window.after.firstPaintAfterLoadTime = 0;"
29         "window.after.firstPaintTime = 0;"));
30
31     std::string before;
32     std::string after;
33     ASSERT_TRUE(content::ExecuteScriptAndExtractString(
34         contents,
35         "window.domAutomationController.send("
36         "    JSON.stringify(before))",
37         &before));
38     ASSERT_TRUE(content::ExecuteScriptAndExtractString(
39         contents,
40         "window.domAutomationController.send("
41         "    JSON.stringify(after))",
42         &after));
43     EXPECT_EQ(before, after);
44   }
45 };
46
47 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest,
48                        LoadTimesSameAfterClientInDocNavigation) {
49   ASSERT_TRUE(embedded_test_server()->Start());
50   GURL plain_url = embedded_test_server()->GetURL("/simple.html");
51   ui_test_utils::NavigateToURL(browser(), plain_url);
52   content::WebContents* contents =
53       browser()->tab_strip_model()->GetActiveWebContents();
54   ASSERT_TRUE(content::ExecuteScript(
55       contents, "window.before = window.chrome.loadTimes()"));
56   ASSERT_TRUE(content::ExecuteScript(
57       contents, "window.location.href = window.location + \"#\""));
58   ASSERT_TRUE(content::ExecuteScript(
59       contents, "window.after = window.chrome.loadTimes()"));
60   CompareBeforeAndAfter();
61 }
62
63 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest,
64                        LoadTimesSameAfterUserInDocNavigation) {
65   ASSERT_TRUE(embedded_test_server()->Start());
66   GURL plain_url = embedded_test_server()->GetURL("/simple.html");
67   GURL hash_url(plain_url.spec() + "#");
68   ui_test_utils::NavigateToURL(browser(), plain_url);
69   content::WebContents* contents =
70       browser()->tab_strip_model()->GetActiveWebContents();
71   ASSERT_TRUE(content::ExecuteScript(
72       contents, "window.before = window.chrome.loadTimes()"));
73   ui_test_utils::NavigateToURL(browser(), hash_url);
74   ASSERT_TRUE(content::ExecuteScript(
75       contents, "window.after = window.chrome.loadTimes()"));
76   CompareBeforeAndAfter();
77 }