app_list: Re-enable people search.
[chromium-blink-merge.git] / chrome / browser / extensions / api / web_navigation / web_navigation_apitest.cc
blob3d691e35fb71cea76109e460161d8d5a648e2a2e
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.
5 #include <list>
6 #include <set>
8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_browser_main.h"
17 #include "chrome/browser/chrome_browser_main_extra_parts.h"
18 #include "chrome/browser/chrome_content_browser_client.h"
19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/download/download_browsertest.h"
21 #include "chrome/browser/download/download_prefs.h"
22 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
23 #include "chrome/browser/extensions/extension_apitest.h"
24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
27 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h"
28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/tabs/tab_strip_model.h"
30 #include "chrome/test/base/ui_test_utils.h"
31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/resource_controller.h"
36 #include "content/public/browser/resource_dispatcher_host.h"
37 #include "content/public/browser/resource_throttle.h"
38 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/context_menu_params.h"
40 #include "content/public/common/resource_type.h"
41 #include "content/public/common/url_constants.h"
42 #include "content/public/test/browser_test_utils.h"
43 #include "extensions/browser/extension_system.h"
44 #include "extensions/common/switches.h"
45 #include "extensions/test/result_catcher.h"
46 #include "net/dns/mock_host_resolver.h"
47 #include "net/test/embedded_test_server/embedded_test_server.h"
48 #include "third_party/WebKit/public/web/WebContextMenuData.h"
49 #include "third_party/WebKit/public/web/WebInputEvent.h"
51 using content::ResourceType;
52 using content::WebContents;
54 namespace extensions {
56 namespace {
58 // This class can defer requests for arbitrary URLs.
59 class TestNavigationListener
60 : public base::RefCountedThreadSafe<TestNavigationListener> {
61 public:
62 TestNavigationListener() {}
64 // Add |url| to the set of URLs we should delay.
65 void DelayRequestsForURL(const GURL& url) {
66 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
67 content::BrowserThread::PostTask(
68 content::BrowserThread::IO,
69 FROM_HERE,
70 base::Bind(&TestNavigationListener::DelayRequestsForURL, this, url));
71 return;
73 urls_to_delay_.insert(url);
76 // Resume all deferred requests.
77 void ResumeAll() {
78 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
79 content::BrowserThread::PostTask(
80 content::BrowserThread::IO,
81 FROM_HERE,
82 base::Bind(&TestNavigationListener::ResumeAll, this));
83 return;
85 WeakThrottleList::const_iterator it;
86 for (it = throttles_.begin(); it != throttles_.end(); ++it) {
87 if (it->get())
88 (*it)->Resume();
90 throttles_.clear();
93 // Constructs a ResourceThrottle if the request for |url| should be held.
95 // Needs to be invoked on the IO thread.
96 content::ResourceThrottle* CreateResourceThrottle(
97 const GURL& url,
98 ResourceType resource_type) {
99 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
100 if (urls_to_delay_.find(url) == urls_to_delay_.end())
101 return NULL;
103 Throttle* throttle = new Throttle();
104 throttles_.push_back(throttle->AsWeakPtr());
105 return throttle;
108 private:
109 friend class base::RefCountedThreadSafe<TestNavigationListener>;
111 virtual ~TestNavigationListener() {}
113 // Stores a throttle per URL request that we have delayed.
114 class Throttle : public content::ResourceThrottle,
115 public base::SupportsWeakPtr<Throttle> {
116 public:
117 void Resume() {
118 controller()->Resume();
121 // content::ResourceThrottle implementation.
122 void WillStartRequest(bool* defer) override { *defer = true; }
124 const char* GetNameForLogging() const override {
125 return "TestNavigationListener::Throttle";
128 typedef base::WeakPtr<Throttle> WeakThrottle;
129 typedef std::list<WeakThrottle> WeakThrottleList;
130 WeakThrottleList throttles_;
132 // The set of URLs to be delayed.
133 std::set<GURL> urls_to_delay_;
135 DISALLOW_COPY_AND_ASSIGN(TestNavigationListener);
138 // Waits for a WC to be created. Once it starts loading |delay_url| (after at
139 // least the first navigation has committed), it delays the load, executes
140 // |script| in the last committed RVH and resumes the load when a URL ending in
141 // |until_url_suffix| commits. This class expects |script| to trigger the load
142 // of an URL ending in |until_url_suffix|.
143 class DelayLoadStartAndExecuteJavascript
144 : public content::NotificationObserver,
145 public content::WebContentsObserver {
146 public:
147 DelayLoadStartAndExecuteJavascript(
148 TestNavigationListener* test_navigation_listener,
149 const GURL& delay_url,
150 const std::string& script,
151 const std::string& until_url_suffix)
152 : content::WebContentsObserver(),
153 test_navigation_listener_(test_navigation_listener),
154 delay_url_(delay_url),
155 until_url_suffix_(until_url_suffix),
156 script_(script),
157 script_was_executed_(false),
158 rvh_(NULL) {
159 registrar_.Add(this,
160 chrome::NOTIFICATION_TAB_ADDED,
161 content::NotificationService::AllSources());
162 test_navigation_listener_->DelayRequestsForURL(delay_url_);
164 ~DelayLoadStartAndExecuteJavascript() override {}
166 void Observe(int type,
167 const content::NotificationSource& source,
168 const content::NotificationDetails& details) override {
169 if (type != chrome::NOTIFICATION_TAB_ADDED) {
170 NOTREACHED();
171 return;
173 content::WebContentsObserver::Observe(
174 content::Details<content::WebContents>(details).ptr());
175 registrar_.RemoveAll();
178 void DidStartProvisionalLoadForFrame(
179 content::RenderFrameHost* render_frame_host,
180 const GURL& validated_url,
181 bool is_error_page,
182 bool is_iframe_srcdoc) override {
183 if (validated_url != delay_url_ || !rvh_)
184 return;
186 rvh_->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(script_));
187 script_was_executed_ = true;
190 void DidCommitProvisionalLoadForFrame(
191 content::RenderFrameHost* render_frame_host,
192 const GURL& url,
193 ui::PageTransition transition_type) override {
194 if (script_was_executed_ && EndsWith(url.spec(), until_url_suffix_, true)) {
195 content::WebContentsObserver::Observe(NULL);
196 test_navigation_listener_->ResumeAll();
198 rvh_ = render_frame_host->GetRenderViewHost();
201 private:
202 content::NotificationRegistrar registrar_;
204 scoped_refptr<TestNavigationListener> test_navigation_listener_;
206 GURL delay_url_;
207 std::string until_url_suffix_;
208 std::string script_;
209 bool script_was_executed_;
210 content::RenderViewHost* rvh_;
212 DISALLOW_COPY_AND_ASSIGN(DelayLoadStartAndExecuteJavascript);
215 // A ResourceDispatcherHostDelegate that adds a TestNavigationObserver.
216 class TestResourceDispatcherHostDelegate
217 : public ChromeResourceDispatcherHostDelegate {
218 public:
219 TestResourceDispatcherHostDelegate(
220 prerender::PrerenderTracker* prerender_tracker,
221 TestNavigationListener* test_navigation_listener)
222 : ChromeResourceDispatcherHostDelegate(prerender_tracker),
223 test_navigation_listener_(test_navigation_listener) {
225 ~TestResourceDispatcherHostDelegate() override {}
227 void RequestBeginning(
228 net::URLRequest* request,
229 content::ResourceContext* resource_context,
230 content::AppCacheService* appcache_service,
231 ResourceType resource_type,
232 ScopedVector<content::ResourceThrottle>* throttles) override {
233 ChromeResourceDispatcherHostDelegate::RequestBeginning(
234 request,
235 resource_context,
236 appcache_service,
237 resource_type,
238 throttles);
239 content::ResourceThrottle* throttle =
240 test_navigation_listener_->CreateResourceThrottle(request->url(),
241 resource_type);
242 if (throttle)
243 throttles->push_back(throttle);
246 private:
247 scoped_refptr<TestNavigationListener> test_navigation_listener_;
249 DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
252 } // namespace
254 class WebNavigationApiTest : public ExtensionApiTest {
255 public:
256 WebNavigationApiTest() {}
257 ~WebNavigationApiTest() override {}
259 void SetUpInProcessBrowserTestFixture() override {
260 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
262 FrameNavigationState::set_allow_extension_scheme(true);
264 base::CommandLine::ForCurrentProcess()->AppendSwitch(
265 switches::kAllowLegacyExtensionManifests);
267 host_resolver()->AddRule("*", "127.0.0.1");
270 void SetUpOnMainThread() override {
271 ExtensionApiTest::SetUpOnMainThread();
272 test_navigation_listener_ = new TestNavigationListener();
273 resource_dispatcher_host_delegate_.reset(
274 new TestResourceDispatcherHostDelegate(
275 g_browser_process->prerender_tracker(),
276 test_navigation_listener_.get()));
277 content::ResourceDispatcherHost::Get()->SetDelegate(
278 resource_dispatcher_host_delegate_.get());
281 TestNavigationListener* test_navigation_listener() {
282 return test_navigation_listener_.get();
285 private:
286 scoped_refptr<TestNavigationListener> test_navigation_listener_;
287 scoped_ptr<TestResourceDispatcherHostDelegate>
288 resource_dispatcher_host_delegate_;
290 DISALLOW_COPY_AND_ASSIGN(WebNavigationApiTest);
293 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Api) {
294 ASSERT_TRUE(StartEmbeddedTestServer());
295 ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
298 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, GetFrame) {
299 ASSERT_TRUE(StartEmbeddedTestServer());
300 ASSERT_TRUE(RunExtensionTest("webnavigation/getFrame")) << message_;
303 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ClientRedirect) {
304 ASSERT_TRUE(StartEmbeddedTestServer());
305 ASSERT_TRUE(RunExtensionTest("webnavigation/clientRedirect"))
306 << message_;
309 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirect) {
310 ASSERT_TRUE(StartEmbeddedTestServer());
311 ASSERT_TRUE(RunExtensionTest("webnavigation/serverRedirect"))
312 << message_;
315 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Download) {
316 base::ScopedTempDir download_directory;
317 ASSERT_TRUE(download_directory.CreateUniqueTempDir());
318 DownloadPrefs* download_prefs =
319 DownloadPrefs::FromBrowserContext(browser()->profile());
320 download_prefs->SetDownloadPath(download_directory.path());
322 DownloadTestObserverNotInProgress download_observer(
323 content::BrowserContext::GetDownloadManager(profile()), 1);
324 download_observer.StartObserving();
325 ASSERT_TRUE(StartEmbeddedTestServer());
326 ASSERT_TRUE(RunExtensionTest("webnavigation/download"))
327 << message_;
328 download_observer.WaitForFinished();
331 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirectSingleProcess) {
332 ASSERT_TRUE(StartEmbeddedTestServer());
334 // Set max renderers to 1 to force running out of processes.
335 content::RenderProcessHost::SetMaxRendererProcessCount(1);
337 // Wait for the extension to set itself up and return control to us.
338 ASSERT_TRUE(
339 RunExtensionTest("webnavigation/serverRedirectSingleProcess"))
340 << message_;
342 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
343 content::WaitForLoadStop(tab);
345 ResultCatcher catcher;
346 GURL url(base::StringPrintf(
347 "http://www.a.com:%u/"
348 "extensions/api_test/webnavigation/serverRedirectSingleProcess/a.html",
349 embedded_test_server()->port()));
351 ui_test_utils::NavigateToURL(browser(), url);
353 url = GURL(base::StringPrintf(
354 "http://www.b.com:%u/server-redirect?http://www.b.com:%u/",
355 embedded_test_server()->port(),
356 embedded_test_server()->port()));
358 ui_test_utils::NavigateToURL(browser(), url);
360 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
363 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ForwardBack) {
364 ASSERT_TRUE(StartEmbeddedTestServer());
365 ASSERT_TRUE(RunExtensionTest("webnavigation/forwardBack")) << message_;
368 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, IFrame) {
369 ASSERT_TRUE(StartEmbeddedTestServer());
370 ASSERT_TRUE(RunExtensionTest("webnavigation/iframe")) << message_;
373 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SrcDoc) {
374 ASSERT_TRUE(StartEmbeddedTestServer());
375 ASSERT_TRUE(RunExtensionTest("webnavigation/srcdoc")) << message_;
378 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, OpenTab) {
379 ASSERT_TRUE(StartEmbeddedTestServer());
380 ASSERT_TRUE(RunExtensionTest("webnavigation/openTab")) << message_;
383 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ReferenceFragment) {
384 ASSERT_TRUE(StartEmbeddedTestServer());
385 ASSERT_TRUE(RunExtensionTest("webnavigation/referenceFragment"))
386 << message_;
389 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SimpleLoad) {
390 ASSERT_TRUE(StartEmbeddedTestServer());
391 ASSERT_TRUE(RunExtensionTest("webnavigation/simpleLoad")) << message_;
394 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Failures) {
395 ASSERT_TRUE(StartEmbeddedTestServer());
396 ASSERT_TRUE(RunExtensionTest("webnavigation/failures")) << message_;
399 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) {
400 ASSERT_TRUE(StartEmbeddedTestServer());
401 ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_;
404 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) {
405 ASSERT_TRUE(StartEmbeddedTestServer());
407 // Wait for the extension to set itself up and return control to us.
408 ASSERT_TRUE(RunExtensionTest("webnavigation/userAction")) << message_;
410 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
411 content::WaitForLoadStop(tab);
413 ResultCatcher catcher;
415 ExtensionService* service = extensions::ExtensionSystem::Get(
416 browser()->profile())->extension_service();
417 const extensions::Extension* extension =
418 service->GetExtensionById(last_loaded_extension_id(), false);
419 GURL url = extension->GetResourceURL("a.html");
421 ui_test_utils::NavigateToURL(browser(), url);
423 // This corresponds to "Open link in new tab".
424 content::ContextMenuParams params;
425 params.is_editable = false;
426 params.media_type = blink::WebContextMenuData::MediaTypeNone;
427 params.page_url = url;
428 params.link_url = extension->GetResourceURL("b.html");
430 TestRenderViewContextMenu menu(tab->GetMainFrame(), params);
431 menu.Init();
432 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
434 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
437 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) {
438 ASSERT_TRUE(StartEmbeddedTestServer());
440 // Wait for the extension to set itself up and return control to us.
441 ASSERT_TRUE(RunExtensionTest("webnavigation/requestOpenTab"))
442 << message_;
444 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
445 content::WaitForLoadStop(tab);
447 ResultCatcher catcher;
449 ExtensionService* service = extensions::ExtensionSystem::Get(
450 browser()->profile())->extension_service();
451 const extensions::Extension* extension =
452 service->GetExtensionById(last_loaded_extension_id(), false);
453 GURL url = extension->GetResourceURL("a.html");
455 ui_test_utils::NavigateToURL(browser(), url);
457 // There's a link on a.html. Middle-click on it to open it in a new tab.
458 blink::WebMouseEvent mouse_event;
459 mouse_event.type = blink::WebInputEvent::MouseDown;
460 mouse_event.button = blink::WebMouseEvent::ButtonMiddle;
461 mouse_event.x = 7;
462 mouse_event.y = 7;
463 mouse_event.clickCount = 1;
464 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
465 mouse_event.type = blink::WebInputEvent::MouseUp;
466 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
468 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
471 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlank) {
472 ASSERT_TRUE(StartEmbeddedTestServer());
474 // Wait for the extension to set itself up and return control to us.
475 ASSERT_TRUE(RunExtensionTest("webnavigation/targetBlank")) << message_;
477 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
478 content::WaitForLoadStop(tab);
480 ResultCatcher catcher;
482 GURL url = embedded_test_server()->GetURL(
483 "/extensions/api_test/webnavigation/targetBlank/a.html");
485 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
486 ui_test_utils::NavigateToURL(&params);
488 // There's a link with target=_blank on a.html. Click on it to open it in a
489 // new tab.
490 blink::WebMouseEvent mouse_event;
491 mouse_event.type = blink::WebInputEvent::MouseDown;
492 mouse_event.button = blink::WebMouseEvent::ButtonLeft;
493 mouse_event.x = 7;
494 mouse_event.y = 7;
495 mouse_event.clickCount = 1;
496 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
497 mouse_event.type = blink::WebInputEvent::MouseUp;
498 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
500 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
503 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlankIncognito) {
504 ASSERT_TRUE(StartEmbeddedTestServer());
506 // Wait for the extension to set itself up and return control to us.
507 ASSERT_TRUE(RunExtensionTestIncognito("webnavigation/targetBlank"))
508 << message_;
510 ResultCatcher catcher;
512 GURL url = embedded_test_server()->GetURL(
513 "/extensions/api_test/webnavigation/targetBlank/a.html");
515 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
516 browser()->profile(), url);
517 WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents();
519 // There's a link with target=_blank on a.html. Click on it to open it in a
520 // new tab.
521 blink::WebMouseEvent mouse_event;
522 mouse_event.type = blink::WebInputEvent::MouseDown;
523 mouse_event.button = blink::WebMouseEvent::ButtonLeft;
524 mouse_event.x = 7;
525 mouse_event.y = 7;
526 mouse_event.clickCount = 1;
527 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
528 mouse_event.type = blink::WebInputEvent::MouseUp;
529 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
531 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
534 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, History) {
535 ASSERT_TRUE(StartEmbeddedTestServer());
536 ASSERT_TRUE(RunExtensionTest("webnavigation/history")) << message_;
539 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcess) {
540 ASSERT_TRUE(StartEmbeddedTestServer());
542 LoadExtension(test_data_dir_.AppendASCII("webnavigation").AppendASCII("app"));
544 // See crossProcess/d.html.
545 DelayLoadStartAndExecuteJavascript call_script(
546 test_navigation_listener(),
547 embedded_test_server()->GetURL("/test1"),
548 "navigate2()",
549 "empty.html");
551 ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcess")) << message_;
554 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessFragment) {
555 ASSERT_TRUE(StartEmbeddedTestServer());
557 // See crossProcessFragment/f.html.
558 DelayLoadStartAndExecuteJavascript call_script3(
559 test_navigation_listener(),
560 embedded_test_server()->GetURL("/test3"),
561 "updateFragment()",
562 base::StringPrintf("f.html?%u#foo", embedded_test_server()->port()));
564 // See crossProcessFragment/g.html.
565 DelayLoadStartAndExecuteJavascript call_script4(
566 test_navigation_listener(),
567 embedded_test_server()->GetURL("/test4"),
568 "updateFragment()",
569 base::StringPrintf("g.html?%u#foo", embedded_test_server()->port()));
571 ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessFragment"))
572 << message_;
575 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessHistory) {
576 ASSERT_TRUE(StartEmbeddedTestServer());
578 // See crossProcessHistory/e.html.
579 DelayLoadStartAndExecuteJavascript call_script2(
580 test_navigation_listener(),
581 embedded_test_server()->GetURL("/test2"),
582 "updateHistory()",
583 "empty.html");
585 // See crossProcessHistory/h.html.
586 DelayLoadStartAndExecuteJavascript call_script5(
587 test_navigation_listener(),
588 embedded_test_server()->GetURL("/test5"),
589 "updateHistory()",
590 "empty.html");
592 // See crossProcessHistory/i.html.
593 DelayLoadStartAndExecuteJavascript call_script6(
594 test_navigation_listener(),
595 embedded_test_server()->GetURL("/test6"),
596 "updateHistory()",
597 "empty.html");
599 ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessHistory"))
600 << message_;
603 // TODO(jam): http://crbug.com/350550
604 #if !(defined(OS_CHROMEOS) && defined(ADDRESS_SANITIZER))
605 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Crash) {
606 ASSERT_TRUE(StartEmbeddedTestServer());
608 // Wait for the extension to set itself up and return control to us.
609 ASSERT_TRUE(RunExtensionTest("webnavigation/crash")) << message_;
611 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
612 content::WaitForLoadStop(tab);
614 ResultCatcher catcher;
616 GURL url(base::StringPrintf(
617 "http://www.a.com:%u/"
618 "extensions/api_test/webnavigation/crash/a.html",
619 embedded_test_server()->port()));
620 ui_test_utils::NavigateToURL(browser(), url);
622 ui_test_utils::NavigateToURL(browser(), GURL(content::kChromeUICrashURL));
624 url = GURL(base::StringPrintf(
625 "http://www.a.com:%u/"
626 "extensions/api_test/webnavigation/crash/b.html",
627 embedded_test_server()->port()));
628 ui_test_utils::NavigateToURL(browser(), url);
630 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
633 #endif
635 } // namespace extensions