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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 class ServiceWorkerBrowserTest : public ContentBrowserTest { | 299 class ServiceWorkerBrowserTest : public ContentBrowserTest { |
300 protected: | 300 protected: |
301 using self = ServiceWorkerBrowserTest; | 301 using self = ServiceWorkerBrowserTest; |
302 | 302 |
303 void SetUpCommandLine(base::CommandLine* command_line) override { | 303 void SetUpCommandLine(base::CommandLine* command_line) override { |
304 command_line->AppendSwitch( | 304 command_line->AppendSwitch( |
305 switches::kEnableExperimentalWebPlatformFeatures); | 305 switches::kEnableExperimentalWebPlatformFeatures); |
306 } | 306 } |
307 | 307 |
308 void SetUpOnMainThread() override { | 308 void SetUpOnMainThread() override { |
309 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 309 ASSERT_TRUE(embedded_test_server()->Start()); |
310 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( | 310 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( |
311 shell()->web_contents()->GetBrowserContext()); | 311 shell()->web_contents()->GetBrowserContext()); |
312 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( | 312 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( |
313 partition->GetServiceWorkerContext()); | 313 partition->GetServiceWorkerContext()); |
314 | 314 |
315 // Navigate to the page to set up a renderer page (where we can embed | 315 // Navigate to the page to set up a renderer page (where we can embed |
316 // a worker). | 316 // a worker). |
317 NavigateToURLBlockUntilNavigationsComplete( | 317 NavigateToURLBlockUntilNavigationsComplete( |
318 shell(), | 318 shell(), |
319 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); | 319 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 } | 978 } |
979 | 979 |
980 // Flaky on Win/Mac: http://crbug.com/533631 | 980 // Flaky on Win/Mac: http://crbug.com/533631 |
981 #if defined(OS_WIN) || defined(OS_MACOSX) | 981 #if defined(OS_WIN) || defined(OS_MACOSX) |
982 #define MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure DISABLED_ResponseFr
omHTTPSServiceWorkerIsMarkedAsSecure | 982 #define MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure DISABLED_ResponseFr
omHTTPSServiceWorkerIsMarkedAsSecure |
983 #else | 983 #else |
984 #define MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure ResponseFromHTTPSSe
rviceWorkerIsMarkedAsSecure | 984 #define MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure ResponseFromHTTPSSe
rviceWorkerIsMarkedAsSecure |
985 #endif | 985 #endif |
986 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, | 986 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, |
987 MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure) { | 987 MAYBE_ResponseFromHTTPSServiceWorkerIsMarkedAsSecure) { |
988 const char kPageUrl[] = "files/service_worker/fetch_event_blob.html"; | 988 const char kPageUrl[] = "/service_worker/fetch_event_blob.html"; |
989 const char kWorkerUrl[] = "files/service_worker/fetch_event_blob.js"; | 989 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; |
990 net::SpawnedTestServer https_server( | 990 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
991 net::SpawnedTestServer::TYPE_HTTPS, | 991 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
992 net::BaseTestServer::SSLOptions( | |
993 net::BaseTestServer::SSLOptions::CERT_OK), | |
994 base::FilePath(FILE_PATH_LITERAL("content/test/data/"))); | |
995 ASSERT_TRUE(https_server.Start()); | 992 ASSERT_TRUE(https_server.Start()); |
996 | 993 |
997 scoped_refptr<WorkerActivatedObserver> observer = | 994 scoped_refptr<WorkerActivatedObserver> observer = |
998 new WorkerActivatedObserver(wrapper()); | 995 new WorkerActivatedObserver(wrapper()); |
999 observer->Init(); | 996 observer->Init(); |
1000 public_context()->RegisterServiceWorker( | 997 public_context()->RegisterServiceWorker( |
1001 https_server.GetURL(kPageUrl), | 998 https_server.GetURL(kPageUrl), |
1002 https_server.GetURL(kWorkerUrl), | 999 https_server.GetURL(kWorkerUrl), |
1003 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | 1000 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); |
1004 observer->Wait(); | 1001 observer->Wait(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 ASSERT_EQ(SERVICE_WORKER_OK, status); | 1282 ASSERT_EQ(SERVICE_WORKER_OK, status); |
1286 // Stop the worker. | 1283 // Stop the worker. |
1287 StopWorker(SERVICE_WORKER_OK); | 1284 StopWorker(SERVICE_WORKER_OK); |
1288 // Restart the worker. | 1285 // Restart the worker. |
1289 StartWorker(SERVICE_WORKER_OK); | 1286 StartWorker(SERVICE_WORKER_OK); |
1290 // Stop the worker. | 1287 // Stop the worker. |
1291 StopWorker(SERVICE_WORKER_OK); | 1288 StopWorker(SERVICE_WORKER_OK); |
1292 } | 1289 } |
1293 | 1290 |
1294 } // namespace content | 1291 } // namespace content |
OLD | NEW |