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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 10 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
11 #include "content/browser/service_worker/embedded_worker_instance.h" | 11 #include "content/browser/service_worker/embedded_worker_instance.h" |
12 #include "content/browser/service_worker/embedded_worker_registry.h" | 12 #include "content/browser/service_worker/embedded_worker_registry.h" |
13 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
14 #include "content/browser/service_worker/service_worker_context_observer.h" | 14 #include "content/browser/service_worker/service_worker_context_observer.h" |
15 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
16 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
17 #include "content/browser/service_worker/service_worker_test_utils.h" | 17 #include "content/browser/service_worker/service_worker_test_utils.h" |
18 #include "content/browser/service_worker/service_worker_version.h" | 18 #include "content/browser/service_worker/service_worker_version.h" |
19 #include "content/common/service_worker/service_worker_messages.h" | 19 #include "content/common/service_worker/service_worker_messages.h" |
20 #include "content/common/service_worker/service_worker_status_code.h" | 20 #include "content/common/service_worker/service_worker_status_code.h" |
21 #include "content/common/service_worker/service_worker_types.h" | 21 #include "content/common/service_worker/service_worker_types.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/navigation_entry.h" | |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/referrer.h" | 29 #include "content/public/common/referrer.h" |
30 #include "content/public/common/security_style.h" | |
31 #include "content/public/common/ssl_status.h" | |
29 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
30 #include "content/public/test/content_browser_test.h" | 33 #include "content/public/test/content_browser_test.h" |
31 #include "content/public/test/content_browser_test_utils.h" | 34 #include "content/public/test/content_browser_test_utils.h" |
32 #include "content/shell/browser/shell.h" | 35 #include "content/shell/browser/shell.h" |
33 #include "content/shell/browser/shell_content_browser_client.h" | 36 #include "content/shell/browser/shell_content_browser_client.h" |
34 #include "net/test/embedded_test_server/embedded_test_server.h" | 37 #include "net/test/embedded_test_server/embedded_test_server.h" |
35 #include "net/test/embedded_test_server/http_request.h" | 38 #include "net/test/embedded_test_server/http_request.h" |
36 #include "net/test/embedded_test_server/http_response.h" | 39 #include "net/test/embedded_test_server/http_response.h" |
37 #include "net/url_request/url_request_filter.h" | 40 #include "net/url_request/url_request_filter.h" |
38 #include "net/url_request/url_request_interceptor.h" | 41 #include "net/url_request/url_request_interceptor.h" |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 shell()->Close(); | 796 shell()->Close(); |
794 { | 797 { |
795 base::RunLoop run_loop; | 798 base::RunLoop run_loop; |
796 public_context()->UnregisterServiceWorker( | 799 public_context()->UnregisterServiceWorker( |
797 embedded_test_server()->GetURL(kPageUrl), | 800 embedded_test_server()->GetURL(kPageUrl), |
798 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 801 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
799 run_loop.Run(); | 802 run_loop.Run(); |
800 } | 803 } |
801 } | 804 } |
802 | 805 |
806 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, Secure) { | |
falken
2015/01/27 03:57:54
Can you give a name that describes more what this
horo
2015/01/27 06:04:41
Done.
| |
807 net::SpawnedTestServer https_server( | |
808 net::SpawnedTestServer::TYPE_HTTPS, | |
809 net::BaseTestServer::SSLOptions( | |
810 net::BaseTestServer::SSLOptions::CERT_OK), | |
811 base::FilePath(FILE_PATH_LITERAL("content/test/data/"))); | |
812 ASSERT_TRUE(https_server.Start()); | |
813 const std::string kPageUrl = "files/service_worker/fetch_event_blob.html"; | |
814 const std::string kWorkerUrl = "files/service_worker/fetch_event_blob.js"; | |
815 { | |
816 scoped_refptr<WorkerActivatedObserver> observer = | |
817 new WorkerActivatedObserver(wrapper()); | |
818 observer->Init(); | |
819 public_context()->RegisterServiceWorker( | |
820 https_server.GetURL(kPageUrl), | |
821 https_server.GetURL(kWorkerUrl), | |
822 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | |
823 observer->Wait(); | |
824 } | |
825 { | |
826 const base::string16 title = base::ASCIIToUTF16("Title"); | |
827 TitleWatcher title_watcher(shell()->web_contents(), title); | |
828 NavigateToURL(shell(), https_server.GetURL(kPageUrl)); | |
829 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | |
830 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); | |
831 NavigationEntry* entry = | |
832 shell()->web_contents()->GetController().GetActiveEntry(); | |
falken
2015/01/27 03:57:54
GetActiveEntry comments say "THIS IS DEPRECATED. D
horo
2015/01/27 06:04:41
Done.
| |
833 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, entry->GetSSL().security_style); | |
834 } | |
835 shell()->Close(); | |
836 { | |
837 base::RunLoop run_loop; | |
838 public_context()->UnregisterServiceWorker( | |
839 https_server.GetURL(kPageUrl), | |
840 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | |
841 run_loop.Run(); | |
842 } | |
843 } | |
844 | |
803 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, ImportsBustMemcache) { | 845 IN_PROC_BROWSER_TEST_F(ServiceWorkerBrowserTest, ImportsBustMemcache) { |
804 const std::string kScopeUrl = "/service_worker/imports_bust_memcache_scope/"; | 846 const std::string kScopeUrl = "/service_worker/imports_bust_memcache_scope/"; |
805 const std::string kPageUrl = "/service_worker/imports_bust_memcache.html"; | 847 const std::string kPageUrl = "/service_worker/imports_bust_memcache.html"; |
806 const std::string kScriptUrl = "/service_worker/worker_with_one_import.js"; | 848 const std::string kScriptUrl = "/service_worker/worker_with_one_import.js"; |
807 const std::string kImportUrl = "/service_worker/long_lived_import.js"; | 849 const std::string kImportUrl = "/service_worker/long_lived_import.js"; |
808 const base::string16 kOKTitle(base::ASCIIToUTF16("OK")); | 850 const base::string16 kOKTitle(base::ASCIIToUTF16("OK")); |
809 const base::string16 kFailTitle(base::ASCIIToUTF16("FAIL")); | 851 const base::string16 kFailTitle(base::ASCIIToUTF16("FAIL")); |
810 | 852 |
811 RunOnIOThread( | 853 RunOnIOThread( |
812 base::Bind(&CreateLongLivedResourceInterceptors, | 854 base::Bind(&CreateLongLivedResourceInterceptors, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 const base::string16 kOKTitle2(base::ASCIIToUTF16("OK_2")); | 1013 const base::string16 kOKTitle2(base::ASCIIToUTF16("OK_2")); |
972 const base::string16 kFailTitle2(base::ASCIIToUTF16("FAIL_2")); | 1014 const base::string16 kFailTitle2(base::ASCIIToUTF16("FAIL_2")); |
973 content::TitleWatcher title_watcher2(shell()->web_contents(), kOKTitle2); | 1015 content::TitleWatcher title_watcher2(shell()->web_contents(), kOKTitle2); |
974 title_watcher2.AlsoWaitForTitle(kFailTitle2); | 1016 title_watcher2.AlsoWaitForTitle(kFailTitle2); |
975 | 1017 |
976 NavigateToURL(shell(), embedded_test_server()->GetURL(kConfirmPageUrl)); | 1018 NavigateToURL(shell(), embedded_test_server()->GetURL(kConfirmPageUrl)); |
977 EXPECT_EQ(kOKTitle2, title_watcher2.WaitAndGetTitle()); | 1019 EXPECT_EQ(kOKTitle2, title_watcher2.WaitAndGetTitle()); |
978 } | 1020 } |
979 | 1021 |
980 } // namespace content | 1022 } // namespace content |
OLD | NEW |