Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: change useCache to updateViaCache Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 *result = fetch_result.result; 634 *result = fetch_result.result;
635 *response = fetch_result.response; 635 *response = fetch_result.response;
636 *blob_data_handle = std::move(fetch_result.blob_data_handle); 636 *blob_data_handle = std::move(fetch_result.blob_data_handle);
637 ASSERT_EQ(SERVICE_WORKER_OK, fetch_result.status); 637 ASSERT_EQ(SERVICE_WORKER_OK, fetch_result.status);
638 } 638 }
639 639
640 void SetUpRegistrationOnIOThread(const std::string& worker_url) { 640 void SetUpRegistrationOnIOThread(const std::string& worker_url) {
641 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 641 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
642 const GURL pattern = embedded_test_server()->GetURL("/service_worker/"); 642 const GURL pattern = embedded_test_server()->GetURL("/service_worker/");
643 registration_ = new ServiceWorkerRegistration( 643 registration_ = new ServiceWorkerRegistration(
644 pattern, 644 ServiceWorkerRegistrationOptions(pattern),
645 wrapper()->context()->storage()->NewRegistrationId(), 645 wrapper()->context()->storage()->NewRegistrationId(),
646 wrapper()->context()->AsWeakPtr()); 646 wrapper()->context()->AsWeakPtr());
647 // Set the update check time to avoid triggering updates in the middle of 647 // Set the update check time to avoid triggering updates in the middle of
648 // tests. 648 // tests.
649 registration_->set_last_update_check(base::Time::Now()); 649 registration_->set_last_update_check(base::Time::Now());
650 650
651 version_ = new ServiceWorkerVersion( 651 version_ = new ServiceWorkerVersion(
652 registration_.get(), 652 registration_.get(),
653 embedded_test_server()->GetURL(worker_url), 653 embedded_test_server()->GetURL(worker_url),
654 wrapper()->context()->storage()->NewVersionId(), 654 wrapper()->context()->storage()->NewVersionId(),
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 content_browser_client.set_data_saver_enabled(true); 1399 content_browser_client.set_data_saver_enabled(true);
1400 ContentBrowserClient* old_client = 1400 ContentBrowserClient* old_client =
1401 SetBrowserClientForTesting(&content_browser_client); 1401 SetBrowserClientForTesting(&content_browser_client);
1402 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); 1402 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged();
1403 scoped_refptr<WorkerActivatedObserver> observer = 1403 scoped_refptr<WorkerActivatedObserver> observer =
1404 new WorkerActivatedObserver(wrapper()); 1404 new WorkerActivatedObserver(wrapper());
1405 observer->Init(); 1405 observer->Init();
1406 public_context()->RegisterServiceWorker( 1406 public_context()->RegisterServiceWorker(
1407 embedded_test_server()->GetURL(kPageUrl), 1407 embedded_test_server()->GetURL(kPageUrl),
1408 embedded_test_server()->GetURL(kWorkerUrl), 1408 embedded_test_server()->GetURL(kWorkerUrl),
1409 blink::WebServiceWorkerUpdateViaCache::kImports,
1409 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 1410 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1410 observer->Wait(); 1411 observer->Wait();
1411 1412
1412 const base::string16 title1 = base::ASCIIToUTF16("save-data=on"); 1413 const base::string16 title1 = base::ASCIIToUTF16("save-data=on");
1413 TitleWatcher title_watcher1(shell()->web_contents(), title1); 1414 TitleWatcher title_watcher1(shell()->web_contents(), title1);
1414 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); 1415 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl));
1415 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); 1416 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle());
1416 1417
1417 SetBrowserClientForTesting(old_client); 1418 SetBrowserClientForTesting(old_client);
1418 shell()->Close(); 1419 shell()->Close();
(...skipping 22 matching lines...) Expand all
1441 content_browser_client.set_data_saver_enabled(true); 1442 content_browser_client.set_data_saver_enabled(true);
1442 ContentBrowserClient* old_client = 1443 ContentBrowserClient* old_client =
1443 SetBrowserClientForTesting(&content_browser_client); 1444 SetBrowserClientForTesting(&content_browser_client);
1444 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); 1445 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged();
1445 scoped_refptr<WorkerActivatedObserver> observer = 1446 scoped_refptr<WorkerActivatedObserver> observer =
1446 new WorkerActivatedObserver(wrapper()); 1447 new WorkerActivatedObserver(wrapper());
1447 observer->Init(); 1448 observer->Init();
1448 public_context()->RegisterServiceWorker( 1449 public_context()->RegisterServiceWorker(
1449 embedded_test_server()->GetURL(kPageUrl), 1450 embedded_test_server()->GetURL(kPageUrl),
1450 embedded_test_server()->GetURL(kWorkerUrl), 1451 embedded_test_server()->GetURL(kWorkerUrl),
1452 blink::WebServiceWorkerUpdateViaCache::kImports,
1451 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 1453 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1452 observer->Wait(); 1454 observer->Wait();
1453 1455
1454 const base::string16 title = base::ASCIIToUTF16("PASS"); 1456 const base::string16 title = base::ASCIIToUTF16("PASS");
1455 TitleWatcher title_watcher(shell()->web_contents(), title); 1457 TitleWatcher title_watcher(shell()->web_contents(), title);
1456 NavigateToURL(shell(), 1458 NavigateToURL(shell(),
1457 embedded_test_server()->GetURL(base::StringPrintf( 1459 embedded_test_server()->GetURL(base::StringPrintf(
1458 "%s?%s", kPageUrl, 1460 "%s?%s", kPageUrl,
1459 cross_origin_server.GetURL("/cross_origin_request.html") 1461 cross_origin_server.GetURL("/cross_origin_request.html")
1460 .spec() 1462 .spec()
(...skipping 23 matching lines...) Expand all
1484 new WorkerActivatedObserver(wrapper()); 1486 new WorkerActivatedObserver(wrapper());
1485 observer->Init(); 1487 observer->Init();
1486 1488
1487 embedded_test_server()->RegisterRequestHandler( 1489 embedded_test_server()->RegisterRequestHandler(
1488 base::Bind(&VerifySaveDataHeaderInRequest)); 1490 base::Bind(&VerifySaveDataHeaderInRequest));
1489 StartServerAndNavigateToSetup(); 1491 StartServerAndNavigateToSetup();
1490 1492
1491 public_context()->RegisterServiceWorker( 1493 public_context()->RegisterServiceWorker(
1492 embedded_test_server()->GetURL(kPageUrl), 1494 embedded_test_server()->GetURL(kPageUrl),
1493 embedded_test_server()->GetURL(kWorkerUrl), 1495 embedded_test_server()->GetURL(kWorkerUrl),
1496 blink::WebServiceWorkerUpdateViaCache::kImports,
1494 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 1497 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1495 observer->Wait(); 1498 observer->Wait();
1496 1499
1497 NavigateToURLBlockUntilNavigationsComplete( 1500 NavigateToURLBlockUntilNavigationsComplete(
1498 shell(), embedded_test_server()->GetURL(kPageUrl), 1); 1501 shell(), embedded_test_server()->GetURL(kPageUrl), 1);
1499 1502
1500 SetBrowserClientForTesting(old_client); 1503 SetBrowserClientForTesting(old_client);
1501 shell()->Close(); 1504 shell()->Close();
1502 1505
1503 base::RunLoop run_loop; 1506 base::RunLoop run_loop;
1504 public_context()->UnregisterServiceWorker( 1507 public_context()->UnregisterServiceWorker(
1505 embedded_test_server()->GetURL(kPageUrl), 1508 embedded_test_server()->GetURL(kPageUrl),
1506 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); 1509 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure()));
1507 run_loop.Run(); 1510 run_loop.Run();
1508 } 1511 }
1509 1512
1510 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, Reload) { 1513 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, Reload) {
1511 StartServerAndNavigateToSetup(); 1514 StartServerAndNavigateToSetup();
1512 const char kPageUrl[] = "/service_worker/reload.html"; 1515 const char kPageUrl[] = "/service_worker/reload.html";
1513 const char kWorkerUrl[] = "/service_worker/fetch_event_reload.js"; 1516 const char kWorkerUrl[] = "/service_worker/fetch_event_reload.js";
1514 scoped_refptr<WorkerActivatedObserver> observer = 1517 scoped_refptr<WorkerActivatedObserver> observer =
1515 new WorkerActivatedObserver(wrapper()); 1518 new WorkerActivatedObserver(wrapper());
1516 observer->Init(); 1519 observer->Init();
1517 public_context()->RegisterServiceWorker( 1520 public_context()->RegisterServiceWorker(
1518 embedded_test_server()->GetURL(kPageUrl), 1521 embedded_test_server()->GetURL(kPageUrl),
1519 embedded_test_server()->GetURL(kWorkerUrl), 1522 embedded_test_server()->GetURL(kWorkerUrl),
1523 blink::WebServiceWorkerUpdateViaCache::kImports,
1520 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 1524 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1521 observer->Wait(); 1525 observer->Wait();
1522 1526
1523 const base::string16 title1 = base::ASCIIToUTF16("reload=false"); 1527 const base::string16 title1 = base::ASCIIToUTF16("reload=false");
1524 TitleWatcher title_watcher1(shell()->web_contents(), title1); 1528 TitleWatcher title_watcher1(shell()->web_contents(), title1);
1525 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); 1529 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl));
1526 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); 1530 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle());
1527 1531
1528 const base::string16 title2 = base::ASCIIToUTF16("reload=true"); 1532 const base::string16 title2 = base::ASCIIToUTF16("reload=true");
1529 TitleWatcher title_watcher2(shell()->web_contents(), title2); 1533 TitleWatcher title_watcher2(shell()->web_contents(), title2);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 callback.Run(HeaderInterceptorResult::KILL); 1587 callback.Run(HeaderInterceptorResult::KILL);
1584 } 1588 }
1585 1589
1586 void SetupForNavigationPreloadTest(const GURL& scope, 1590 void SetupForNavigationPreloadTest(const GURL& scope,
1587 const GURL& worker_url) { 1591 const GURL& worker_url) {
1588 scoped_refptr<WorkerActivatedObserver> observer = 1592 scoped_refptr<WorkerActivatedObserver> observer =
1589 new WorkerActivatedObserver(wrapper()); 1593 new WorkerActivatedObserver(wrapper());
1590 observer->Init(); 1594 observer->Init();
1591 1595
1592 public_context()->RegisterServiceWorker( 1596 public_context()->RegisterServiceWorker(
1593 scope, worker_url, 1597 scope, worker_url, blink::WebServiceWorkerUpdateViaCache::kImports,
1594 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 1598 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1595 observer->Wait(); 1599 observer->Wait();
1596 } 1600 }
1597 1601
1598 std::string LoadNavigationPreloadTestPage(const GURL& page_url, 1602 std::string LoadNavigationPreloadTestPage(const GURL& page_url,
1599 const GURL& worker_url, 1603 const GURL& worker_url,
1600 const char* expected_result) { 1604 const char* expected_result) {
1601 RegisterMonitorRequestHandler(); 1605 RegisterMonitorRequestHandler();
1602 StartServerAndNavigateToSetup(); 1606 StartServerAndNavigateToSetup();
1603 SetupForNavigationPreloadTest(page_url, worker_url); 1607 SetupForNavigationPreloadTest(page_url, worker_url);
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; 2292 const char kPageUrl[] = "/service_worker/fetch_event_blob.html";
2289 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; 2293 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
2290 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 2294 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
2291 https_server.ServeFilesFromSourceDirectory("content/test/data"); 2295 https_server.ServeFilesFromSourceDirectory("content/test/data");
2292 ASSERT_TRUE(https_server.Start()); 2296 ASSERT_TRUE(https_server.Start());
2293 2297
2294 scoped_refptr<WorkerActivatedObserver> observer = 2298 scoped_refptr<WorkerActivatedObserver> observer =
2295 new WorkerActivatedObserver(wrapper()); 2299 new WorkerActivatedObserver(wrapper());
2296 observer->Init(); 2300 observer->Init();
2297 public_context()->RegisterServiceWorker( 2301 public_context()->RegisterServiceWorker(
2298 https_server.GetURL(kPageUrl), 2302 https_server.GetURL(kPageUrl), https_server.GetURL(kWorkerUrl),
2299 https_server.GetURL(kWorkerUrl), 2303 blink::WebServiceWorkerUpdateViaCache::kImports,
2300 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 2304 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
2301 observer->Wait(); 2305 observer->Wait();
2302 2306
2303 const base::string16 title = base::ASCIIToUTF16("Title"); 2307 const base::string16 title = base::ASCIIToUTF16("Title");
2304 TitleWatcher title_watcher(shell()->web_contents(), title); 2308 TitleWatcher title_watcher(shell()->web_contents(), title);
2305 NavigateToURL(shell(), https_server.GetURL(kPageUrl)); 2309 NavigateToURL(shell(), https_server.GetURL(kPageUrl));
2306 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 2310 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
2307 NavigationEntry* entry = 2311 NavigationEntry* entry =
2308 shell()->web_contents()->GetController().GetVisibleEntry(); 2312 shell()->web_contents()->GetController().GetVisibleEntry();
2309 EXPECT_TRUE(entry->GetSSL().initialized); 2313 EXPECT_TRUE(entry->GetSSL().initialized);
(...skipping 16 matching lines...) Expand all
2326 ResponseFromHTTPServiceWorkerIsNotMarkedAsSecure) { 2330 ResponseFromHTTPServiceWorkerIsNotMarkedAsSecure) {
2327 StartServerAndNavigateToSetup(); 2331 StartServerAndNavigateToSetup();
2328 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; 2332 const char kPageUrl[] = "/service_worker/fetch_event_blob.html";
2329 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; 2333 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
2330 scoped_refptr<WorkerActivatedObserver> observer = 2334 scoped_refptr<WorkerActivatedObserver> observer =
2331 new WorkerActivatedObserver(wrapper()); 2335 new WorkerActivatedObserver(wrapper());
2332 observer->Init(); 2336 observer->Init();
2333 public_context()->RegisterServiceWorker( 2337 public_context()->RegisterServiceWorker(
2334 embedded_test_server()->GetURL(kPageUrl), 2338 embedded_test_server()->GetURL(kPageUrl),
2335 embedded_test_server()->GetURL(kWorkerUrl), 2339 embedded_test_server()->GetURL(kWorkerUrl),
2340 blink::WebServiceWorkerUpdateViaCache::kImports,
2336 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 2341 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
2337 observer->Wait(); 2342 observer->Wait();
2338 2343
2339 const base::string16 title = base::ASCIIToUTF16("Title"); 2344 const base::string16 title = base::ASCIIToUTF16("Title");
2340 TitleWatcher title_watcher(shell()->web_contents(), title); 2345 TitleWatcher title_watcher(shell()->web_contents(), title);
2341 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); 2346 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl));
2342 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 2347 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
2343 NavigationEntry* entry = 2348 NavigationEntry* entry =
2344 shell()->web_contents()->GetController().GetVisibleEntry(); 2349 shell()->web_contents()->GetController().GetVisibleEntry();
2345 EXPECT_TRUE(entry->GetSSL().initialized); 2350 EXPECT_TRUE(entry->GetSSL().initialized);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); 2444 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure()));
2440 run_loop.Run(); 2445 run_loop.Run();
2441 } 2446 }
2442 2447
2443 // If we use a worker URL that doesn't exist, registration fails. 2448 // If we use a worker URL that doesn't exist, registration fails.
2444 { 2449 {
2445 base::RunLoop run_loop; 2450 base::RunLoop run_loop;
2446 public_context()->RegisterServiceWorker( 2451 public_context()->RegisterServiceWorker(
2447 embedded_test_server()->GetURL(kScope), 2452 embedded_test_server()->GetURL(kScope),
2448 embedded_test_server()->GetURL("/does/not/exist"), 2453 embedded_test_server()->GetURL("/does/not/exist"),
2454 blink::WebServiceWorkerUpdateViaCache::kImports,
2449 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); 2455 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure()));
2450 run_loop.Run(); 2456 run_loop.Run();
2451 } 2457 }
2452 EXPECT_EQ(0, CountRenderProcessHosts()); 2458 EXPECT_EQ(0, CountRenderProcessHosts());
2453 2459
2454 // Register returns when the promise would be resolved. 2460 // Register returns when the promise would be resolved.
2455 { 2461 {
2456 base::RunLoop run_loop; 2462 base::RunLoop run_loop;
2457 public_context()->RegisterServiceWorker( 2463 public_context()->RegisterServiceWorker(
2458 embedded_test_server()->GetURL(kScope), 2464 embedded_test_server()->GetURL(kScope),
2459 embedded_test_server()->GetURL(kWorkerUrl), 2465 embedded_test_server()->GetURL(kWorkerUrl),
2466 blink::WebServiceWorkerUpdateViaCache::kImports,
2460 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); 2467 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure()));
2461 run_loop.Run(); 2468 run_loop.Run();
2462 } 2469 }
2463 EXPECT_EQ(1, CountRenderProcessHosts()); 2470 EXPECT_EQ(1, CountRenderProcessHosts());
2464 2471
2465 // Registering again should succeed, although the algo still 2472 // Registering again should succeed, although the algo still
2466 // might not be complete. 2473 // might not be complete.
2467 { 2474 {
2468 base::RunLoop run_loop; 2475 base::RunLoop run_loop;
2469 public_context()->RegisterServiceWorker( 2476 public_context()->RegisterServiceWorker(
2470 embedded_test_server()->GetURL(kScope), 2477 embedded_test_server()->GetURL(kScope),
2471 embedded_test_server()->GetURL(kWorkerUrl), 2478 embedded_test_server()->GetURL(kWorkerUrl),
2479 blink::WebServiceWorkerUpdateViaCache::kImports,
2472 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); 2480 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure()));
2473 run_loop.Run(); 2481 run_loop.Run();
2474 } 2482 }
2475 2483
2476 // The registration algo might not be far enough along to have 2484 // The registration algo might not be far enough along to have
2477 // stored the registration data, so it may not be findable 2485 // stored the registration data, so it may not be findable
2478 // at this point. 2486 // at this point.
2479 2487
2480 // Unregistering something should return true. 2488 // Unregistering something should return true.
2481 { 2489 {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 static const std::string kScriptUrl; 2779 static const std::string kScriptUrl;
2772 static const int kV8CacheTimeStampDataSize; 2780 static const int kV8CacheTimeStampDataSize;
2773 2781
2774 void RegisterAndActivateServiceWorker() { 2782 void RegisterAndActivateServiceWorker() {
2775 scoped_refptr<WorkerActivatedObserver> observer = 2783 scoped_refptr<WorkerActivatedObserver> observer =
2776 new WorkerActivatedObserver(wrapper()); 2784 new WorkerActivatedObserver(wrapper());
2777 observer->Init(); 2785 observer->Init();
2778 public_context()->RegisterServiceWorker( 2786 public_context()->RegisterServiceWorker(
2779 embedded_test_server()->GetURL(kPageUrl), 2787 embedded_test_server()->GetURL(kPageUrl),
2780 embedded_test_server()->GetURL(kWorkerUrl), 2788 embedded_test_server()->GetURL(kWorkerUrl),
2789 blink::WebServiceWorkerUpdateViaCache::kImports,
2781 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 2790 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
2782 observer->Wait(); 2791 observer->Wait();
2783 } 2792 }
2784 2793
2785 void NavigateToTestPage() { 2794 void NavigateToTestPage() {
2786 const base::string16 title = 2795 const base::string16 title =
2787 base::ASCIIToUTF16("Title was changed by the script."); 2796 base::ASCIIToUTF16("Title was changed by the script.");
2788 TitleWatcher title_watcher(shell()->web_contents(), title); 2797 TitleWatcher title_watcher(shell()->web_contents(), title);
2789 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); 2798 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl));
2790 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 2799 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 ServiceWorkerBrowserTest::SetUpOnMainThread(); 2918 ServiceWorkerBrowserTest::SetUpOnMainThread();
2910 } 2919 }
2911 2920
2912 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope, 2921 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope,
2913 const std::string& script) { 2922 const std::string& script) {
2914 scoped_refptr<WorkerActivatedObserver> observer = 2923 scoped_refptr<WorkerActivatedObserver> observer =
2915 new WorkerActivatedObserver(wrapper()); 2924 new WorkerActivatedObserver(wrapper());
2916 observer->Init(); 2925 observer->Init();
2917 public_context()->RegisterServiceWorker( 2926 public_context()->RegisterServiceWorker(
2918 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script), 2927 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script),
2928 blink::WebServiceWorkerUpdateViaCache::kImports,
2919 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); 2929 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
2920 observer->Wait(); 2930 observer->Wait();
2921 } 2931 }
2922 2932
2923 void RunTestWithCrossOriginURL(const std::string& test_page, 2933 void RunTestWithCrossOriginURL(const std::string& test_page,
2924 const std::string& cross_origin_url) { 2934 const std::string& cross_origin_url) {
2925 const base::string16 title = base::ASCIIToUTF16("PASS"); 2935 const base::string16 title = base::ASCIIToUTF16("PASS");
2926 TitleWatcher title_watcher(shell()->web_contents(), title); 2936 TitleWatcher title_watcher(shell()->web_contents(), title);
2927 NavigateToURL(shell(), 2937 NavigateToURL(shell(),
2928 embedded_test_server()->GetURL( 2938 embedded_test_server()->GetURL(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) { 2975 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) {
2966 StartServerAndNavigateToSetup(); 2976 StartServerAndNavigateToSetup();
2967 const char kPageUrl[] = "/service_worker/disable_web_security_update.html"; 2977 const char kPageUrl[] = "/service_worker/disable_web_security_update.html";
2968 const char kScopeUrl[] = "/service_worker/scope/"; 2978 const char kScopeUrl[] = "/service_worker/scope/";
2969 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; 2979 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
2970 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl); 2980 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl);
2971 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); 2981 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
2972 } 2982 }
2973 2983
2974 } // namespace content 2984 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698