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 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1909 } | 1909 } |
1910 | 1910 |
1911 private: | 1911 private: |
1912 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerV8CacheStrategiesAggressiveTest); | 1912 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerV8CacheStrategiesAggressiveTest); |
1913 }; | 1913 }; |
1914 | 1914 |
1915 IN_PROC_BROWSER_TEST_F(ServiceWorkerV8CacheStrategiesAggressiveTest, | 1915 IN_PROC_BROWSER_TEST_F(ServiceWorkerV8CacheStrategiesAggressiveTest, |
1916 V8CacheOnCacheStorage) { | 1916 V8CacheOnCacheStorage) { |
1917 CheckStrategyIsAggressive(); | 1917 CheckStrategyIsAggressive(); |
1918 } | 1918 } |
1919 | 1919 |
nhiroki
2016/08/01 04:32:45
Can you add a comment about what this test confirm
horo
2016/08/01 07:40:55
Done.
| |
1920 class ServiceWorkerDisableWebSecurityTest : public ServiceWorkerBrowserTest { | |
1921 public: | |
1922 ServiceWorkerDisableWebSecurityTest() {} | |
1923 ~ServiceWorkerDisableWebSecurityTest() override {} | |
1924 | |
1925 void SetUpCommandLine(base::CommandLine* command_line) override { | |
1926 command_line->AppendSwitch(switches::kDisableWebSecurity); | |
1927 } | |
1928 | |
1929 void SetUpOnMainThread() override { | |
1930 cross_origin_server_.ServeFilesFromSourceDirectory("content/test/data"); | |
1931 ASSERT_TRUE(cross_origin_server_.Start()); | |
1932 ServiceWorkerBrowserTest::SetUpOnMainThread(); | |
1933 } | |
1934 | |
1935 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope, | |
1936 const std::string& script) { | |
1937 scoped_refptr<WorkerActivatedObserver> observer = | |
1938 new WorkerActivatedObserver(wrapper()); | |
1939 observer->Init(); | |
1940 public_context()->RegisterServiceWorker( | |
1941 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script), | |
1942 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing))); | |
1943 observer->Wait(); | |
1944 } | |
1945 | |
1946 void RunTestWithCrossOriginURL(const std::string& test_page, | |
1947 const std::string& cross_origin_url) { | |
1948 const base::string16 title = base::ASCIIToUTF16("PASS"); | |
1949 TitleWatcher title_watcher(shell()->web_contents(), title); | |
1950 NavigateToURL(shell(), | |
1951 embedded_test_server()->GetURL( | |
1952 test_page + "?" + | |
1953 cross_origin_server_.GetURL(cross_origin_url).spec())); | |
1954 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | |
1955 } | |
1956 | |
1957 net::EmbeddedTestServer cross_origin_server_; | |
nhiroki
2016/08/01 04:32:45
Can you move this to the private section?
horo
2016/08/01 07:40:55
Done.
| |
1958 | |
1959 private: | |
1960 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDisableWebSecurityTest); | |
1961 }; | |
1962 | |
1963 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, | |
1964 GetRegistrationNoCrash) { | |
1965 const char kPageUrl[] = | |
1966 "/service_worker/disable_web_security_get_registration.html"; | |
1967 const char kScopeUrl[] = "/service_worker/"; | |
1968 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); | |
1969 } | |
1970 | |
1971 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, RegisterNoCrash) { | |
1972 const char kPageUrl[] = "/service_worker/disable_web_security_register.html"; | |
1973 const char kScopeUrl[] = "/service_worker/"; | |
1974 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); | |
1975 } | |
1976 | |
1977 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UnregisterNoCrash) { | |
1978 const char kPageUrl[] = | |
1979 "/service_worker/disable_web_security_unregister.html"; | |
1980 const char kScopeUrl[] = "/service_worker/scope/"; | |
1981 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; | |
1982 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl); | |
1983 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); | |
1984 } | |
1985 | |
1986 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) { | |
1987 const char kPageUrl[] = "/service_worker/disable_web_security_update.html"; | |
1988 const char kScopeUrl[] = "/service_worker/scope/"; | |
1989 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js"; | |
1990 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl); | |
1991 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl); | |
1992 } | |
1993 | |
1920 } // namespace content | 1994 } // namespace content |
OLD | NEW |