Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / serviceworkers / ServiceWorkerContainerTest.cpp
index 9c937fe..bf4ac0e 100644 (file)
@@ -67,7 +67,7 @@ private:
         {
         }
 
-        virtual ScriptValue call(ScriptValue arg) OVERRIDE
+        virtual ScriptValue call(ScriptValue arg) override
         {
             m_owner.m_arg = arg;
             m_owner.m_callCount++;
@@ -108,9 +108,9 @@ public:
     {
     }
 
-    virtual ~ExpectDOMException() OVERRIDE { }
+    virtual ~ExpectDOMException() override { }
 
-    virtual void operator()(ScriptValue value) const OVERRIDE
+    virtual void operator()(ScriptValue value) const override
     {
         DOMException* exception = V8DOMException::toImplWithTypeCheck(value.isolate(), value.v8Value());
         EXPECT_TRUE(exception) << "the value should be a DOMException";
@@ -129,9 +129,9 @@ private:
 
 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider {
 public:
-    virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { }
+    virtual ~NotReachedWebServiceWorkerProvider() override { }
 
-    virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE
+    virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override
     {
         ADD_FAILURE() << "the provider should not be called to register a Service Worker";
         delete callbacks;
@@ -177,9 +177,9 @@ protected:
 
         ServiceWorkerContainer* container = ServiceWorkerContainer::create(executionContext());
         ScriptState::Scope scriptScope(scriptState());
-        RegistrationOptionList* options = RegistrationOptionList::create();
-        options->setScope(scope);
-        ScriptPromise promise = container->registerServiceWorker(scriptState(), scriptURL, *options);
+        RegistrationOptions options;
+        options.setScope(scope);
+        ScriptPromise promise = container->registerServiceWorker(scriptState(), scriptURL, options);
         expectRejected(scriptState(), promise, valueTest);
 
         container->willBeDetachedFromFrame();
@@ -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/");
@@ -275,9 +284,9 @@ private:
         {
         }
 
-        virtual ~WebServiceWorkerProviderImpl() OVERRIDE { }
+        virtual ~WebServiceWorkerProviderImpl() override { }
 
-        virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE
+        virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override
         {
             m_owner.m_registerCallCount++;
             m_owner.m_registerScope = pattern;
@@ -285,7 +294,7 @@ private:
             m_registrationCallbacksToDelete.append(adoptPtr(callbacks));
         }
 
-        virtual void getRegistration(const WebURL& documentURL, WebServiceWorkerGetRegistrationCallbacks* callbacks) OVERRIDE
+        virtual void getRegistration(const WebURL& documentURL, WebServiceWorkerGetRegistrationCallbacks* callbacks) override
         {
             m_owner.m_getRegistrationCallCount++;
             m_owner.m_getRegistrationURL = documentURL;
@@ -318,13 +327,13 @@ TEST_F(ServiceWorkerContainerTest, RegisterUnregister_NonHttpsSecureOriginDelega
     // register
     {
         ScriptState::Scope scriptScope(scriptState());
-        RegistrationOptionList* options = RegistrationOptionList::create();
-        options->setScope("y/");
-        container->registerServiceWorker(scriptState(), "/z/worker.js", *options);
+        RegistrationOptions options;
+        options.setScope("y/");
+        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();