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

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

Issue 2196633002: [ServiceWorker] Don't check the origin equality when disable-web-security flag is set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated nhiroki's comment Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
1920 // ServiceWorkerDisableWebSecurityTests check the behavior when the web security
1921 // is disabled. If '--disable-web-security' flag is set, we don't check the
1922 // origin equality in Blink. So the Service Worker related APIs should succeed
1923 // even if it is thouching other origin Service Workers.
1924 class ServiceWorkerDisableWebSecurityTest : public ServiceWorkerBrowserTest {
1925 public:
1926 ServiceWorkerDisableWebSecurityTest() {}
1927 ~ServiceWorkerDisableWebSecurityTest() override {}
1928
1929 void SetUpCommandLine(base::CommandLine* command_line) override {
1930 command_line->AppendSwitch(switches::kDisableWebSecurity);
1931 }
1932
1933 void SetUpOnMainThread() override {
1934 cross_origin_server_.ServeFilesFromSourceDirectory("content/test/data");
1935 ASSERT_TRUE(cross_origin_server_.Start());
1936 ServiceWorkerBrowserTest::SetUpOnMainThread();
1937 }
1938
1939 void RegisterServiceWorkerOnCrossOriginServer(const std::string& scope,
1940 const std::string& script) {
1941 scoped_refptr<WorkerActivatedObserver> observer =
1942 new WorkerActivatedObserver(wrapper());
1943 observer->Init();
1944 public_context()->RegisterServiceWorker(
1945 cross_origin_server_.GetURL(scope), cross_origin_server_.GetURL(script),
1946 base::Bind(&ExpectResultAndRun, true, base::Bind(&base::DoNothing)));
1947 observer->Wait();
1948 }
1949
1950 void RunTestWithCrossOriginURL(const std::string& test_page,
1951 const std::string& cross_origin_url) {
1952 const base::string16 title = base::ASCIIToUTF16("PASS");
1953 TitleWatcher title_watcher(shell()->web_contents(), title);
1954 NavigateToURL(shell(),
1955 embedded_test_server()->GetURL(
1956 test_page + "?" +
1957 cross_origin_server_.GetURL(cross_origin_url).spec()));
1958 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
1959 }
1960
1961 private:
1962 net::EmbeddedTestServer cross_origin_server_;
1963 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDisableWebSecurityTest);
1964 };
1965
1966 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest,
1967 GetRegistrationNoCrash) {
1968 const char kPageUrl[] =
1969 "/service_worker/disable_web_security_get_registration.html";
1970 const char kScopeUrl[] = "/service_worker/";
1971 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
1972 }
1973
1974 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, RegisterNoCrash) {
1975 const char kPageUrl[] = "/service_worker/disable_web_security_register.html";
1976 const char kScopeUrl[] = "/service_worker/";
1977 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
1978 }
1979
1980 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UnregisterNoCrash) {
1981 const char kPageUrl[] =
1982 "/service_worker/disable_web_security_unregister.html";
1983 const char kScopeUrl[] = "/service_worker/scope/";
1984 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
1985 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl);
1986 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
1987 }
1988
1989 IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) {
1990 const char kPageUrl[] = "/service_worker/disable_web_security_update.html";
1991 const char kScopeUrl[] = "/service_worker/scope/";
1992 const char kWorkerUrl[] = "/service_worker/fetch_event_blob.js";
1993 RegisterServiceWorkerOnCrossOriginServer(kScopeUrl, kWorkerUrl);
1994 RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
1995 }
1996
1920 } // namespace content 1997 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698