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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2118 // This LoadURL ends up purging the pending entry, which is why this is | 2118 // This LoadURL ends up purging the pending entry, which is why this is |
2119 // tricky. | 2119 // tricky. |
2120 EXPECT_EQ(nullptr, controller.GetPendingEntry()); | 2120 EXPECT_EQ(nullptr, controller.GetPendingEntry()); |
2121 shell()->web_contents()->Stop(); | 2121 shell()->web_contents()->Stop(); |
2122 watcher.Wait(); | 2122 watcher.Wait(); |
2123 } | 2123 } |
2124 | 2124 |
2125 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2125 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
2126 } | 2126 } |
2127 | 2127 |
2128 namespace { | |
2129 | |
2130 class RenderProcessKilledObserver : public WebContentsObserver { | |
2131 public: | |
2132 RenderProcessKilledObserver(WebContents* web_contents) | |
2133 : WebContentsObserver(web_contents) {} | |
2134 ~RenderProcessKilledObserver() override {} | |
2135 | |
2136 void RenderProcessGone(base::TerminationStatus status) override { | |
2137 CHECK_NE(status, | |
2138 base::TerminationStatus::TERMINATION_STATUS_PROCESS_WAS_KILLED); | |
2139 } | |
2140 }; | |
2141 | |
2142 } | |
2143 | |
2144 // This tests for a race in ReloadOriginalRequest. Not crashing means that the | |
2145 // test is successful. | |
2146 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ReloadOriginalRequest) { | |
2147 GURL url(embedded_test_server()->GetURL( | |
2148 "/navigation_controller/simple_page_1.html")); | |
2149 NavigateToURL(shell(), url); | |
2150 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
2151 ->GetFrameTree() | |
2152 ->root(); | |
2153 RenderProcessKilledObserver kill_observer(shell()->web_contents()); | |
2154 | |
2155 for (int i = 0; i < 1000; i++) { | |
Charlie Reis
2015/07/06 20:56:39
This doesn't seem like a great strategy for a test
lfg
2015/07/08 22:09:28
Sorry, this was just a test because I wasn't sure
| |
2156 EXPECT_FALSE(shell()->web_contents()->IsLoading()); | |
2157 NavigateToURL(shell(), url); | |
2158 | |
2159 // Redirect. | |
2160 { | |
2161 GURL foo_url(embedded_test_server()->GetURL( | |
2162 "foo.com", "/navigation_controller/simple_page_1.html")); | |
2163 std::string script = "location.replace('" + foo_url.spec() + "');"; | |
2164 FrameNavigateParamsCapturer capturer(root); | |
2165 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | |
2166 capturer.Wait(); | |
2167 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | |
2168 capturer.params().transition); | |
2169 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | |
2170 } | |
2171 | |
2172 // Modify an entry in the session history and reload the original request. | |
2173 { | |
2174 std::string script = | |
2175 "setTimeout(function() { history.replaceState({}, '', 'foo') }, 0);"; | |
2176 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); | |
2177 EXPECT_FALSE(shell()->web_contents()->IsLoading()); | |
2178 shell()->web_contents()->GetController().ReloadOriginalRequestURL(false); | |
2179 EXPECT_TRUE(shell()->web_contents()->IsLoading()); | |
Charlie Reis
2015/07/06 20:56:39
It seems like we should be able to verify that the
lfg
2015/07/08 22:09:28
We can't, because we're not running the message lo
Charlie Reis
2015/07/08 23:23:37
Hmm, ok. It's unfortunate, since that's the part
lfg
2015/07/14 18:58:31
I've changed the test to look at the commits inste
| |
2180 // Wait until there's no more navigations. | |
Charlie Reis
2015/07/06 20:56:39
nit: Blank line above.
lfg
2015/07/08 22:09:28
Done.
| |
2181 while (shell()->web_contents()->GetLastCommittedURL() != url) | |
2182 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | |
2183 } | |
2184 } | |
2185 } | |
2186 | |
2187 | |
2128 } // namespace content | 2188 } // namespace content |
OLD | NEW |