OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/automation/automation_util.h" | 7 #include "chrome/browser/automation/automation_util.h" |
8 #include "chrome/browser/extensions/extension_test_message_listener.h" | 8 #include "chrome/browser/extensions/extension_test_message_listener.h" |
9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
10 #include "chrome/browser/prerender/prerender_link_manager.h" | 10 #include "chrome/browser/prerender/prerender_link_manager.h" |
11 #include "chrome/browser/prerender/prerender_link_manager_factory.h" | 11 #include "chrome/browser/prerender/prerender_link_manager_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/test/base/test_launcher_utils.h" | 16 #include "chrome/test/base/test_launcher_utils.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
21 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/fake_speech_recognition_manager.h" | 22 #include "content/public/test/fake_speech_recognition_manager.h" |
| 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
23 #include "ui/compositor/compositor_setup.h" | 24 #include "ui/compositor/compositor_setup.h" |
24 #include "ui/gl/gl_switches.h" | 25 #include "ui/gl/gl_switches.h" |
25 | 26 |
26 using prerender::PrerenderLinkManager; | 27 using prerender::PrerenderLinkManager; |
27 using prerender::PrerenderLinkManagerFactory; | 28 using prerender::PrerenderLinkManagerFactory; |
28 | 29 |
29 // This class intercepts media access request from the embedder. The request | 30 // This class intercepts media access request from the embedder. The request |
30 // should be triggered only if the embedder API (from tests) allows the request | 31 // should be triggered only if the embedder API (from tests) allows the request |
31 // in Javascript. | 32 // in Javascript. |
32 // We do not issue the actual media request; the fact that the request reached | 33 // We do not issue the actual media request; the fact that the request reached |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 content::WebContents** named_partition_contents2, | 198 content::WebContents** named_partition_contents2, |
198 content::WebContents** persistent_partition_contents1, | 199 content::WebContents** persistent_partition_contents1, |
199 content::WebContents** persistent_partition_contents2, | 200 content::WebContents** persistent_partition_contents2, |
200 content::WebContents** persistent_partition_contents3) { | 201 content::WebContents** persistent_partition_contents3) { |
201 GURL::Replacements replace_host; | 202 GURL::Replacements replace_host; |
202 std::string host_str("localhost"); // Must stay in scope with replace_host. | 203 std::string host_str("localhost"); // Must stay in scope with replace_host. |
203 replace_host.SetHostStr(host_str); | 204 replace_host.SetHostStr(host_str); |
204 | 205 |
205 navigate_to_url = navigate_to_url.ReplaceComponents(replace_host); | 206 navigate_to_url = navigate_to_url.ReplaceComponents(replace_host); |
206 | 207 |
207 GURL tag_url1 = test_server()->GetURL( | 208 GURL tag_url1 = embedded_test_server()->GetURL( |
208 "files/extensions/platform_apps/web_view/isolation/cookie.html"); | 209 "/extensions/platform_apps/web_view/isolation/cookie.html"); |
209 tag_url1 = tag_url1.ReplaceComponents(replace_host); | 210 tag_url1 = tag_url1.ReplaceComponents(replace_host); |
210 GURL tag_url2 = test_server()->GetURL( | 211 GURL tag_url2 = embedded_test_server()->GetURL( |
211 "files/extensions/platform_apps/web_view/isolation/cookie2.html"); | 212 "/extensions/platform_apps/web_view/isolation/cookie2.html"); |
212 tag_url2 = tag_url2.ReplaceComponents(replace_host); | 213 tag_url2 = tag_url2.ReplaceComponents(replace_host); |
213 GURL tag_url3 = test_server()->GetURL( | 214 GURL tag_url3 = embedded_test_server()->GetURL( |
214 "files/extensions/platform_apps/web_view/isolation/storage1.html"); | 215 "/extensions/platform_apps/web_view/isolation/storage1.html"); |
215 tag_url3 = tag_url3.ReplaceComponents(replace_host); | 216 tag_url3 = tag_url3.ReplaceComponents(replace_host); |
216 GURL tag_url4 = test_server()->GetURL( | 217 GURL tag_url4 = embedded_test_server()->GetURL( |
217 "files/extensions/platform_apps/web_view/isolation/storage2.html"); | 218 "/extensions/platform_apps/web_view/isolation/storage2.html"); |
218 tag_url4 = tag_url4.ReplaceComponents(replace_host); | 219 tag_url4 = tag_url4.ReplaceComponents(replace_host); |
219 GURL tag_url5 = test_server()->GetURL( | 220 GURL tag_url5 = embedded_test_server()->GetURL( |
220 "files/extensions/platform_apps/web_view/isolation/storage1.html#p1"); | 221 "/extensions/platform_apps/web_view/isolation/storage1.html#p1"); |
221 tag_url5 = tag_url5.ReplaceComponents(replace_host); | 222 tag_url5 = tag_url5.ReplaceComponents(replace_host); |
222 GURL tag_url6 = test_server()->GetURL( | 223 GURL tag_url6 = embedded_test_server()->GetURL( |
223 "files/extensions/platform_apps/web_view/isolation/storage1.html#p2"); | 224 "/extensions/platform_apps/web_view/isolation/storage1.html#p2"); |
224 tag_url6 = tag_url6.ReplaceComponents(replace_host); | 225 tag_url6 = tag_url6.ReplaceComponents(replace_host); |
225 GURL tag_url7 = test_server()->GetURL( | 226 GURL tag_url7 = embedded_test_server()->GetURL( |
226 "files/extensions/platform_apps/web_view/isolation/storage1.html#p3"); | 227 "/extensions/platform_apps/web_view/isolation/storage1.html#p3"); |
227 tag_url7 = tag_url7.ReplaceComponents(replace_host); | 228 tag_url7 = tag_url7.ReplaceComponents(replace_host); |
228 | 229 |
229 ui_test_utils::NavigateToURLWithDisposition( | 230 ui_test_utils::NavigateToURLWithDisposition( |
230 browser(), navigate_to_url, CURRENT_TAB, | 231 browser(), navigate_to_url, CURRENT_TAB, |
231 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 232 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
232 | 233 |
233 ui_test_utils::UrlLoadObserver observer1( | 234 ui_test_utils::UrlLoadObserver observer1( |
234 tag_url1, content::NotificationService::AllSources()); | 235 tag_url1, content::NotificationService::AllSources()); |
235 ui_test_utils::UrlLoadObserver observer2( | 236 ui_test_utils::UrlLoadObserver observer2( |
236 tag_url2, content::NotificationService::AllSources()); | 237 tag_url2, content::NotificationService::AllSources()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 content::TitleWatcher title_watcher(web_contents, expected_title); | 350 content::TitleWatcher title_watcher(web_contents, expected_title); |
350 title_watcher.AlsoWaitForTitle(error_title); | 351 title_watcher.AlsoWaitForTitle(error_title); |
351 EXPECT_TRUE(content::ExecuteScript(web_contents, script)); | 352 EXPECT_TRUE(content::ExecuteScript(web_contents, script)); |
352 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 353 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
353 } | 354 } |
354 | 355 |
355 void TestHelper(const std::string& test_name, | 356 void TestHelper(const std::string& test_name, |
356 const std::string& test_passed_msg, | 357 const std::string& test_passed_msg, |
357 const std::string& test_failed_msg, | 358 const std::string& test_failed_msg, |
358 const std::string& app_location) { | 359 const std::string& app_location) { |
359 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 360 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
360 ExtensionTestMessageListener launched_listener("Launched", false); | 361 ExtensionTestMessageListener launched_listener("Launched", false); |
361 LoadAndLaunchPlatformApp(app_location.c_str()); | 362 LoadAndLaunchPlatformApp(app_location.c_str()); |
362 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 363 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
363 | 364 |
364 content::WebContents* embedder_web_contents = | 365 content::WebContents* embedder_web_contents = |
365 GetFirstShellWindowWebContents(); | 366 GetFirstShellWindowWebContents(); |
366 ASSERT_TRUE(embedder_web_contents); | 367 ASSERT_TRUE(embedder_web_contents); |
367 | 368 |
368 ExtensionTestMessageListener done_listener(test_passed_msg, false); | 369 ExtensionTestMessageListener done_listener(test_passed_msg, false); |
369 done_listener.AlsoListenForFailureMessage(test_failed_msg); | 370 done_listener.AlsoListenForFailureMessage(test_failed_msg); |
370 EXPECT_TRUE(content::ExecuteScript( | 371 EXPECT_TRUE(content::ExecuteScript( |
371 embedder_web_contents, | 372 embedder_web_contents, |
372 base::StringPrintf("runTest('%s')", test_name.c_str()))); | 373 base::StringPrintf("runTest('%s')", test_name.c_str()))); |
373 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); | 374 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
374 } | 375 } |
375 | 376 |
376 content::WebContents* LoadGuest(const std::string& guest_path, | 377 content::WebContents* LoadGuest(const std::string& guest_path, |
377 const std::string& app_path) { | 378 const std::string& app_path) { |
378 GURL::Replacements replace_host; | 379 GURL::Replacements replace_host; |
379 std::string host_str("localhost"); // Must stay in scope with replace_host. | 380 std::string host_str("localhost"); // Must stay in scope with replace_host. |
380 replace_host.SetHostStr(host_str); | 381 replace_host.SetHostStr(host_str); |
381 | 382 |
382 GURL guest_url = test_server()->GetURL(guest_path); | 383 GURL guest_url = embedded_test_server()->GetURL(guest_path); |
383 guest_url = guest_url.ReplaceComponents(replace_host); | 384 guest_url = guest_url.ReplaceComponents(replace_host); |
384 | 385 |
385 ui_test_utils::UrlLoadObserver guest_observer( | 386 ui_test_utils::UrlLoadObserver guest_observer( |
386 guest_url, content::NotificationService::AllSources()); | 387 guest_url, content::NotificationService::AllSources()); |
387 | 388 |
388 ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false); | 389 ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false); |
389 LoadAndLaunchPlatformApp(app_path.c_str()); | 390 LoadAndLaunchPlatformApp(app_path.c_str()); |
390 guest_observer.Wait(); | 391 guest_observer.Wait(); |
391 | 392 |
392 content::Source<content::NavigationController> source = | 393 content::Source<content::NavigationController> source = |
393 guest_observer.source(); | 394 guest_observer.source(); |
394 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()->IsGuest()); | 395 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()->IsGuest()); |
395 | 396 |
396 bool satisfied = guest_loaded_listener.WaitUntilSatisfied(); | 397 bool satisfied = guest_loaded_listener.WaitUntilSatisfied(); |
397 if (!satisfied) | 398 if (!satisfied) |
398 return NULL; | 399 return NULL; |
399 | 400 |
400 content::WebContents* guest_web_contents = source->GetWebContents(); | 401 content::WebContents* guest_web_contents = source->GetWebContents(); |
401 return guest_web_contents; | 402 return guest_web_contents; |
402 } | 403 } |
403 | 404 |
404 // Runs media_access/allow tests. | 405 // Runs media_access/allow tests. |
405 void MediaAccessAPIAllowTestHelper(const std::string& test_name); | 406 void MediaAccessAPIAllowTestHelper(const std::string& test_name); |
406 | 407 |
407 // Runs media_access/deny tests, each of them are run separately otherwise | 408 // Runs media_access/deny tests, each of them are run separately otherwise |
408 // they timeout (mostly on Windows). | 409 // they timeout (mostly on Windows). |
409 void MediaAccessAPIDenyTestHelper(const std::string& test_name) { | 410 void MediaAccessAPIDenyTestHelper(const std::string& test_name) { |
410 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 411 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
411 ExtensionTestMessageListener loaded_listener("loaded", false); | 412 ExtensionTestMessageListener loaded_listener("loaded", false); |
412 LoadAndLaunchPlatformApp("web_view/media_access/deny"); | 413 LoadAndLaunchPlatformApp("web_view/media_access/deny"); |
413 ASSERT_TRUE(loaded_listener.WaitUntilSatisfied()); | 414 ASSERT_TRUE(loaded_listener.WaitUntilSatisfied()); |
414 | 415 |
415 content::WebContents* embedder_web_contents = | 416 content::WebContents* embedder_web_contents = |
416 GetFirstShellWindowWebContents(); | 417 GetFirstShellWindowWebContents(); |
417 ASSERT_TRUE(embedder_web_contents); | 418 ASSERT_TRUE(embedder_web_contents); |
418 | 419 |
419 ExtensionTestMessageListener test_run_listener("PASSED", false); | 420 ExtensionTestMessageListener test_run_listener("PASSED", false); |
420 test_run_listener.AlsoListenForFailureMessage("FAILED"); | 421 test_run_listener.AlsoListenForFailureMessage("FAILED"); |
(...skipping 11 matching lines...) Expand all Loading... |
432 | 433 |
433 // This test is flaky on Windows, Chrome OS, and Mac (all platforms that | 434 // This test is flaky on Windows, Chrome OS, and Mac (all platforms that |
434 // have threaded compositing enabled). | 435 // have threaded compositing enabled). |
435 // http://crbug.com/176122 | 436 // http://crbug.com/176122 |
436 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 437 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
437 #define MAYBE_Shim DISABLED_Shim | 438 #define MAYBE_Shim DISABLED_Shim |
438 #else | 439 #else |
439 #define MAYBE_Shim Shim | 440 #define MAYBE_Shim Shim |
440 #endif | 441 #endif |
441 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_Shim) { | 442 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_Shim) { |
442 ASSERT_TRUE(StartTestServer()); | 443 ASSERT_TRUE(StartEmbeddedTestServer()); |
443 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/shim")) << message_; | 444 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/shim")) << message_; |
444 } | 445 } |
445 | 446 |
446 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) { | 447 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) { |
447 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/src_attribute")) | 448 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/src_attribute")) |
448 << message_; | 449 << message_; |
449 } | 450 } |
450 | 451 |
451 // This test verifies that prerendering has been disabled inside <webview>. | 452 // This test verifies that prerendering has been disabled inside <webview>. |
452 // This test is here rather than in PrerenderBrowserTest for testing convenience | 453 // This test is here rather than in PrerenderBrowserTest for testing convenience |
453 // only. If it breaks then this is a bug in the prerenderer. | 454 // only. If it breaks then this is a bug in the prerenderer. |
454 IN_PROC_BROWSER_TEST_F(WebViewTest, NoPrerenderer) { | 455 IN_PROC_BROWSER_TEST_F(WebViewTest, NoPrerenderer) { |
455 ASSERT_TRUE(StartTestServer()); | 456 ASSERT_TRUE(StartEmbeddedTestServer()); |
456 content::WebContents* guest_web_contents = | 457 content::WebContents* guest_web_contents = |
457 LoadGuest( | 458 LoadGuest( |
458 "files/extensions/platform_apps/web_view/noprerenderer/guest.html", | 459 "/extensions/platform_apps/web_view/noprerenderer/guest.html", |
459 "web_view/noprerenderer"); | 460 "web_view/noprerenderer"); |
460 ASSERT_TRUE(guest_web_contents != NULL); | 461 ASSERT_TRUE(guest_web_contents != NULL); |
461 | 462 |
462 PrerenderLinkManager* prerender_link_manager = | 463 PrerenderLinkManager* prerender_link_manager = |
463 PrerenderLinkManagerFactory::GetForProfile( | 464 PrerenderLinkManagerFactory::GetForProfile( |
464 Profile::FromBrowserContext(guest_web_contents->GetBrowserContext())); | 465 Profile::FromBrowserContext(guest_web_contents->GetBrowserContext())); |
465 ASSERT_TRUE(prerender_link_manager != NULL); | 466 ASSERT_TRUE(prerender_link_manager != NULL); |
466 EXPECT_TRUE(prerender_link_manager->IsEmpty()); | 467 EXPECT_TRUE(prerender_link_manager->IsEmpty()); |
467 } | 468 } |
468 | 469 |
469 // This tests cookie isolation for packaged apps with webview tags. It navigates | 470 // This tests cookie isolation for packaged apps with webview tags. It navigates |
470 // the main browser window to a page that sets a cookie and loads an app with | 471 // the main browser window to a page that sets a cookie and loads an app with |
471 // multiple webview tags. Each tag sets a cookie and the test checks the proper | 472 // multiple webview tags. Each tag sets a cookie and the test checks the proper |
472 // storage isolation is enforced. | 473 // storage isolation is enforced. |
473 IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) { | 474 IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) { |
474 ASSERT_TRUE(StartTestServer()); | 475 ASSERT_TRUE(StartEmbeddedTestServer()); |
475 const std::string kExpire = | 476 const std::string kExpire = |
476 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; | 477 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; |
477 std::string cookie_script1(kExpire); | 478 std::string cookie_script1(kExpire); |
478 cookie_script1.append( | 479 cookie_script1.append( |
479 "document.cookie = 'guest1=true; path=/; expires=' + expire + ';';"); | 480 "document.cookie = 'guest1=true; path=/; expires=' + expire + ';';"); |
480 std::string cookie_script2(kExpire); | 481 std::string cookie_script2(kExpire); |
481 cookie_script2.append( | 482 cookie_script2.append( |
482 "document.cookie = 'guest2=true; path=/; expires=' + expire + ';';"); | 483 "document.cookie = 'guest2=true; path=/; expires=' + expire + ';';"); |
483 | 484 |
484 GURL::Replacements replace_host; | 485 GURL::Replacements replace_host; |
485 std::string host_str("localhost"); // Must stay in scope with replace_host. | 486 std::string host_str("localhost"); // Must stay in scope with replace_host. |
486 replace_host.SetHostStr(host_str); | 487 replace_host.SetHostStr(host_str); |
487 | 488 |
488 GURL set_cookie_url = test_server()->GetURL( | 489 GURL set_cookie_url = embedded_test_server()->GetURL( |
489 "files/extensions/platform_apps/isolation/set_cookie.html"); | 490 "/extensions/platform_apps/isolation/set_cookie.html"); |
490 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); | 491 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); |
491 | 492 |
492 // The first two partitions will be used to set cookies and ensure they are | 493 // The first two partitions will be used to set cookies and ensure they are |
493 // shared. The named partition is used to ensure that cookies are isolated | 494 // shared. The named partition is used to ensure that cookies are isolated |
494 // between partitions within the same app. | 495 // between partitions within the same app. |
495 content::WebContents* cookie_contents1; | 496 content::WebContents* cookie_contents1; |
496 content::WebContents* cookie_contents2; | 497 content::WebContents* cookie_contents2; |
497 content::WebContents* named_partition_contents1; | 498 content::WebContents* named_partition_contents1; |
498 content::WebContents* named_partition_contents2; | 499 content::WebContents* named_partition_contents2; |
499 | 500 |
(...skipping 30 matching lines...) Expand all Loading... |
530 // The third tag should not have any cookies as it is in a separate partition. | 531 // The third tag should not have any cookies as it is in a separate partition. |
531 automation_util::GetCookies(GURL("http://localhost"), | 532 automation_util::GetCookies(GURL("http://localhost"), |
532 named_partition_contents1, | 533 named_partition_contents1, |
533 &cookie_size, &cookie_value); | 534 &cookie_size, &cookie_value); |
534 EXPECT_EQ("", cookie_value); | 535 EXPECT_EQ("", cookie_value); |
535 } | 536 } |
536 | 537 |
537 // This tests that in-memory storage partitions are reset on browser restart, | 538 // This tests that in-memory storage partitions are reset on browser restart, |
538 // but persistent ones maintain state for cookies and HTML5 storage. | 539 // but persistent ones maintain state for cookies and HTML5 storage. |
539 IN_PROC_BROWSER_TEST_F(WebViewTest, PRE_StoragePersistence) { | 540 IN_PROC_BROWSER_TEST_F(WebViewTest, PRE_StoragePersistence) { |
540 ASSERT_TRUE(StartTestServer()); | 541 ASSERT_TRUE(StartEmbeddedTestServer()); |
541 const std::string kExpire = | 542 const std::string kExpire = |
542 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; | 543 "var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; |
543 std::string cookie_script1(kExpire); | 544 std::string cookie_script1(kExpire); |
544 cookie_script1.append( | 545 cookie_script1.append( |
545 "document.cookie = 'inmemory=true; path=/; expires=' + expire + ';';"); | 546 "document.cookie = 'inmemory=true; path=/; expires=' + expire + ';';"); |
546 std::string cookie_script2(kExpire); | 547 std::string cookie_script2(kExpire); |
547 cookie_script2.append( | 548 cookie_script2.append( |
548 "document.cookie = 'persist1=true; path=/; expires=' + expire + ';';"); | 549 "document.cookie = 'persist1=true; path=/; expires=' + expire + ';';"); |
549 std::string cookie_script3(kExpire); | 550 std::string cookie_script3(kExpire); |
550 cookie_script3.append( | 551 cookie_script3.append( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 EXPECT_EQ("persist1=true", cookie_value); | 616 EXPECT_EQ("persist1=true", cookie_value); |
616 automation_util::GetCookies(GURL("http://localhost"), | 617 automation_util::GetCookies(GURL("http://localhost"), |
617 persistent_partition_contents3, | 618 persistent_partition_contents3, |
618 &cookie_size, &cookie_value); | 619 &cookie_size, &cookie_value); |
619 EXPECT_EQ("persist2=true", cookie_value); | 620 EXPECT_EQ("persist2=true", cookie_value); |
620 } | 621 } |
621 | 622 |
622 // This is the post-reset portion of the StoragePersistence test. See | 623 // This is the post-reset portion of the StoragePersistence test. See |
623 // PRE_StoragePersistence for main comment. | 624 // PRE_StoragePersistence for main comment. |
624 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_StoragePersistence) { | 625 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_StoragePersistence) { |
625 ASSERT_TRUE(StartTestServer()); | 626 ASSERT_TRUE(StartEmbeddedTestServer()); |
626 | 627 |
627 // We don't care where the main browser is on this test. | 628 // We don't care where the main browser is on this test. |
628 GURL blank_url("about:blank"); | 629 GURL blank_url("about:blank"); |
629 | 630 |
630 // The first two partitions will be used to set cookies and ensure they are | 631 // The first two partitions will be used to set cookies and ensure they are |
631 // shared. The named partition is used to ensure that cookies are isolated | 632 // shared. The named partition is used to ensure that cookies are isolated |
632 // between partitions within the same app. | 633 // between partitions within the same app. |
633 content::WebContents* cookie_contents1; | 634 content::WebContents* cookie_contents1; |
634 content::WebContents* cookie_contents2; | 635 content::WebContents* cookie_contents2; |
635 content::WebContents* named_partition_contents1; | 636 content::WebContents* named_partition_contents1; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 #define MAYBE_DOMStorageIsolation DISABLED_DOMStorageIsolation | 686 #define MAYBE_DOMStorageIsolation DISABLED_DOMStorageIsolation |
686 #else | 687 #else |
687 #define MAYBE_DOMStorageIsolation DOMStorageIsolation | 688 #define MAYBE_DOMStorageIsolation DOMStorageIsolation |
688 #endif | 689 #endif |
689 | 690 |
690 // This tests DOM storage isolation for packaged apps with webview tags. It | 691 // This tests DOM storage isolation for packaged apps with webview tags. It |
691 // loads an app with multiple webview tags and each tag sets DOM storage | 692 // loads an app with multiple webview tags and each tag sets DOM storage |
692 // entries, which the test checks to ensure proper storage isolation is | 693 // entries, which the test checks to ensure proper storage isolation is |
693 // enforced. | 694 // enforced. |
694 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_DOMStorageIsolation) { | 695 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_DOMStorageIsolation) { |
695 ASSERT_TRUE(StartTestServer()); | 696 ASSERT_TRUE(StartEmbeddedTestServer()); |
696 GURL regular_url = test_server()->GetURL("files/title1.html"); | 697 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); |
697 | 698 |
698 std::string output; | 699 std::string output; |
699 std::string get_local_storage("window.domAutomationController.send(" | 700 std::string get_local_storage("window.domAutomationController.send(" |
700 "window.localStorage.getItem('foo') || 'badval')"); | 701 "window.localStorage.getItem('foo') || 'badval')"); |
701 std::string get_session_storage("window.domAutomationController.send(" | 702 std::string get_session_storage("window.domAutomationController.send(" |
702 "window.sessionStorage.getItem('bar') || 'badval')"); | 703 "window.sessionStorage.getItem('bar') || 'badval')"); |
703 | 704 |
704 content::WebContents* default_tag_contents1; | 705 content::WebContents* default_tag_contents1; |
705 content::WebContents* default_tag_contents2; | 706 content::WebContents* default_tag_contents2; |
706 content::WebContents* storage_contents1; | 707 content::WebContents* storage_contents1; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 #if defined(OS_WIN) | 780 #if defined(OS_WIN) |
780 #define MAYBE_IndexedDBIsolation DISABLED_IndexedDBIsolation | 781 #define MAYBE_IndexedDBIsolation DISABLED_IndexedDBIsolation |
781 #else | 782 #else |
782 #define MAYBE_IndexedDBIsolation IndexedDBIsolation | 783 #define MAYBE_IndexedDBIsolation IndexedDBIsolation |
783 #endif | 784 #endif |
784 | 785 |
785 // This tests IndexedDB isolation for packaged apps with webview tags. It loads | 786 // This tests IndexedDB isolation for packaged apps with webview tags. It loads |
786 // an app with multiple webview tags and each tag creates an IndexedDB record, | 787 // an app with multiple webview tags and each tag creates an IndexedDB record, |
787 // which the test checks to ensure proper storage isolation is enforced. | 788 // which the test checks to ensure proper storage isolation is enforced. |
788 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_IndexedDBIsolation) { | 789 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_IndexedDBIsolation) { |
789 ASSERT_TRUE(StartTestServer()); | 790 ASSERT_TRUE(StartEmbeddedTestServer()); |
790 GURL regular_url = test_server()->GetURL("files/title1.html"); | 791 GURL regular_url = embedded_test_server()->GetURL("/title1.html"); |
791 | 792 |
792 content::WebContents* default_tag_contents1; | 793 content::WebContents* default_tag_contents1; |
793 content::WebContents* default_tag_contents2; | 794 content::WebContents* default_tag_contents2; |
794 content::WebContents* storage_contents1; | 795 content::WebContents* storage_contents1; |
795 content::WebContents* storage_contents2; | 796 content::WebContents* storage_contents2; |
796 | 797 |
797 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1, | 798 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1, |
798 &default_tag_contents2, &storage_contents1, | 799 &default_tag_contents2, &storage_contents1, |
799 &storage_contents2, NULL, NULL, NULL); | 800 &storage_contents2, NULL, NULL, NULL); |
800 | 801 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 MediaAccessAPIDeny_TestNoListenersImplyDeny) { | 893 MediaAccessAPIDeny_TestNoListenersImplyDeny) { |
893 MediaAccessAPIDenyTestHelper("testNoListenersImplyDeny"); | 894 MediaAccessAPIDenyTestHelper("testNoListenersImplyDeny"); |
894 } | 895 } |
895 | 896 |
896 IN_PROC_BROWSER_TEST_F(WebViewTest, | 897 IN_PROC_BROWSER_TEST_F(WebViewTest, |
897 MediaAccessAPIDeny_TestNoPreventDefaultImpliesDeny) { | 898 MediaAccessAPIDeny_TestNoPreventDefaultImpliesDeny) { |
898 MediaAccessAPIDenyTestHelper("testNoPreventDefaultImpliesDeny"); | 899 MediaAccessAPIDenyTestHelper("testNoPreventDefaultImpliesDeny"); |
899 } | 900 } |
900 | 901 |
901 void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) { | 902 void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) { |
902 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 903 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
903 ExtensionTestMessageListener launched_listener("Launched", false); | 904 ExtensionTestMessageListener launched_listener("Launched", false); |
904 LoadAndLaunchPlatformApp("web_view/media_access/allow"); | 905 LoadAndLaunchPlatformApp("web_view/media_access/allow"); |
905 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 906 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
906 | 907 |
907 content::WebContents* embedder_web_contents = | 908 content::WebContents* embedder_web_contents = |
908 GetFirstShellWindowWebContents(); | 909 GetFirstShellWindowWebContents(); |
909 ASSERT_TRUE(embedder_web_contents); | 910 ASSERT_TRUE(embedder_web_contents); |
910 MockWebContentsDelegate* mock = new MockWebContentsDelegate; | 911 MockWebContentsDelegate* mock = new MockWebContentsDelegate; |
911 embedder_web_contents->SetDelegate(mock); | 912 embedder_web_contents->SetDelegate(mock); |
912 | 913 |
(...skipping 21 matching lines...) Expand all Loading... |
934 MediaAccessAPIAllowTestHelper("testAllowTwice"); | 935 MediaAccessAPIAllowTestHelper("testAllowTwice"); |
935 } | 936 } |
936 | 937 |
937 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAsync) { | 938 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAsync) { |
938 MediaAccessAPIAllowTestHelper("testAllowAsync"); | 939 MediaAccessAPIAllowTestHelper("testAllowAsync"); |
939 } | 940 } |
940 | 941 |
941 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for | 942 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for |
942 // guests. | 943 // guests. |
943 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { | 944 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { |
944 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 945 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
945 ASSERT_TRUE(RunPlatformAppTestWithArg( | 946 ASSERT_TRUE(RunPlatformAppTestWithArg( |
946 "platform_apps/web_view/common", "screen_coordinates")) | 947 "platform_apps/web_view/common", "screen_coordinates")) |
947 << message_; | 948 << message_; |
948 } | 949 } |
949 | 950 |
950 IN_PROC_BROWSER_TEST_F(WebViewTest, SpeechRecognition) { | 951 IN_PROC_BROWSER_TEST_F(WebViewTest, SpeechRecognition) { |
951 ASSERT_TRUE(StartTestServer()); | 952 ASSERT_TRUE(StartEmbeddedTestServer()); |
952 content::WebContents* guest_web_contents = LoadGuest( | 953 content::WebContents* guest_web_contents = LoadGuest( |
953 "files/extensions/platform_apps/web_view/speech/guest.html", | 954 "/extensions/platform_apps/web_view/speech/guest.html", |
954 "web_view/speech"); | 955 "web_view/speech"); |
955 ASSERT_TRUE(guest_web_contents); | 956 ASSERT_TRUE(guest_web_contents); |
956 | 957 |
957 // Click on the guest (center of the WebContents), the guest is rendered in a | 958 // Click on the guest (center of the WebContents), the guest is rendered in a |
958 // way that this will trigger clicking on speech recognition input mic. | 959 // way that this will trigger clicking on speech recognition input mic. |
959 SimulateMouseClick(guest_web_contents, 0, WebKit::WebMouseEvent::ButtonLeft); | 960 SimulateMouseClick(guest_web_contents, 0, WebKit::WebMouseEvent::ButtonLeft); |
960 | 961 |
961 string16 expected_title(ASCIIToUTF16("PASSED")); | 962 string16 expected_title(ASCIIToUTF16("PASSED")); |
962 string16 error_title(ASCIIToUTF16("FAILED")); | 963 string16 error_title(ASCIIToUTF16("FAILED")); |
963 content::TitleWatcher title_watcher(guest_web_contents, expected_title); | 964 content::TitleWatcher title_watcher(guest_web_contents, expected_title); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 TestHelper("testMultipleBridgeIdAllow", | 1033 TestHelper("testMultipleBridgeIdAllow", |
1033 "DoneGeolocationTest.PASSED", | 1034 "DoneGeolocationTest.PASSED", |
1034 "DoneGeolocationTest.FAILED", | 1035 "DoneGeolocationTest.FAILED", |
1035 "web_view/geolocation/embedder_has_permission"); | 1036 "web_view/geolocation/embedder_has_permission"); |
1036 } | 1037 } |
1037 | 1038 |
1038 // Tests that | 1039 // Tests that |
1039 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest | 1040 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest |
1040 // is handled correctly (and does not crash). | 1041 // is handled correctly (and does not crash). |
1041 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) { | 1042 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) { |
1042 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 1043 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
1043 ASSERT_TRUE(RunPlatformAppTest( | 1044 ASSERT_TRUE(RunPlatformAppTest( |
1044 "platform_apps/web_view/geolocation/cancel_request")) << message_; | 1045 "platform_apps/web_view/geolocation/cancel_request")) << message_; |
1045 } | 1046 } |
1046 | 1047 |
1047 IN_PROC_BROWSER_TEST_F(WebViewTest, Navigation) { | 1048 IN_PROC_BROWSER_TEST_F(WebViewTest, Navigation) { |
1048 TestHelper("testNavigation", | 1049 TestHelper("testNavigation", |
1049 "DoneNavigationTest.PASSED", | 1050 "DoneNavigationTest.PASSED", |
1050 "DoneNavigationTest.FAILED", | 1051 "DoneNavigationTest.FAILED", |
1051 "web_view/navigation"); | 1052 "web_view/navigation"); |
1052 } | 1053 } |
1053 | 1054 |
1054 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) { | 1055 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) { |
1055 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 1056 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
1056 ASSERT_TRUE(RunPlatformAppTestWithArg( | 1057 ASSERT_TRUE(RunPlatformAppTestWithArg( |
1057 "platform_apps/web_view/common", "console_messages")) | 1058 "platform_apps/web_view/common", "console_messages")) |
1058 << message_; | 1059 << message_; |
1059 } | 1060 } |
1060 | 1061 |
1061 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) { | 1062 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) { |
1062 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 1063 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
1063 content::WebContents* guest_web_contents = | 1064 content::WebContents* guest_web_contents = |
1064 LoadGuest("files/extensions/platform_apps/web_view/download/guest.html", | 1065 LoadGuest("/extensions/platform_apps/web_view/download/guest.html", |
1065 "web_view/download"); | 1066 "web_view/download"); |
1066 ASSERT_TRUE(guest_web_contents); | 1067 ASSERT_TRUE(guest_web_contents); |
1067 | 1068 |
1068 // Replace WebContentsDelegate with mock version so we can intercept download | 1069 // Replace WebContentsDelegate with mock version so we can intercept download |
1069 // requests. | 1070 // requests. |
1070 content::WebContentsDelegate* delegate = guest_web_contents->GetDelegate(); | 1071 content::WebContentsDelegate* delegate = guest_web_contents->GetDelegate(); |
1071 MockDownloadWebContentsDelegate* mock_delegate = | 1072 MockDownloadWebContentsDelegate* mock_delegate = |
1072 new MockDownloadWebContentsDelegate(delegate); | 1073 new MockDownloadWebContentsDelegate(delegate); |
1073 guest_web_contents->SetDelegate(mock_delegate); | 1074 guest_web_contents->SetDelegate(mock_delegate); |
1074 | 1075 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 // Now load an app with <webview>. | 1111 // Now load an app with <webview>. |
1111 ExtensionTestMessageListener done_listener("DoneTest", false); | 1112 ExtensionTestMessageListener done_listener("DoneTest", false); |
1112 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted"); | 1113 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted"); |
1113 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); | 1114 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
1114 } | 1115 } |
1115 | 1116 |
1116 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) { | 1117 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) { |
1117 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready")) | 1118 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready")) |
1118 << message_; | 1119 << message_; |
1119 } | 1120 } |
OLD | NEW |