| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/basictypes.h" | 5 #include <stdint.h> |
| 6 |
| 6 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 7 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 11 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 12 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
| 13 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
| 14 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
| 15 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 RenderFrameHost* initial_rfh = | 132 RenderFrameHost* initial_rfh = |
| 132 static_cast<WebContentsImpl*>(shell()->web_contents()) | 133 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 133 ->GetFrameTree()->root()->current_frame_host(); | 134 ->GetFrameTree()->root()->current_frame_host(); |
| 134 | 135 |
| 135 // Simulate clicking on a cross-site link. | 136 // Simulate clicking on a cross-site link. |
| 136 { | 137 { |
| 137 TestNavigationObserver observer(shell()->web_contents()); | 138 TestNavigationObserver observer(shell()->web_contents()); |
| 138 const char kReplacePortNumber[] = | 139 const char kReplacePortNumber[] = |
| 139 "window.domAutomationController.send(setPortNumber(%d));"; | 140 "window.domAutomationController.send(setPortNumber(%d));"; |
| 140 uint16 port_number = embedded_test_server()->port(); | 141 uint16_t port_number = embedded_test_server()->port(); |
| 141 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 142 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
| 142 bool success = false; | 143 bool success = false; |
| 143 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 144 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 144 shell()->web_contents(), | 145 shell()->web_contents(), |
| 145 base::StringPrintf(kReplacePortNumber, port_number), | 146 base::StringPrintf(kReplacePortNumber, port_number), |
| 146 &success)); | 147 &success)); |
| 147 success = false; | 148 success = false; |
| 148 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 149 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 149 shell()->web_contents(), | 150 shell()->web_contents(), |
| 150 "window.domAutomationController.send(clickCrossSiteLink());", | 151 "window.domAutomationController.send(clickCrossSiteLink());", |
| (...skipping 30 matching lines...) Expand all Loading... |
| 181 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); | 182 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); |
| 182 NavigateToURL(shell(), error_url); | 183 NavigateToURL(shell(), error_url); |
| 183 EXPECT_EQ(error_url, observer.last_navigation_url()); | 184 EXPECT_EQ(error_url, observer.last_navigation_url()); |
| 184 NavigationEntry* entry = | 185 NavigationEntry* entry = |
| 185 shell()->web_contents()->GetController().GetLastCommittedEntry(); | 186 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 186 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); | 187 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); |
| 187 } | 188 } |
| 188 } | 189 } |
| 189 | 190 |
| 190 } // namespace content | 191 } // namespace content |
| OLD | NEW |