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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp

Issue 672383003: [ServiceWorker] Don't allow registration of the ServiceWorker scope outside the script directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
index 04f0433e8f460e28853f1c22e537e34a4b78bfb9..bf4ac0e0ec5a358ef0053c08a762c61d63eed602 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
@@ -228,6 +228,15 @@ TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected)
ExpectDOMException("SecurityError", "The scope must match the current origin."));
}
+TEST_F(ServiceWorkerContainerTest, Register_DifferentDirectoryThanScript)
+{
+ setPageURL("https://www.example.com/");
+ testRegisterRejected(
+ "https://www.example.com/js/worker.js",
+ "https://www.example.com/",
+ ExpectDOMException("SecurityError", "The scope must be under the directory of the script URL."));
+}
+
TEST_F(ServiceWorkerContainerTest, GetRegistration_NonSecureOriginIsRejected)
{
setPageURL("http://www.example.com/");
@@ -320,11 +329,11 @@ TEST_F(ServiceWorkerContainerTest, RegisterUnregister_NonHttpsSecureOriginDelega
ScriptState::Scope scriptScope(scriptState());
RegistrationOptions options;
options.setScope("y/");
- container->registerServiceWorker(scriptState(), "/z/worker.js", options);
+ container->registerServiceWorker(scriptState(), "/x/y/worker.js", options);
EXPECT_EQ(1ul, stubProvider.registerCallCount());
EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/")), stubProvider.registerScope());
- EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/z/worker.js")), stubProvider.registerScriptURL());
+ EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/y/worker.js")), stubProvider.registerScriptURL());
}
container->willBeDetachedFromFrame();
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698