1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <list>
#include <set>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/download/download_browsertest.h"
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_controller.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "webkit/common/resource_type.h"
using content::WebContents;
namespace extensions {
namespace {
// This class can defer requests for arbitrary URLs.
class TestNavigationListener
: public base::RefCountedThreadSafe<TestNavigationListener> {
public:
TestNavigationListener() {}
// Add |url| to the set of URLs we should delay.
void DelayRequestsForURL(const GURL& url) {
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&TestNavigationListener::DelayRequestsForURL, this, url));
return;
}
urls_to_delay_.insert(url);
}
// Resume all deferred requests.
void ResumeAll() {
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&TestNavigationListener::ResumeAll, this));
return;
}
WeakThrottleList::const_iterator it;
for (it = throttles_.begin(); it != throttles_.end(); ++it) {
if (it->get())
(*it)->Resume();
}
throttles_.clear();
}
// Constructs a ResourceThrottle if the request for |url| should be held.
//
// Needs to be invoked on the IO thread.
content::ResourceThrottle* CreateResourceThrottle(
const GURL& url,
ResourceType::Type resource_type) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
if (urls_to_delay_.find(url) == urls_to_delay_.end())
return NULL;
Throttle* throttle = new Throttle();
throttles_.push_back(throttle->AsWeakPtr());
return throttle;
}
private:
friend class base::RefCountedThreadSafe<TestNavigationListener>;
virtual ~TestNavigationListener() {}
// Stores a throttle per URL request that we have delayed.
class Throttle : public content::ResourceThrottle,
public base::SupportsWeakPtr<Throttle> {
public:
void Resume() {
controller()->Resume();
}
// content::ResourceThrottle implementation.
virtual void WillStartRequest(bool* defer) OVERRIDE {
*defer = true;
}
virtual const char* GetNameForLogging() const OVERRIDE {
return "TestNavigationListener::Throttle";
}
};
typedef base::WeakPtr<Throttle> WeakThrottle;
typedef std::list<WeakThrottle> WeakThrottleList;
WeakThrottleList throttles_;
// The set of URLs to be delayed.
std::set<GURL> urls_to_delay_;
DISALLOW_COPY_AND_ASSIGN(TestNavigationListener);
};
// Waits for a WC to be created. Once it starts loading |delay_url| (after at
// least the first navigation has committed), it delays the load, executes
// |script| in the last committed RVH and resumes the load when a URL ending in
// |until_url_suffix| commits. This class expects |script| to trigger the load
// of an URL ending in |until_url_suffix|.
class DelayLoadStartAndExecuteJavascript
: public content::NotificationObserver,
public content::WebContentsObserver {
public:
DelayLoadStartAndExecuteJavascript(
TestNavigationListener* test_navigation_listener,
const GURL& delay_url,
const std::string& script,
const std::string& until_url_suffix)
: content::WebContentsObserver(),
test_navigation_listener_(test_navigation_listener),
delay_url_(delay_url),
until_url_suffix_(until_url_suffix),
script_(script),
script_was_executed_(false),
rvh_(NULL) {
registrar_.Add(this,
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
test_navigation_listener_->DelayRequestsForURL(delay_url_);
}
virtual ~DelayLoadStartAndExecuteJavascript() {}
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
if (type != chrome::NOTIFICATION_TAB_ADDED) {
NOTREACHED();
return;
}
content::WebContentsObserver::Observe(
content::Details<content::WebContents>(details).ptr());
registrar_.RemoveAll();
}
virtual void DidStartProvisionalLoadForFrame(
int64 frame_id,
int64 parent_frame_id,
bool is_main_frame,
const GURL& validated_url,
bool is_error_page,
bool is_iframe_srcdoc,
content::RenderViewHost* render_view_host) OVERRIDE {
if (validated_url != delay_url_ || !rvh_)
return;
rvh_->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(script_));
script_was_executed_ = true;
}
virtual void DidCommitProvisionalLoadForFrame(
int64 frame_id,
const base::string16& frame_unique_name,
bool is_main_frame,
const GURL& url,
content::PageTransition transition_type,
content::RenderViewHost* render_view_host) OVERRIDE {
if (script_was_executed_ && EndsWith(url.spec(), until_url_suffix_, true)) {
content::WebContentsObserver::Observe(NULL);
test_navigation_listener_->ResumeAll();
}
rvh_ = render_view_host;
}
private:
content::NotificationRegistrar registrar_;
scoped_refptr<TestNavigationListener> test_navigation_listener_;
GURL delay_url_;
std::string until_url_suffix_;
std::string script_;
bool script_was_executed_;
content::RenderViewHost* rvh_;
DISALLOW_COPY_AND_ASSIGN(DelayLoadStartAndExecuteJavascript);
};
// A ResourceDispatcherHostDelegate that adds a TestNavigationObserver.
class TestResourceDispatcherHostDelegate
: public ChromeResourceDispatcherHostDelegate {
public:
TestResourceDispatcherHostDelegate(
prerender::PrerenderTracker* prerender_tracker,
TestNavigationListener* test_navigation_listener)
: ChromeResourceDispatcherHostDelegate(prerender_tracker),
test_navigation_listener_(test_navigation_listener) {
}
virtual ~TestResourceDispatcherHostDelegate() {}
virtual void RequestBeginning(
net::URLRequest* request,
content::ResourceContext* resource_context,
appcache::AppCacheService* appcache_service,
ResourceType::Type resource_type,
int child_id,
int route_id,
ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE {
ChromeResourceDispatcherHostDelegate::RequestBeginning(
request,
resource_context,
appcache_service,
resource_type,
child_id,
route_id,
throttles);
content::ResourceThrottle* throttle =
test_navigation_listener_->CreateResourceThrottle(request->url(),
resource_type);
if (throttle)
throttles->push_back(throttle);
}
private:
scoped_refptr<TestNavigationListener> test_navigation_listener_;
DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
};
} // namespace
class WebNavigationApiTest : public ExtensionApiTest {
public:
WebNavigationApiTest() {}
virtual ~WebNavigationApiTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
FrameNavigationState::set_allow_extension_scheme(true);
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAllowLegacyExtensionManifests);
host_resolver()->AddRule("*", "127.0.0.1");
}
virtual void SetUpOnMainThread() OVERRIDE {
ExtensionApiTest::SetUpOnMainThread();
test_navigation_listener_ = new TestNavigationListener();
resource_dispatcher_host_delegate_.reset(
new TestResourceDispatcherHostDelegate(
g_browser_process->prerender_tracker(),
test_navigation_listener_.get()));
content::ResourceDispatcherHost::Get()->SetDelegate(
resource_dispatcher_host_delegate_.get());
}
TestNavigationListener* test_navigation_listener() {
return test_navigation_listener_.get();
}
private:
scoped_refptr<TestNavigationListener> test_navigation_listener_;
scoped_ptr<TestResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;
DISALLOW_COPY_AND_ASSIGN(WebNavigationApiTest);
};
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Api) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, GetFrame) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/getFrame")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ClientRedirect) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/clientRedirect"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirect) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/serverRedirect"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Download) {
DownloadTestObserverNotInProgress download_observer(
content::BrowserContext::GetDownloadManager(profile()), 1);
download_observer.StartObserving();
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/download"))
<< message_;
download_observer.WaitForFinished();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirectSingleProcess) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Set max renderers to 1 to force running out of processes.
content::RenderProcessHost::SetMaxRendererProcessCount(1);
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(
RunExtensionTest("webnavigation/serverRedirectSingleProcess"))
<< message_;
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(tab);
ResultCatcher catcher;
GURL url(base::StringPrintf(
"http://www.a.com:%d/"
"extensions/api_test/webnavigation/serverRedirectSingleProcess/a.html",
embedded_test_server()->port()));
ui_test_utils::NavigateToURL(browser(), url);
url = GURL(base::StringPrintf(
"http://www.b.com:%d/server-redirect?http://www.b.com:%d/",
embedded_test_server()->port(),
embedded_test_server()->port()));
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ForwardBack) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/forwardBack")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, IFrame) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/iframe")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SrcDoc) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/srcdoc")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, OpenTab) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/openTab")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ReferenceFragment) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/referenceFragment"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, SimpleLoad) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/simpleLoad")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Failures) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/failures")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(RunExtensionTest("webnavigation/userAction")) << message_;
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(tab);
ResultCatcher catcher;
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
const extensions::Extension* extension =
service->GetExtensionById(last_loaded_extension_id(), false);
GURL url = extension->GetResourceURL("a.html");
ui_test_utils::NavigateToURL(browser(), url);
// This corresponds to "Open link in new tab".
content::ContextMenuParams params;
params.is_editable = false;
params.media_type = blink::WebContextMenuData::MediaTypeNone;
params.page_url = url;
params.frame_id = WebNavigationTabObserver::Get(tab)->
frame_navigation_state().GetMainFrameID().frame_num;
params.link_url = extension->GetResourceURL("b.html");
TestRenderViewContextMenu menu(tab->GetMainFrame(), params);
menu.Init();
menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(RunExtensionTest("webnavigation/requestOpenTab"))
<< message_;
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(tab);
ResultCatcher catcher;
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
const extensions::Extension* extension =
service->GetExtensionById(last_loaded_extension_id(), false);
GURL url = extension->GetResourceURL("a.html");
ui_test_utils::NavigateToURL(browser(), url);
// There's a link on a.html. Middle-click on it to open it in a new tab.
blink::WebMouseEvent mouse_event;
mouse_event.type = blink::WebInputEvent::MouseDown;
mouse_event.button = blink::WebMouseEvent::ButtonMiddle;
mouse_event.x = 7;
mouse_event.y = 7;
mouse_event.clickCount = 1;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
mouse_event.type = blink::WebInputEvent::MouseUp;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlank) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(RunExtensionTest("webnavigation/targetBlank")) << message_;
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(tab);
ResultCatcher catcher;
GURL url = embedded_test_server()->GetURL(
"/extensions/api_test/webnavigation/targetBlank/a.html");
chrome::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK);
ui_test_utils::NavigateToURL(¶ms);
// There's a link with target=_blank on a.html. Click on it to open it in a
// new tab.
blink::WebMouseEvent mouse_event;
mouse_event.type = blink::WebInputEvent::MouseDown;
mouse_event.button = blink::WebMouseEvent::ButtonLeft;
mouse_event.x = 7;
mouse_event.y = 7;
mouse_event.clickCount = 1;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
mouse_event.type = blink::WebInputEvent::MouseUp;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlankIncognito) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(RunExtensionTestIncognito("webnavigation/targetBlank"))
<< message_;
ResultCatcher catcher;
GURL url = embedded_test_server()->GetURL(
"/extensions/api_test/webnavigation/targetBlank/a.html");
Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
browser()->profile(), url);
WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents();
// There's a link with target=_blank on a.html. Click on it to open it in a
// new tab.
blink::WebMouseEvent mouse_event;
mouse_event.type = blink::WebInputEvent::MouseDown;
mouse_event.button = blink::WebMouseEvent::ButtonLeft;
mouse_event.x = 7;
mouse_event.y = 7;
mouse_event.clickCount = 1;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
mouse_event.type = blink::WebInputEvent::MouseUp;
tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, History) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("webnavigation/history")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcess) {
ASSERT_TRUE(StartEmbeddedTestServer());
LoadExtension(test_data_dir_.AppendASCII("webnavigation").AppendASCII("app"));
// See crossProcess/d.html.
DelayLoadStartAndExecuteJavascript call_script(
test_navigation_listener(),
embedded_test_server()->GetURL("/test1"),
"navigate2()",
"empty.html");
ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcess")) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessFragment) {
ASSERT_TRUE(StartEmbeddedTestServer());
// See crossProcessFragment/f.html.
DelayLoadStartAndExecuteJavascript call_script3(
test_navigation_listener(),
embedded_test_server()->GetURL("/test3"),
"updateFragment()",
base::StringPrintf("f.html?%d#foo", embedded_test_server()->port()));
// See crossProcessFragment/g.html.
DelayLoadStartAndExecuteJavascript call_script4(
test_navigation_listener(),
embedded_test_server()->GetURL("/test4"),
"updateFragment()",
base::StringPrintf("g.html?%d#foo", embedded_test_server()->port()));
ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessFragment"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessHistory) {
ASSERT_TRUE(StartEmbeddedTestServer());
// See crossProcessHistory/e.html.
DelayLoadStartAndExecuteJavascript call_script2(
test_navigation_listener(),
embedded_test_server()->GetURL("/test2"),
"updateHistory()",
"empty.html");
// See crossProcessHistory/h.html.
DelayLoadStartAndExecuteJavascript call_script5(
test_navigation_listener(),
embedded_test_server()->GetURL("/test5"),
"updateHistory()",
"empty.html");
// See crossProcessHistory/i.html.
DelayLoadStartAndExecuteJavascript call_script6(
test_navigation_listener(),
embedded_test_server()->GetURL("/test6"),
"updateHistory()",
"empty.html");
ASSERT_TRUE(RunExtensionTest("webnavigation/crossProcessHistory"))
<< message_;
}
// TODO(jam): http://crbug.com/350550
#if !(defined(OS_CHROMEOS) && defined(ADDRESS_SANITIZER))
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Crash) {
ASSERT_TRUE(StartEmbeddedTestServer());
// Wait for the extension to set itself up and return control to us.
ASSERT_TRUE(RunExtensionTest("webnavigation/crash")) << message_;
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
content::WaitForLoadStop(tab);
ResultCatcher catcher;
GURL url(base::StringPrintf(
"http://www.a.com:%d/"
"extensions/api_test/webnavigation/crash/a.html",
embedded_test_server()->port()));
ui_test_utils::NavigateToURL(browser(), url);
ui_test_utils::NavigateToURL(browser(), GURL(content::kChromeUICrashURL));
url = GURL(base::StringPrintf(
"http://www.a.com:%d/"
"extensions/api_test/webnavigation/crash/b.html",
embedded_test_server()->port()));
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
#endif
} // namespace extensions
|