| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "content/browser/child_process_launcher.h" | 6 #include "content/browser/child_process_launcher.h" |
| 7 #include "content/browser/renderer_host/render_process_host_impl.h" | 7 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 8 #include "content/public/browser/navigation_entry.h" | 8 #include "content/public/browser/navigation_entry.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Navigate once and simulate a process failing to spawn. | 58 // Navigate once and simulate a process failing to spawn. |
| 59 TestNavigationObserver nav_observer1(window->web_contents(), 1); | 59 TestNavigationObserver nav_observer1(window->web_contents(), 1); |
| 60 client = new MockChildProcessLauncherClient; | 60 client = new MockChildProcessLauncherClient; |
| 61 window->LoadURL(url); | 61 window->LoadURL(url); |
| 62 client->client_ = static_cast<RenderProcessHostImpl*>( | 62 client->client_ = static_cast<RenderProcessHostImpl*>( |
| 63 window->web_contents()->GetRenderProcessHost()) | 63 window->web_contents()->GetRenderProcessHost()) |
| 64 ->child_process_launcher_->ReplaceClientForTest(client); | 64 ->child_process_launcher_->ReplaceClientForTest(client); |
| 65 client->simulate_failure_ = true; | 65 client->simulate_failure_ = true; |
| 66 nav_observer1.Wait(); | 66 nav_observer1.Wait(); |
| 67 delete client; | 67 delete client; |
| 68 NavigationEntry* last_entry = | |
| 69 shell()->web_contents()->GetController().GetLastCommittedEntry(); | |
| 70 // Make sure we didn't navigate. | 68 // Make sure we didn't navigate. |
| 71 CHECK(!last_entry); | 69 CHECK(shell()->web_contents()->GetController().IsInitialNavigation()); |
| 72 | 70 |
| 73 // Navigate again and let the process spawn correctly. | 71 // Navigate again and let the process spawn correctly. |
| 74 TestNavigationObserver nav_observer2(window->web_contents(), 1); | 72 TestNavigationObserver nav_observer2(window->web_contents(), 1); |
| 75 window->LoadURL(url); | 73 window->LoadURL(url); |
| 76 nav_observer2.Wait(); | 74 nav_observer2.Wait(); |
| 77 last_entry = shell()->web_contents()->GetController().GetLastCommittedEntry(); | 75 NavigationEntry* last_entry = |
| 76 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 78 // Make sure that we navigated to the proper URL. | 77 // Make sure that we navigated to the proper URL. |
| 78 CHECK(!shell()->web_contents()->GetController().IsInitialNavigation()); |
| 79 CHECK(last_entry && last_entry->GetPageType() == PAGE_TYPE_NORMAL); | 79 CHECK(last_entry && last_entry->GetPageType() == PAGE_TYPE_NORMAL); |
| 80 CHECK(shell()->web_contents()->GetLastCommittedURL() == url); | 80 CHECK(shell()->web_contents()->GetLastCommittedURL() == url); |
| 81 | 81 |
| 82 // Navigate again, using the same renderer. | 82 // Navigate again, using the same renderer. |
| 83 url = GURL("data:text/html,dataurl"); | 83 url = GURL("data:text/html,dataurl"); |
| 84 TestNavigationObserver nav_observer3(window->web_contents(), 1); | 84 TestNavigationObserver nav_observer3(window->web_contents(), 1); |
| 85 window->LoadURL(url); | 85 window->LoadURL(url); |
| 86 nav_observer3.Wait(); | 86 nav_observer3.Wait(); |
| 87 last_entry = shell()->web_contents()->GetController().GetLastCommittedEntry(); | 87 last_entry = shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 88 // Make sure that we navigated to the proper URL. | 88 // Make sure that we navigated to the proper URL. |
| 89 CHECK(last_entry && last_entry->GetPageType() == PAGE_TYPE_NORMAL); | 89 CHECK(last_entry && last_entry->GetPageType() == PAGE_TYPE_NORMAL); |
| 90 CHECK(shell()->web_contents()->GetLastCommittedURL() == url); | 90 CHECK(shell()->web_contents()->GetLastCommittedURL() == url); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace content | 93 } // namespace content |
| OLD | NEW |