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 "config.h" | 5 #include "config.h" |
6 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 6 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return self->bindToV8Function(); | 60 return self->bindToV8Function(); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner) | 64 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner) |
65 : ScriptFunction(scriptState) | 65 : ScriptFunction(scriptState) |
66 , m_owner(owner) | 66 , m_owner(owner) |
67 { | 67 { |
68 } | 68 } |
69 | 69 |
70 virtual ScriptValue call(ScriptValue arg) OVERRIDE | 70 virtual ScriptValue call(ScriptValue arg) override |
71 { | 71 { |
72 m_owner.m_arg = arg; | 72 m_owner.m_arg = arg; |
73 m_owner.m_callCount++; | 73 m_owner.m_callCount++; |
74 return ScriptValue(); | 74 return ScriptValue(); |
75 } | 75 } |
76 | 76 |
77 StubScriptFunction& m_owner; | 77 StubScriptFunction& m_owner; |
78 }; | 78 }; |
79 }; | 79 }; |
80 | 80 |
(...skipping 20 matching lines...) Expand all Loading... |
101 | 101 |
102 // Matches a ScriptValue and a DOMException with a specific name and message. | 102 // Matches a ScriptValue and a DOMException with a specific name and message. |
103 class ExpectDOMException : public ScriptValueTest { | 103 class ExpectDOMException : public ScriptValueTest { |
104 public: | 104 public: |
105 ExpectDOMException(const String& expectedName, const String& expectedMessage
) | 105 ExpectDOMException(const String& expectedName, const String& expectedMessage
) |
106 : m_expectedName(expectedName) | 106 : m_expectedName(expectedName) |
107 , m_expectedMessage(expectedMessage) | 107 , m_expectedMessage(expectedMessage) |
108 { | 108 { |
109 } | 109 } |
110 | 110 |
111 virtual ~ExpectDOMException() OVERRIDE { } | 111 virtual ~ExpectDOMException() override { } |
112 | 112 |
113 virtual void operator()(ScriptValue value) const OVERRIDE | 113 virtual void operator()(ScriptValue value) const override |
114 { | 114 { |
115 DOMException* exception = V8DOMException::toImplWithTypeCheck(value.isol
ate(), value.v8Value()); | 115 DOMException* exception = V8DOMException::toImplWithTypeCheck(value.isol
ate(), value.v8Value()); |
116 EXPECT_TRUE(exception) << "the value should be a DOMException"; | 116 EXPECT_TRUE(exception) << "the value should be a DOMException"; |
117 if (!exception) | 117 if (!exception) |
118 return; | 118 return; |
119 EXPECT_EQ(m_expectedName, exception->name()); | 119 EXPECT_EQ(m_expectedName, exception->name()); |
120 EXPECT_EQ(m_expectedMessage, exception->message()); | 120 EXPECT_EQ(m_expectedMessage, exception->message()); |
121 } | 121 } |
122 | 122 |
123 private: | 123 private: |
124 String m_expectedName; | 124 String m_expectedName; |
125 String m_expectedMessage; | 125 String m_expectedMessage; |
126 }; | 126 }; |
127 | 127 |
128 // Service Worker-specific tests. | 128 // Service Worker-specific tests. |
129 | 129 |
130 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { | 130 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { |
131 public: | 131 public: |
132 virtual ~NotReachedWebServiceWorkerProvider() OVERRIDE { } | 132 virtual ~NotReachedWebServiceWorkerProvider() override { } |
133 | 133 |
134 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 134 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri
ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override |
135 { | 135 { |
136 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; | 136 ADD_FAILURE() << "the provider should not be called to register a Servic
e Worker"; |
137 delete callbacks; | 137 delete callbacks; |
138 } | 138 } |
139 }; | 139 }; |
140 | 140 |
141 class ServiceWorkerContainerTest : public ::testing::Test { | 141 class ServiceWorkerContainerTest : public ::testing::Test { |
142 protected: | 142 protected: |
143 ServiceWorkerContainerTest() | 143 ServiceWorkerContainerTest() |
144 : m_page(DummyPageHolder::create()) | 144 : m_page(DummyPageHolder::create()) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 const WebURL& getRegistrationURL() { return m_getRegistrationURL; } | 268 const WebURL& getRegistrationURL() { return m_getRegistrationURL; } |
269 | 269 |
270 private: | 270 private: |
271 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider { | 271 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider { |
272 public: | 272 public: |
273 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner) | 273 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner) |
274 : m_owner(owner) | 274 : m_owner(owner) |
275 { | 275 { |
276 } | 276 } |
277 | 277 |
278 virtual ~WebServiceWorkerProviderImpl() OVERRIDE { } | 278 virtual ~WebServiceWorkerProviderImpl() override { } |
279 | 279 |
280 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) OVERRIDE | 280 virtual void registerServiceWorker(const WebURL& pattern, const WebURL&
scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override |
281 { | 281 { |
282 m_owner.m_registerCallCount++; | 282 m_owner.m_registerCallCount++; |
283 m_owner.m_registerScope = pattern; | 283 m_owner.m_registerScope = pattern; |
284 m_owner.m_registerScriptURL = scriptURL; | 284 m_owner.m_registerScriptURL = scriptURL; |
285 m_registrationCallbacksToDelete.append(adoptPtr(callbacks)); | 285 m_registrationCallbacksToDelete.append(adoptPtr(callbacks)); |
286 } | 286 } |
287 | 287 |
288 virtual void getRegistration(const WebURL& documentURL, WebServiceWorker
GetRegistrationCallbacks* callbacks) OVERRIDE | 288 virtual void getRegistration(const WebURL& documentURL, WebServiceWorker
GetRegistrationCallbacks* callbacks) override |
289 { | 289 { |
290 m_owner.m_getRegistrationCallCount++; | 290 m_owner.m_getRegistrationCallCount++; |
291 m_owner.m_getRegistrationURL = documentURL; | 291 m_owner.m_getRegistrationURL = documentURL; |
292 m_getRegistrationCallbacksToDelete.append(adoptPtr(callbacks)); | 292 m_getRegistrationCallbacksToDelete.append(adoptPtr(callbacks)); |
293 } | 293 } |
294 | 294 |
295 private: | 295 private: |
296 StubWebServiceWorkerProvider& m_owner; | 296 StubWebServiceWorkerProvider& m_owner; |
297 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_registrationCal
lbacksToDelete; | 297 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks> > m_registrationCal
lbacksToDelete; |
298 Vector<OwnPtr<WebServiceWorkerGetRegistrationCallbacks> > m_getRegistrat
ionCallbacksToDelete; | 298 Vector<OwnPtr<WebServiceWorkerGetRegistrationCallbacks> > m_getRegistrat
ionCallbacksToDelete; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 container->getRegistration(scriptState(), ""); | 344 container->getRegistration(scriptState(), ""); |
345 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 345 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 346 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
347 } | 347 } |
348 | 348 |
349 container->willBeDetachedFromFrame(); | 349 container->willBeDetachedFromFrame(); |
350 } | 350 } |
351 | 351 |
352 } // namespace | 352 } // namespace |
353 } // namespace blink | 353 } // namespace blink |
OLD | NEW |