Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / web_navigation / web_navigation_apitest.cc
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.
4
5 #include <list>
6 #include <set>
7
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"
50
51 using content::ResourceType;
52 using content::WebContents;
53
54 namespace extensions {
55
56 namespace {
57
58 // This class can defer requests for arbitrary URLs.
59 class TestNavigationListener
60     : public base::RefCountedThreadSafe<TestNavigationListener> {
61  public:
62   TestNavigationListener() {}
63
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;
72     }
73     urls_to_delay_.insert(url);
74   }
75
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;
84     }
85     WeakThrottleList::const_iterator it;
86     for (it = throttles_.begin(); it != throttles_.end(); ++it) {
87       if (it->get())
88         (*it)->Resume();
89     }
90     throttles_.clear();
91   }
92
93   // Constructs a ResourceThrottle if the request for |url| should be held.
94   //
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;
102
103     Throttle* throttle = new Throttle();
104     throttles_.push_back(throttle->AsWeakPtr());
105     return throttle;
106   }
107
108  private:
109   friend class base::RefCountedThreadSafe<TestNavigationListener>;
110
111   virtual ~TestNavigationListener() {}
112
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();
119     }
120
121     // content::ResourceThrottle implementation.
122     void WillStartRequest(bool* defer) override { *defer = true; }
123
124     const char* GetNameForLogging() const override {
125       return "TestNavigationListener::Throttle";
126     }
127   };
128   typedef base::WeakPtr<Throttle> WeakThrottle;
129   typedef std::list<WeakThrottle> WeakThrottleList;
130   WeakThrottleList throttles_;
131
132   // The set of URLs to be delayed.
133   std::set<GURL> urls_to_delay_;
134
135   DISALLOW_COPY_AND_ASSIGN(TestNavigationListener);
136 };
137
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_);
163   }
164   ~DelayLoadStartAndExecuteJavascript() override {}
165
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;
172     }
173     content::WebContentsObserver::Observe(
174         content::Details<content::WebContents>(details).ptr());
175     registrar_.RemoveAll();
176   }
177
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;
185
186     rvh_->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(script_));
187     script_was_executed_ = true;
188   }
189
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();
197     }
198     rvh_ = render_frame_host->GetRenderViewHost();
199   }
200
201  private:
202   content::NotificationRegistrar registrar_;
203
204   scoped_refptr<TestNavigationListener> test_navigation_listener_;
205
206   GURL delay_url_;
207   std::string until_url_suffix_;
208   std::string script_;
209   bool script_was_executed_;
210   content::RenderViewHost* rvh_;
211
212   DISALLOW_COPY_AND_ASSIGN(DelayLoadStartAndExecuteJavascript);
213 };
214
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) {
224   }
225   ~TestResourceDispatcherHostDelegate() override {}
226
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);
244   }
245
246  private:
247   scoped_refptr<TestNavigationListener> test_navigation_listener_;
248
249   DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
250 };
251
252 }  // namespace
253
254 class WebNavigationApiTest : public ExtensionApiTest {
255  public:
256   WebNavigationApiTest() {}
257   ~WebNavigationApiTest() override {}
258
259   void SetUpInProcessBrowserTestFixture() override {
260     ExtensionApiTest::SetUpInProcessBrowserTestFixture();
261
262     FrameNavigationState::set_allow_extension_scheme(true);
263
264     CommandLine::ForCurrentProcess()->AppendSwitch(
265         switches::kAllowLegacyExtensionManifests);
266
267     host_resolver()->AddRule("*", "127.0.0.1");
268   }
269
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());
279   }
280
281   TestNavigationListener* test_navigation_listener() {
282     return test_navigation_listener_.get();
283   }
284
285  private:
286   scoped_refptr<TestNavigationListener> test_navigation_listener_;
287   scoped_ptr<TestResourceDispatcherHostDelegate>
288       resource_dispatcher_host_delegate_;
289
290   DISALLOW_COPY_AND_ASSIGN(WebNavigationApiTest);
291 };
292
293 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Api) {
294   ASSERT_TRUE(StartEmbeddedTestServer());
295   ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
296 }
297
298 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, GetFrame) {
299   ASSERT_TRUE(StartEmbeddedTestServer());
300   ASSERT_TRUE(RunExtensionTest("webnavigation/getFrame")) << message_;
301 }
302
303 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ClientRedirect) {
304   ASSERT_TRUE(StartEmbeddedTestServer());
305   ASSERT_TRUE(RunExtensionTest("webnavigation/clientRedirect"))
306       << message_;
307 }
308
309 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirect) {
310   ASSERT_TRUE(StartEmbeddedTestServer());
311   ASSERT_TRUE(RunExtensionTest("webnavigation/serverRedirect"))
312       << message_;
313 }
314
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());
321
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();
329 }
330
331 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirectSingleProcess) {
332   ASSERT_TRUE(StartEmbeddedTestServer());
333
334   // Set max renderers to 1 to force running out of processes.
335   content::RenderProcessHost::SetMaxRendererProcessCount(1);
336
337   // Wait for the extension to set itself up and return control to us.
338   ASSERT_TRUE(
339       RunExtensionTest("webnavigation/serverRedirectSingleProcess"))
340       << message_;
341
342   WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
343   content::WaitForLoadStop(tab);
344
345   ResultCatcher catcher;
346   GURL url(base::StringPrintf(
347       "http://www.a.com:%d/"
348       "extensions/api_test/webnavigation/serverRedirectSingleProcess/a.html",
349       embedded_test_server()->port()));
350
351   ui_test_utils::NavigateToURL(browser(), url);
352
353   url = GURL(base::StringPrintf(
354       "http://www.b.com:%d/server-redirect?http://www.b.com:%d/",
355       embedded_test_server()->port(),
356       embedded_test_server()->port()));
357
358   ui_test_utils::NavigateToURL(browser(), url);
359
360   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
361 }
362
363 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ForwardBack) {
364   ASSERT_TRUE(StartEmbeddedTestServer());
365   ASSERT_TRUE(RunExtensionTest("webnavigation/forwardBack")) << message_;
366 }
367
368 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, IFrame) {
369   ASSERT_TRUE(StartEmbeddedTestServer());
370   ASSERT_TRUE(RunExtensionTest("webnavigation/iframe")) << message_;
371 }
372
373 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SrcDoc) {
374   ASSERT_TRUE(StartEmbeddedTestServer());
375   ASSERT_TRUE(RunExtensionTest("webnavigation/srcdoc")) << message_;
376 }
377
378 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, OpenTab) {
379   ASSERT_TRUE(StartEmbeddedTestServer());
380   ASSERT_TRUE(RunExtensionTest("webnavigation/openTab")) << message_;
381 }
382
383 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ReferenceFragment) {
384   ASSERT_TRUE(StartEmbeddedTestServer());
385   ASSERT_TRUE(RunExtensionTest("webnavigation/referenceFragment"))
386       << message_;
387 }
388
389 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SimpleLoad) {
390   ASSERT_TRUE(StartEmbeddedTestServer());
391   ASSERT_TRUE(RunExtensionTest("webnavigation/simpleLoad")) << message_;
392 }
393
394 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Failures) {
395   ASSERT_TRUE(StartEmbeddedTestServer());
396   ASSERT_TRUE(RunExtensionTest("webnavigation/failures")) << message_;
397 }
398
399 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) {
400   ASSERT_TRUE(StartEmbeddedTestServer());
401   ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_;
402 }
403
404 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) {
405   ASSERT_TRUE(StartEmbeddedTestServer());
406
407   // Wait for the extension to set itself up and return control to us.
408   ASSERT_TRUE(RunExtensionTest("webnavigation/userAction")) << message_;
409
410   WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
411   content::WaitForLoadStop(tab);
412
413   ResultCatcher catcher;
414
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");
420
421   ui_test_utils::NavigateToURL(browser(), url);
422
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");
429
430   TestRenderViewContextMenu menu(tab->GetMainFrame(), params);
431   menu.Init();
432   menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
433
434   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
435 }
436
437 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) {
438   ASSERT_TRUE(StartEmbeddedTestServer());
439
440   // Wait for the extension to set itself up and return control to us.
441   ASSERT_TRUE(RunExtensionTest("webnavigation/requestOpenTab"))
442       << message_;
443
444   WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
445   content::WaitForLoadStop(tab);
446
447   ResultCatcher catcher;
448
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");
454
455   ui_test_utils::NavigateToURL(browser(), url);
456
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);
467
468   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
469 }
470
471 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlank) {
472   ASSERT_TRUE(StartEmbeddedTestServer());
473
474   // Wait for the extension to set itself up and return control to us.
475   ASSERT_TRUE(RunExtensionTest("webnavigation/targetBlank")) << message_;
476
477   WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
478   content::WaitForLoadStop(tab);
479
480   ResultCatcher catcher;
481
482   GURL url = embedded_test_server()->GetURL(
483       "/extensions/api_test/webnavigation/targetBlank/a.html");
484
485   chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
486   ui_test_utils::NavigateToURL(&params);
487
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);
499
500   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
501 }
502
503 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlankIncognito) {
504   ASSERT_TRUE(StartEmbeddedTestServer());
505
506   // Wait for the extension to set itself up and return control to us.
507   ASSERT_TRUE(RunExtensionTestIncognito("webnavigation/targetBlank"))
508       << message_;
509
510   ResultCatcher catcher;
511
512   GURL url = embedded_test_server()->GetURL(
513       "/extensions/api_test/webnavigation/targetBlank/a.html");
514
515   Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
516       browser()->profile(), url);
517   WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents();
518
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);
530
531   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
532 }
533
534 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, History) {
535   ASSERT_TRUE(StartEmbeddedTestServer());
536   ASSERT_TRUE(RunExtensionTest("webnavigation/history")) << message_;
537 }
538
539 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcess) {
540   ASSERT_TRUE(StartEmbeddedTestServer());
541
542   LoadExtension(test_data_dir_.AppendASCII("webnavigation").AppendASCII("app"));
543
544   // See crossProcess/d.html.
545   DelayLoadStartAndExecuteJavascript call_script(
546       test_navigation_listener(),
547       embedded_test_server()->GetURL("/test1"),
548       "navigate2()",
549       "empty.html");
550
551   ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcess")) << message_;
552 }
553
554 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessFragment) {
555   ASSERT_TRUE(StartEmbeddedTestServer());
556
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?%d#foo", embedded_test_server()->port()));
563
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?%d#foo", embedded_test_server()->port()));
570
571   ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessFragment"))
572       << message_;
573 }
574
575 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessHistory) {
576   ASSERT_TRUE(StartEmbeddedTestServer());
577
578   // See crossProcessHistory/e.html.
579   DelayLoadStartAndExecuteJavascript call_script2(
580       test_navigation_listener(),
581       embedded_test_server()->GetURL("/test2"),
582       "updateHistory()",
583       "empty.html");
584
585   // See crossProcessHistory/h.html.
586   DelayLoadStartAndExecuteJavascript call_script5(
587       test_navigation_listener(),
588       embedded_test_server()->GetURL("/test5"),
589       "updateHistory()",
590       "empty.html");
591
592   // See crossProcessHistory/i.html.
593   DelayLoadStartAndExecuteJavascript call_script6(
594       test_navigation_listener(),
595       embedded_test_server()->GetURL("/test6"),
596       "updateHistory()",
597       "empty.html");
598
599   ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessHistory"))
600       << message_;
601 }
602
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());
607
608   // Wait for the extension to set itself up and return control to us.
609   ASSERT_TRUE(RunExtensionTest("webnavigation/crash")) << message_;
610
611   WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
612   content::WaitForLoadStop(tab);
613
614   ResultCatcher catcher;
615
616   GURL url(base::StringPrintf(
617       "http://www.a.com:%d/"
618           "extensions/api_test/webnavigation/crash/a.html",
619       embedded_test_server()->port()));
620   ui_test_utils::NavigateToURL(browser(), url);
621
622   ui_test_utils::NavigateToURL(browser(), GURL(content::kChromeUICrashURL));
623
624   url = GURL(base::StringPrintf(
625       "http://www.a.com:%d/"
626           "extensions/api_test/webnavigation/crash/b.html",
627       embedded_test_server()->port()));
628   ui_test_utils::NavigateToURL(browser(), url);
629
630   ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
631 }
632
633 #endif
634
635 }  // namespace extensions