| OLD | NEW |
| 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 *result = fetch_result.result; | 564 *result = fetch_result.result; |
| 565 *response = fetch_result.response; | 565 *response = fetch_result.response; |
| 566 *blob_data_handle = std::move(fetch_result.blob_data_handle); | 566 *blob_data_handle = std::move(fetch_result.blob_data_handle); |
| 567 ASSERT_EQ(SERVICE_WORKER_OK, fetch_result.status); | 567 ASSERT_EQ(SERVICE_WORKER_OK, fetch_result.status); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void SetUpRegistrationOnIOThread(const std::string& worker_url) { | 570 void SetUpRegistrationOnIOThread(const std::string& worker_url) { |
| 571 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 571 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 572 const GURL pattern = embedded_test_server()->GetURL("/service_worker/"); | 572 const GURL pattern = embedded_test_server()->GetURL("/service_worker/"); |
| 573 registration_ = new ServiceWorkerRegistration( | 573 registration_ = new ServiceWorkerRegistration( |
| 574 pattern, | 574 pattern, false, wrapper()->context()->storage()->NewRegistrationId(), |
| 575 wrapper()->context()->storage()->NewRegistrationId(), | |
| 576 wrapper()->context()->AsWeakPtr()); | 575 wrapper()->context()->AsWeakPtr()); |
| 577 // Set the update check time to avoid triggering updates in the middle of | 576 // Set the update check time to avoid triggering updates in the middle of |
| 578 // tests. | 577 // tests. |
| 579 registration_->set_last_update_check(base::Time::Now()); | 578 registration_->set_last_update_check(base::Time::Now()); |
| 580 | 579 |
| 581 version_ = new ServiceWorkerVersion( | 580 version_ = new ServiceWorkerVersion( |
| 582 registration_.get(), | 581 registration_.get(), |
| 583 embedded_test_server()->GetURL(worker_url), | 582 embedded_test_server()->GetURL(worker_url), |
| 584 wrapper()->context()->storage()->NewVersionId(), | 583 wrapper()->context()->storage()->NewVersionId(), |
| 585 wrapper()->context()->AsWeakPtr()); | 584 wrapper()->context()->AsWeakPtr()); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 MockContentBrowserClient content_browser_client; | 1300 MockContentBrowserClient content_browser_client; |
| 1302 content_browser_client.set_data_saver_enabled(true); | 1301 content_browser_client.set_data_saver_enabled(true); |
| 1303 ContentBrowserClient* old_client = | 1302 ContentBrowserClient* old_client = |
| 1304 SetBrowserClientForTesting(&content_browser_client); | 1303 SetBrowserClientForTesting(&content_browser_client); |
| 1305 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 1304 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
| 1306 scoped_refptr<WorkerActivatedObserver> observer = | 1305 scoped_refptr<WorkerActivatedObserver> observer = |
| 1307 new WorkerActivatedObserver(wrapper()); | 1306 new WorkerActivatedObserver(wrapper()); |
| 1308 observer->Init(); | 1307 observer->Init(); |
| 1309 public_context()->RegisterServiceWorker( | 1308 public_context()->RegisterServiceWorker( |
| 1310 embedded_test_server()->GetURL(kPageUrl), | 1309 embedded_test_server()->GetURL(kPageUrl), |
| 1311 embedded_test_server()->GetURL(kWorkerUrl), | 1310 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 1312 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1311 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 1313 observer->Wait(); | 1312 observer->Wait(); |
| 1314 | 1313 |
| 1315 const base::string16 title1 = base::ASCIIToUTF16("save-data=on"); | 1314 const base::string16 title1 = base::ASCIIToUTF16("save-data=on"); |
| 1316 TitleWatcher title_watcher1(shell()->web_contents(), title1); | 1315 TitleWatcher title_watcher1(shell()->web_contents(), title1); |
| 1317 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); | 1316 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); |
| 1318 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); | 1317 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); |
| 1319 | 1318 |
| 1320 SetBrowserClientForTesting(old_client); | 1319 SetBrowserClientForTesting(old_client); |
| 1321 shell()->Close(); | 1320 shell()->Close(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1343 MockContentBrowserClient content_browser_client; | 1342 MockContentBrowserClient content_browser_client; |
| 1344 content_browser_client.set_data_saver_enabled(true); | 1343 content_browser_client.set_data_saver_enabled(true); |
| 1345 ContentBrowserClient* old_client = | 1344 ContentBrowserClient* old_client = |
| 1346 SetBrowserClientForTesting(&content_browser_client); | 1345 SetBrowserClientForTesting(&content_browser_client); |
| 1347 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 1346 shell()->web_contents()->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
| 1348 scoped_refptr<WorkerActivatedObserver> observer = | 1347 scoped_refptr<WorkerActivatedObserver> observer = |
| 1349 new WorkerActivatedObserver(wrapper()); | 1348 new WorkerActivatedObserver(wrapper()); |
| 1350 observer->Init(); | 1349 observer->Init(); |
| 1351 public_context()->RegisterServiceWorker( | 1350 public_context()->RegisterServiceWorker( |
| 1352 embedded_test_server()->GetURL(kPageUrl), | 1351 embedded_test_server()->GetURL(kPageUrl), |
| 1353 embedded_test_server()->GetURL(kWorkerUrl), | 1352 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 1354 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1353 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 1355 observer->Wait(); | 1354 observer->Wait(); |
| 1356 | 1355 |
| 1357 const base::string16 title = base::ASCIIToUTF16("PASS"); | 1356 const base::string16 title = base::ASCIIToUTF16("PASS"); |
| 1358 TitleWatcher title_watcher(shell()->web_contents(), title); | 1357 TitleWatcher title_watcher(shell()->web_contents(), title); |
| 1359 NavigateToURL(shell(), | 1358 NavigateToURL(shell(), |
| 1360 embedded_test_server()->GetURL(base::StringPrintf( | 1359 embedded_test_server()->GetURL(base::StringPrintf( |
| 1361 "%s?%s", kPageUrl, | 1360 "%s?%s", kPageUrl, |
| 1362 cross_origin_server.GetURL("/cross_origin_request.html") | 1361 cross_origin_server.GetURL("/cross_origin_request.html") |
| 1363 .spec() | 1362 .spec() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1386 scoped_refptr<WorkerActivatedObserver> observer = | 1385 scoped_refptr<WorkerActivatedObserver> observer = |
| 1387 new WorkerActivatedObserver(wrapper()); | 1386 new WorkerActivatedObserver(wrapper()); |
| 1388 observer->Init(); | 1387 observer->Init(); |
| 1389 | 1388 |
| 1390 embedded_test_server()->RegisterRequestHandler( | 1389 embedded_test_server()->RegisterRequestHandler( |
| 1391 base::Bind(&VerifySaveDataHeaderInRequest)); | 1390 base::Bind(&VerifySaveDataHeaderInRequest)); |
| 1392 StartServerAndNavigateToSetup(); | 1391 StartServerAndNavigateToSetup(); |
| 1393 | 1392 |
| 1394 public_context()->RegisterServiceWorker( | 1393 public_context()->RegisterServiceWorker( |
| 1395 embedded_test_server()->GetURL(kPageUrl), | 1394 embedded_test_server()->GetURL(kPageUrl), |
| 1396 embedded_test_server()->GetURL(kWorkerUrl), | 1395 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 1397 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1396 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 1398 observer->Wait(); | 1397 observer->Wait(); |
| 1399 | 1398 |
| 1400 NavigateToURLBlockUntilNavigationsComplete( | 1399 NavigateToURLBlockUntilNavigationsComplete( |
| 1401 shell(), embedded_test_server()->GetURL(kPageUrl), 1); | 1400 shell(), embedded_test_server()->GetURL(kPageUrl), 1); |
| 1402 | 1401 |
| 1403 SetBrowserClientForTesting(old_client); | 1402 SetBrowserClientForTesting(old_client); |
| 1404 shell()->Close(); | 1403 shell()->Close(); |
| 1405 | 1404 |
| 1406 base::RunLoop run_loop; | 1405 base::RunLoop run_loop; |
| 1407 public_context()->UnregisterServiceWorker( | 1406 public_context()->UnregisterServiceWorker( |
| 1408 embedded_test_server()->GetURL(kPageUrl), | 1407 embedded_test_server()->GetURL(kPageUrl), |
| 1409 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 1408 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
| 1410 run_loop.Run(); | 1409 run_loop.Run(); |
| 1411 } | 1410 } |
| 1412 | 1411 |
| 1413 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, Reload) { | 1412 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, Reload) { |
| 1414 StartServerAndNavigateToSetup(); | 1413 StartServerAndNavigateToSetup(); |
| 1415 const char kPageUrl[] = "/service_worker/reload.html"; | 1414 const char kPageUrl[] = "/service_worker/reload.html"; |
| 1416 const char kWorkerUrl[] = "/service_worker/fetch_event_reload.js"; | 1415 const char kWorkerUrl[] = "/service_worker/fetch_event_reload.js"; |
| 1417 scoped_refptr<WorkerActivatedObserver> observer = | 1416 scoped_refptr<WorkerActivatedObserver> observer = |
| 1418 new WorkerActivatedObserver(wrapper()); | 1417 new WorkerActivatedObserver(wrapper()); |
| 1419 observer->Init(); | 1418 observer->Init(); |
| 1420 public_context()->RegisterServiceWorker( | 1419 public_context()->RegisterServiceWorker( |
| 1421 embedded_test_server()->GetURL(kPageUrl), | 1420 embedded_test_server()->GetURL(kPageUrl), |
| 1422 embedded_test_server()->GetURL(kWorkerUrl), | 1421 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 1423 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1422 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 1424 observer->Wait(); | 1423 observer->Wait(); |
| 1425 | 1424 |
| 1426 const base::string16 title1 = base::ASCIIToUTF16("reload=false"); | 1425 const base::string16 title1 = base::ASCIIToUTF16("reload=false"); |
| 1427 TitleWatcher title_watcher1(shell()->web_contents(), title1); | 1426 TitleWatcher title_watcher1(shell()->web_contents(), title1); |
| 1428 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); | 1427 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); |
| 1429 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); | 1428 EXPECT_EQ(title1, title_watcher1.WaitAndGetTitle()); |
| 1430 | 1429 |
| 1431 const base::string16 title2 = base::ASCIIToUTF16("reload=true"); | 1430 const base::string16 title2 = base::ASCIIToUTF16("reload=true"); |
| 1432 TitleWatcher title_watcher2(shell()->web_contents(), title2); | 1431 TitleWatcher title_watcher2(shell()->web_contents(), title2); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 callback.Run(false, 0); | 1485 callback.Run(false, 0); |
| 1487 } | 1486 } |
| 1488 | 1487 |
| 1489 void SetupForNavigationPreloadTest(const GURL& scope, | 1488 void SetupForNavigationPreloadTest(const GURL& scope, |
| 1490 const GURL& worker_url) { | 1489 const GURL& worker_url) { |
| 1491 scoped_refptr<WorkerActivatedObserver> observer = | 1490 scoped_refptr<WorkerActivatedObserver> observer = |
| 1492 new WorkerActivatedObserver(wrapper()); | 1491 new WorkerActivatedObserver(wrapper()); |
| 1493 observer->Init(); | 1492 observer->Init(); |
| 1494 | 1493 |
| 1495 public_context()->RegisterServiceWorker( | 1494 public_context()->RegisterServiceWorker( |
| 1496 scope, worker_url, | 1495 scope, worker_url, false, |
| 1497 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1496 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 1498 observer->Wait(); | 1497 observer->Wait(); |
| 1499 } | 1498 } |
| 1500 | 1499 |
| 1501 void RegisterMonitorRequestHandler() { | 1500 void RegisterMonitorRequestHandler() { |
| 1502 embedded_test_server()->RegisterRequestMonitor( | 1501 embedded_test_server()->RegisterRequestMonitor( |
| 1503 base::Bind(&self::MonitorRequestHandler, base::Unretained(this))); | 1502 base::Bind(&self::MonitorRequestHandler, base::Unretained(this))); |
| 1504 } | 1503 } |
| 1505 | 1504 |
| 1506 void RegisterStaticFile(const std::string& relative_url, | 1505 void RegisterStaticFile(const std::string& relative_url, |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; | 2195 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; |
| 2197 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; | 2196 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; |
| 2198 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 2197 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 2199 https_server.ServeFilesFromSourceDirectory("content/test/data"); | 2198 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
| 2200 ASSERT_TRUE(https_server.Start()); | 2199 ASSERT_TRUE(https_server.Start()); |
| 2201 | 2200 |
| 2202 scoped_refptr<WorkerActivatedObserver> observer = | 2201 scoped_refptr<WorkerActivatedObserver> observer = |
| 2203 new WorkerActivatedObserver(wrapper()); | 2202 new WorkerActivatedObserver(wrapper()); |
| 2204 observer->Init(); | 2203 observer->Init(); |
| 2205 public_context()->RegisterServiceWorker( | 2204 public_context()->RegisterServiceWorker( |
| 2206 https_server.GetURL(kPageUrl), | 2205 https_server.GetURL(kPageUrl), https_server.GetURL(kWorkerUrl), false, |
| 2207 https_server.GetURL(kWorkerUrl), | |
| 2208 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 2206 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 2209 observer->Wait(); | 2207 observer->Wait(); |
| 2210 | 2208 |
| 2211 const base::string16 title = base::ASCIIToUTF16("Title"); | 2209 const base::string16 title = base::ASCIIToUTF16("Title"); |
| 2212 TitleWatcher title_watcher(shell()->web_contents(), title); | 2210 TitleWatcher title_watcher(shell()->web_contents(), title); |
| 2213 NavigateToURL(shell(), https_server.GetURL(kPageUrl)); | 2211 NavigateToURL(shell(), https_server.GetURL(kPageUrl)); |
| 2214 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | 2212 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); |
| 2215 NavigationEntry* entry = | 2213 NavigationEntry* entry = |
| 2216 shell()->web_contents()->GetController().GetVisibleEntry(); | 2214 shell()->web_contents()->GetController().GetVisibleEntry(); |
| 2217 EXPECT_TRUE(entry->GetSSL().initialized); | 2215 EXPECT_TRUE(entry->GetSSL().initialized); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2233 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, | 2231 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, |
| 2234 ResponseFromHTTPServiceWorkerIsNotMarkedAsSecure) { | 2232 ResponseFromHTTPServiceWorkerIsNotMarkedAsSecure) { |
| 2235 StartServerAndNavigateToSetup(); | 2233 StartServerAndNavigateToSetup(); |
| 2236 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; | 2234 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; |
| 2237 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; | 2235 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; |
| 2238 scoped_refptr<WorkerActivatedObserver> observer = | 2236 scoped_refptr<WorkerActivatedObserver> observer = |
| 2239 new WorkerActivatedObserver(wrapper()); | 2237 new WorkerActivatedObserver(wrapper()); |
| 2240 observer->Init(); | 2238 observer->Init(); |
| 2241 public_context()->RegisterServiceWorker( | 2239 public_context()->RegisterServiceWorker( |
| 2242 embedded_test_server()->GetURL(kPageUrl), | 2240 embedded_test_server()->GetURL(kPageUrl), |
| 2243 embedded_test_server()->GetURL(kWorkerUrl), | 2241 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 2244 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 2242 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 2245 observer->Wait(); | 2243 observer->Wait(); |
| 2246 | 2244 |
| 2247 const base::string16 title = base::ASCIIToUTF16("Title"); | 2245 const base::string16 title = base::ASCIIToUTF16("Title"); |
| 2248 TitleWatcher title_watcher(shell()->web_contents(), title); | 2246 TitleWatcher title_watcher(shell()->web_contents(), title); |
| 2249 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); | 2247 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); |
| 2250 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | 2248 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); |
| 2251 NavigationEntry* entry = | 2249 NavigationEntry* entry = |
| 2252 shell()->web_contents()->GetController().GetVisibleEntry(); | 2250 shell()->web_contents()->GetController().GetVisibleEntry(); |
| 2253 EXPECT_TRUE(entry->GetSSL().initialized); | 2251 EXPECT_TRUE(entry->GetSSL().initialized); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 embedded_test_server()->GetURL("/"), | 2344 embedded_test_server()->GetURL("/"), |
| 2347 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); | 2345 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); |
| 2348 run_loop.Run(); | 2346 run_loop.Run(); |
| 2349 } | 2347 } |
| 2350 | 2348 |
| 2351 // If we use a worker URL that doesn't exist, registration fails. | 2349 // If we use a worker URL that doesn't exist, registration fails. |
| 2352 { | 2350 { |
| 2353 base::RunLoop run_loop; | 2351 base::RunLoop run_loop; |
| 2354 public_context()->RegisterServiceWorker( | 2352 public_context()->RegisterServiceWorker( |
| 2355 embedded_test_server()->GetURL(kScope), | 2353 embedded_test_server()->GetURL(kScope), |
| 2356 embedded_test_server()->GetURL("/does/not/exist"), | 2354 embedded_test_server()->GetURL("/does/not/exist"), false, |
| 2357 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); | 2355 base::Bind(&ExpectResultAndRun, false, run_loop.QuitClosure())); |
| 2358 run_loop.Run(); | 2356 run_loop.Run(); |
| 2359 } | 2357 } |
| 2360 EXPECT_EQ(0, CountRenderProcessHosts()); | 2358 EXPECT_EQ(0, CountRenderProcessHosts()); |
| 2361 | 2359 |
| 2362 // Register returns when the promise would be resolved. | 2360 // Register returns when the promise would be resolved. |
| 2363 { | 2361 { |
| 2364 base::RunLoop run_loop; | 2362 base::RunLoop run_loop; |
| 2365 public_context()->RegisterServiceWorker( | 2363 public_context()->RegisterServiceWorker( |
| 2366 embedded_test_server()->GetURL(kScope), | 2364 embedded_test_server()->GetURL(kScope), |
| 2367 embedded_test_server()->GetURL(kWorkerUrl), | 2365 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 2368 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 2366 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
| 2369 run_loop.Run(); | 2367 run_loop.Run(); |
| 2370 } | 2368 } |
| 2371 EXPECT_EQ(1, CountRenderProcessHosts()); | 2369 EXPECT_EQ(1, CountRenderProcessHosts()); |
| 2372 | 2370 |
| 2373 // Registering again should succeed, although the algo still | 2371 // Registering again should succeed, although the algo still |
| 2374 // might not be complete. | 2372 // might not be complete. |
| 2375 { | 2373 { |
| 2376 base::RunLoop run_loop; | 2374 base::RunLoop run_loop; |
| 2377 public_context()->RegisterServiceWorker( | 2375 public_context()->RegisterServiceWorker( |
| 2378 embedded_test_server()->GetURL(kScope), | 2376 embedded_test_server()->GetURL(kScope), |
| 2379 embedded_test_server()->GetURL(kWorkerUrl), | 2377 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 2380 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 2378 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
| 2381 run_loop.Run(); | 2379 run_loop.Run(); |
| 2382 } | 2380 } |
| 2383 | 2381 |
| 2384 // The registration algo might not be far enough along to have | 2382 // The registration algo might not be far enough along to have |
| 2385 // stored the registration data, so it may not be findable | 2383 // stored the registration data, so it may not be findable |
| 2386 // at this point. | 2384 // at this point. |
| 2387 | 2385 |
| 2388 // Unregistering something should return true. | 2386 // Unregistering something should return true. |
| 2389 { | 2387 { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 static const std::string kWorkerUrl; | 2676 static const std::string kWorkerUrl; |
| 2679 static const std::string kScriptUrl; | 2677 static const std::string kScriptUrl; |
| 2680 static const int kV8CacheTimeStampDataSize; | 2678 static const int kV8CacheTimeStampDataSize; |
| 2681 | 2679 |
| 2682 void RegisterAndActivateServiceWorker() { | 2680 void RegisterAndActivateServiceWorker() { |
| 2683 scoped_refptr<WorkerActivatedObserver> observer = | 2681 scoped_refptr<WorkerActivatedObserver> observer = |
| 2684 new WorkerActivatedObserver(wrapper()); | 2682 new WorkerActivatedObserver(wrapper()); |
| 2685 observer->Init(); | 2683 observer->Init(); |
| 2686 public_context()->RegisterServiceWorker( | 2684 public_context()->RegisterServiceWorker( |
| 2687 embedded_test_server()->GetURL(kPageUrl), | 2685 embedded_test_server()->GetURL(kPageUrl), |
| 2688 embedded_test_server()->GetURL(kWorkerUrl), | 2686 embedded_test_server()->GetURL(kWorkerUrl), false, |
| 2689 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 2687 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 2690 observer->Wait(); | 2688 observer->Wait(); |
| 2691 } | 2689 } |
| 2692 | 2690 |
| 2693 void NavigateToTestPage() { | 2691 void NavigateToTestPage() { |
| 2694 const base::string16 title = | 2692 const base::string16 title = |
| 2695 base::ASCIIToUTF16("Title was changed by the script."); | 2693 base::ASCIIToUTF16("Title was changed by the script."); |
| 2696 TitleWatcher title_watcher(shell()->web_contents(), title); | 2694 TitleWatcher title_watcher(shell()->web_contents(), title); |
| 2697 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); | 2695 NavigateToURL(shell(), embedded_test_server()->GetURL(kPageUrl)); |
| 2698 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | 2696 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 ServiceWorkerBrowserTest::SetUpOnMainThread(); | 2815 ServiceWorkerBrowserTest::SetUpOnMainThread(); |
| 2818 } | 2816 } |
| 2819 | 2817 |
| 2820 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope, | 2818 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope, |
| 2821 const std::string& script) { | 2819 const std::string& script) { |
| 2822 scoped_refptr<WorkerActivatedObserver> observer = | 2820 scoped_refptr<WorkerActivatedObserver> observer = |
| 2823 new WorkerActivatedObserver(wrapper()); | 2821 new WorkerActivatedObserver(wrapper()); |
| 2824 observer->Init(); | 2822 observer->Init(); |
| 2825 public_context()->RegisterServiceWorker( | 2823 public_context()->RegisterServiceWorker( |
| 2826 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script), | 2824 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script), |
| 2825 false, |
| 2827 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 2826 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
| 2828 observer->Wait(); | 2827 observer->Wait(); |
| 2829 } | 2828 } |
| 2830 | 2829 |
| 2831 void RunTestWithCrossOriginURL(const std::string& test_page, | 2830 void RunTestWithCrossOriginURL(const std::string& test_page, |
| 2832 const std::string& cross_origin_url) { | 2831 const std::string& cross_origin_url) { |
| 2833 const base::string16 title = base::ASCIIToUTF16("PASS"); | 2832 const base::string16 title = base::ASCIIToUTF16("PASS"); |
| 2834 TitleWatcher title_watcher(shell()->web_contents(), title); | 2833 TitleWatcher title_watcher(shell()->web_contents(), title); |
| 2835 NavigateToURL(shell(), | 2834 NavigateToURL(shell(), |
| 2836 embedded_test_server()->GetURL( | 2835 embedded_test_server()->GetURL( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2937 // effect in CanSuspendRenderer(). | 2936 // effect in CanSuspendRenderer(). |
| 2938 shell()->web_contents()->WasHidden(); | 2937 shell()->web_contents()->WasHidden(); |
| 2939 EXPECT_TRUE(rph->IsProcessBackgrounded()); | 2938 EXPECT_TRUE(rph->IsProcessBackgrounded()); |
| 2940 | 2939 |
| 2941 // The process which has service worker thread shouldn't be suspended. | 2940 // The process which has service worker thread shouldn't be suspended. |
| 2942 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); | 2941 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); |
| 2943 } | 2942 } |
| 2944 #endif | 2943 #endif |
| 2945 | 2944 |
| 2946 } // namespace content | 2945 } // namespace content |
| OLD | NEW |