| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 void setPageURL(const String& url) | 165 void setPageURL(const String& url) |
| 166 { | 166 { |
| 167 // For URL completion. | 167 // For URL completion. |
| 168 m_page->document().setURL(KURL(KURL(), url)); | 168 m_page->document().setURL(KURL(KURL(), url)); |
| 169 | 169 |
| 170 // The basis for security checks. | 170 // The basis for security checks. |
| 171 m_page->document().setSecurityOrigin(SecurityOrigin::createFromString(ur
l)); | 171 m_page->document().setSecurityOrigin(SecurityOrigin::createFromString(ur
l)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void setVisibilityState(PageVisibilityState visibilityState) | 174 void setPageVisibilityState(PageVisibilityState visibilityState) |
| 175 { | 175 { |
| 176 m_page->page().setVisibilityState(visibilityState, true); // Set as init
ial state | 176 m_page->page().setVisibilityState(visibilityState, true); // Set as init
ial state |
| 177 } | 177 } |
| 178 | 178 |
| 179 void setFocused(bool focused) | 179 void setFocused(bool focused) |
| 180 { | 180 { |
| 181 m_page->page().focusController().setActive(focused); | 181 m_page->page().focusController().setActive(focused); |
| 182 m_page->page().focusController().setFocused(focused); | 182 m_page->page().focusController().setFocused(focused); |
| 183 } | 183 } |
| 184 | 184 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 container->getRegistration(scriptState(), ""); | 357 container->getRegistration(scriptState(), ""); |
| 358 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 358 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
| 359 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 359 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 container->willBeDetachedFromFrame(); | 362 container->willBeDetachedFromFrame(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(ServiceWorkerContainerTest, GetClientInfo) | 365 TEST_F(ServiceWorkerContainerTest, GetClientInfo) |
| 366 { | 366 { |
| 367 setVisibilityState(PageVisibilityStateVisible); | 367 setPageVisibilityState(PageVisibilityStateVisible); |
| 368 setFocused(true); | 368 setFocused(true); |
| 369 setPageURL("http://localhost/x/index.html"); | 369 setPageURL("http://localhost/x/index.html"); |
| 370 | 370 |
| 371 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); | 371 ServiceWorkerContainer* container = ServiceWorkerContainer::create(execution
Context()); |
| 372 | 372 |
| 373 WebServiceWorkerClientInfo info; | 373 WebServiceWorkerClientInfo info; |
| 374 ASSERT_TRUE(container->getClientInfo(&info)); | 374 ASSERT_TRUE(container->getClientInfo(&info)); |
| 375 EXPECT_EQ(WebString("visible"), info.visibilityState); | 375 EXPECT_EQ(WebPageVisibilityStateVisible, info.pageVisibilityState); |
| 376 EXPECT_TRUE(info.isFocused); | 376 EXPECT_TRUE(info.isFocused); |
| 377 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), info.url); | 377 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), info.url); |
| 378 EXPECT_EQ(WebURLRequest::FrameTypeTopLevel, info.frameType); | 378 EXPECT_EQ(WebURLRequest::FrameTypeTopLevel, info.frameType); |
| 379 | 379 |
| 380 setVisibilityState(PageVisibilityStateHidden); | 380 setPageVisibilityState(PageVisibilityStateHidden); |
| 381 setFocused(false); | 381 setFocused(false); |
| 382 ASSERT_TRUE(container->getClientInfo(&info)); | 382 ASSERT_TRUE(container->getClientInfo(&info)); |
| 383 EXPECT_EQ(WebString("hidden"), info.visibilityState); | 383 EXPECT_EQ(WebPageVisibilityStateHidden, info.pageVisibilityState); |
| 384 EXPECT_FALSE(info.isFocused); | 384 EXPECT_FALSE(info.isFocused); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace | 387 } // namespace |
| 388 } // namespace blink | 388 } // namespace blink |
| OLD | NEW |