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

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

Issue 783663002: Implement ServiceWorkerClient attributes [1/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
Index: Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
index bf4ac0e0ec5a358ef0053c08a762c61d63eed602..22a0b49f9e25fab4c839e89b75750be9a651df11 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp
@@ -14,10 +14,12 @@
#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
+#include "core/page/FocusController.h"
#include "core/testing/DummyPageHolder.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/SecurityOrigin.h"
+#include "public/platform/WebServiceWorkerClientsInfo.h"
#include "public/platform/WebServiceWorkerProvider.h"
#include "public/platform/WebURL.h"
#include "wtf/OwnPtr.h"
@@ -163,12 +165,23 @@ protected:
void setPageURL(const String& url)
{
// For URL completion.
- m_page->document().setBaseURLOverride(KURL(KURL(), url));
+ m_page->document().setURL(KURL(KURL(), url));
// The basis for security checks.
m_page->document().setSecurityOrigin(SecurityOrigin::createFromString(url));
}
+ void setVisibilityState(PageVisibilityState visibilityState)
+ {
+ m_page->page().setVisibilityState(visibilityState, true); // Set as initial state
+ }
+
+ void setFocused(bool focused)
+ {
+ m_page->page().focusController().setActive(focused);
+ m_page->page().focusController().setFocused(focused);
+ }
+
void testRegisterRejected(const String& scriptURL, const String& scope, const ScriptValueTest& valueTest)
{
// When the registration is rejected, a register call must not reach
@@ -358,5 +371,21 @@ TEST_F(ServiceWorkerContainerTest, GetRegistration_OmittedDocumentURLDefaultsToP
container->willBeDetachedFromFrame();
}
+TEST_F(ServiceWorkerContainerTest, GetClientInfo)
+{
+ setVisibilityState(PageVisibilityStateVisible);
+ setFocused(true);
+ setPageURL("http://localhost/x/index.html");
+
+ ServiceWorkerContainer* container = ServiceWorkerContainer::create(executionContext());
+
+ WebServiceWorkerClientInfo info;
+ ASSERT_TRUE(container->getClientInfo(&info));
+ EXPECT_EQ(WebString("visible"), info.visibilityState);
+ EXPECT_TRUE(info.isFocused);
+ EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), info.url);
+ EXPECT_EQ(WebURLRequest::FrameTypeTopLevel, info.frameType);
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.cpp ('k') | public/platform/WebServiceWorkerClientsInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698