| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 13 #include "net/test/spawned_test_server/spawned_test_server.h" | |
| 14 | 13 |
| 15 class HostRulesTest : public InProcessBrowserTest { | 14 class HostRulesTest : public InProcessBrowserTest { |
| 16 protected: | 15 protected: |
| 17 HostRulesTest() {} | 16 HostRulesTest() {} |
| 18 | 17 |
| 19 void SetUpCommandLine(base::CommandLine* command_line) override { | 18 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 20 ASSERT_TRUE(test_server()->Start()); | 19 ASSERT_TRUE(embedded_test_server()->Start()); |
| 21 | 20 |
| 22 // Map all hosts to our local server. | 21 // Map all hosts to our local server. |
| 23 std::string host_rule( | 22 std::string host_rule("MAP * " + |
| 24 "MAP * " + test_server()->host_port_pair().ToString()); | 23 embedded_test_server()->host_port_pair().ToString()); |
| 25 command_line->AppendSwitchASCII(switches::kHostRules, host_rule); | 24 command_line->AppendSwitchASCII(switches::kHostRules, host_rule); |
| 26 // Use no proxy or otherwise this test will fail on a machine that has a | 25 // Use no proxy or otherwise this test will fail on a machine that has a |
| 27 // proxy configured. | 26 // proxy configured. |
| 28 command_line->AppendSwitch(switches::kNoProxyServer); | 27 command_line->AppendSwitch(switches::kNoProxyServer); |
| 29 } | 28 } |
| 30 | 29 |
| 31 private: | 30 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(HostRulesTest); | 31 DISALLOW_COPY_AND_ASSIGN(HostRulesTest); |
| 33 }; | 32 }; |
| 34 | 33 |
| 35 IN_PROC_BROWSER_TEST_F(HostRulesTest, TestMap) { | 34 IN_PROC_BROWSER_TEST_F(HostRulesTest, TestMap) { |
| 36 // Go to the empty page using www.google.com as the host. | 35 // Go to the empty page using www.google.com as the host. |
| 37 GURL local_url = test_server()->GetURL("files/empty.html"); | 36 GURL local_url = embedded_test_server()->GetURL("/empty.html"); |
| 38 GURL test_url(std::string("http://www.google.com") + local_url.path()); | 37 GURL test_url(std::string("http://www.google.com") + local_url.path()); |
| 39 ui_test_utils::NavigateToURL(browser(), test_url); | 38 ui_test_utils::NavigateToURL(browser(), test_url); |
| 40 | 39 |
| 41 std::string html; | 40 std::string html; |
| 42 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 41 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 43 browser()->tab_strip_model()->GetActiveWebContents(), | 42 browser()->tab_strip_model()->GetActiveWebContents(), |
| 44 "window.domAutomationController.send(document.body.outerHTML);", | 43 "window.domAutomationController.send(document.body.outerHTML);", |
| 45 &html)); | 44 &html)); |
| 46 | 45 |
| 47 EXPECT_STREQ("<body></body>", html.c_str()); | 46 EXPECT_STREQ("<body></body>", html.c_str()); |
| 48 } | 47 } |
| OLD | NEW |