Drop clientCreationURL from ServiceWorkerRegistrationKey
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Dec 2017 18:29:05 +0000 (18:29 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Dec 2017 18:29:05 +0000 (18:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180255

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT test that is now passing.

* web-platform-tests/service-workers/service-worker/multiple-register.https-expected.txt:

Source/WebCore:

Drop clientCreationURL from ServiceWorkerRegistrationKey. It is not needed and leads to
wrong behavior when using the Service Worker API from inside service workers.

* workers/service/ServiceWorkerJobData.cpp:
(WebCore::ServiceWorkerJobData::registrationKey const):
* workers/service/ServiceWorkerRegistrationKey.cpp:
(WebCore::ServiceWorkerRegistrationKey::ServiceWorkerRegistrationKey):
(WebCore::ServiceWorkerRegistrationKey::hash const):
(WebCore::ServiceWorkerRegistrationKey::operator== const):
(WebCore::ServiceWorkerRegistrationKey::isolatedCopy const):
(WebCore::ServiceWorkerRegistrationKey::loggingString const):
* workers/service/ServiceWorkerRegistrationKey.h:
(WebCore::ServiceWorkerRegistrationKey::scope const):
(WebCore::ServiceWorkerRegistrationKey::setScope):
(WebCore::ServiceWorkerRegistrationKey::encode const):
(WebCore::ServiceWorkerRegistrationKey::decode):
(WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::constructDeletedValue):
(WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::isDeletedValue):
(WebCore::ServiceWorkerRegistrationKey::clientCreationURL const): Deleted.
(WebCore::ServiceWorkerRegistrationKey::setClientCreationURL): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225398 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multiple-register.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerJobData.cpp
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h

index 21ae597..2713eae 100644 (file)
@@ -1,3 +1,14 @@
+2017-12-01  Chris Dumez  <cdumez@apple.com>
+
+        Drop clientCreationURL from ServiceWorkerRegistrationKey
+        https://bugs.webkit.org/show_bug.cgi?id=180255
+
+        Reviewed by Youenn Fablet.
+
+        Rebaseline WPT test that is now passing.
+
+        * web-platform-tests/service-workers/service-worker/multiple-register.https-expected.txt:
+
 2017-11-30  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, unskip service worker test that no longer times out after r225346.
index 1566557..a95adf3 100644 (file)
@@ -1,6 +1,5 @@
 
-
 PASS Subsequent registrations resolve to the same registration object 
-FAIL Subsequent registrations from a different iframe resolve to the different registration object but they refer to the same registration and workers assert_unreached: unexpected rejection: assert_equals: installing worker should be null expected null but got object "[object ServiceWorker]" Reached unreachable code
+PASS Subsequent registrations from a different iframe resolve to the different registration object but they refer to the same registration and workers 
 PASS Concurrent registrations resolve to the same registration object 
 
index 52876da..8ed5593 100644 (file)
@@ -1,3 +1,31 @@
+2017-12-01  Chris Dumez  <cdumez@apple.com>
+
+        Drop clientCreationURL from ServiceWorkerRegistrationKey
+        https://bugs.webkit.org/show_bug.cgi?id=180255
+
+        Reviewed by Youenn Fablet.
+
+        Drop clientCreationURL from ServiceWorkerRegistrationKey. It is not needed and leads to
+        wrong behavior when using the Service Worker API from inside service workers.
+
+        * workers/service/ServiceWorkerJobData.cpp:
+        (WebCore::ServiceWorkerJobData::registrationKey const):
+        * workers/service/ServiceWorkerRegistrationKey.cpp:
+        (WebCore::ServiceWorkerRegistrationKey::ServiceWorkerRegistrationKey):
+        (WebCore::ServiceWorkerRegistrationKey::hash const):
+        (WebCore::ServiceWorkerRegistrationKey::operator== const):
+        (WebCore::ServiceWorkerRegistrationKey::isolatedCopy const):
+        (WebCore::ServiceWorkerRegistrationKey::loggingString const):
+        * workers/service/ServiceWorkerRegistrationKey.h:
+        (WebCore::ServiceWorkerRegistrationKey::scope const):
+        (WebCore::ServiceWorkerRegistrationKey::setScope):
+        (WebCore::ServiceWorkerRegistrationKey::encode const):
+        (WebCore::ServiceWorkerRegistrationKey::decode):
+        (WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::ServiceWorkerRegistrationKey>::isDeletedValue):
+        (WebCore::ServiceWorkerRegistrationKey::clientCreationURL const): Deleted.
+        (WebCore::ServiceWorkerRegistrationKey::setClientCreationURL): Deleted.
+
 2017-12-01  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WinCairo] Wrongly placed scroll bars in HiDPI
index 69e67c9..6894cb0 100644 (file)
@@ -44,7 +44,7 @@ ServiceWorkerRegistrationKey ServiceWorkerJobData::registrationKey() const
 {
     URL scope = scopeURL;
     scope.removeFragmentIdentifier();
-    return { URL { clientCreationURL }, SecurityOriginData { topOrigin }, WTFMove(scope) };
+    return { SecurityOriginData { topOrigin }, WTFMove(scope) };
 }
 
 ServiceWorkerJobData ServiceWorkerJobData::isolatedCopy() const
index 4793aa0..b2424f8 100644 (file)
@@ -32,9 +32,8 @@
 
 namespace WebCore {
 
-ServiceWorkerRegistrationKey::ServiceWorkerRegistrationKey(URL&& clientURL, SecurityOriginData&& topOrigin, URL&& scope)
-    : m_clientCreationURL(WTFMove(clientURL))
-    , m_topOrigin(WTFMove(topOrigin))
+ServiceWorkerRegistrationKey::ServiceWorkerRegistrationKey(SecurityOriginData&& topOrigin, URL&& scope)
+    : m_topOrigin(WTFMove(topOrigin))
     , m_scope(WTFMove(scope))
 {
     ASSERT(!m_scope.hasFragment());
@@ -47,22 +46,21 @@ ServiceWorkerRegistrationKey ServiceWorkerRegistrationKey::emptyKey()
 
 unsigned ServiceWorkerRegistrationKey::hash() const
 {
-    unsigned hashes[3];
-    hashes[0] = URLHash::hash(m_clientCreationURL);
-    hashes[1] = SecurityOriginDataHash::hash(m_topOrigin);
-    hashes[2] = StringHash::hash(m_scope);
+    unsigned hashes[2];
+    hashes[0] = SecurityOriginDataHash::hash(m_topOrigin);
+    hashes[1] = StringHash::hash(m_scope);
 
     return StringHasher::hashMemory(hashes, sizeof(hashes));
 }
 
 bool ServiceWorkerRegistrationKey::operator==(const ServiceWorkerRegistrationKey& other) const
 {
-    return m_clientCreationURL == other.m_clientCreationURL && m_topOrigin == other.m_topOrigin && m_scope == other.m_scope;
+    return m_topOrigin == other.m_topOrigin && m_scope == other.m_scope;
 }
 
 ServiceWorkerRegistrationKey ServiceWorkerRegistrationKey::isolatedCopy() const
 {
-    return { m_clientCreationURL.isolatedCopy(), m_topOrigin.isolatedCopy(), m_scope.isolatedCopy() };
+    return { m_topOrigin.isolatedCopy(), m_scope.isolatedCopy() };
 }
 
 bool ServiceWorkerRegistrationKey::isMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const
@@ -81,7 +79,7 @@ bool ServiceWorkerRegistrationKey::originIsMatching(const SecurityOriginData& to
 #ifndef NDEBUG
 String ServiceWorkerRegistrationKey::loggingString() const
 {
-    return makeString(m_topOrigin.debugString(), "-", m_clientCreationURL.string(), "-", m_scope.string());
+    return makeString(m_topOrigin.debugString(), "-", m_scope.string());
 }
 #endif
 
index 81b01bc..429824f 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 class ServiceWorkerRegistrationKey {
 public:
     ServiceWorkerRegistrationKey() = default;
-    WEBCORE_EXPORT ServiceWorkerRegistrationKey(URL&& clientURL, SecurityOriginData&& topOrigin, URL&& scope);
+    WEBCORE_EXPORT ServiceWorkerRegistrationKey(SecurityOriginData&& topOrigin, URL&& scope);
 
     static ServiceWorkerRegistrationKey emptyKey();
     unsigned hash() const;
@@ -46,8 +46,8 @@ public:
     size_t scopeLength() const { return m_scope.string().length(); }
 
     const SecurityOriginData& topOrigin() const { return m_topOrigin; }
-    const URL& clientCreationURL() const { return m_clientCreationURL; }
-    void setClientCreationURL(URL&& url) { m_clientCreationURL = WTFMove(url); }
+    const URL& scope() const { return m_scope; }
+    void setScope(URL&& scope) { m_scope = WTFMove(scope); }
 
     ServiceWorkerRegistrationKey isolatedCopy() const;
 
@@ -59,7 +59,6 @@ public:
 #endif
 
 private:
-    URL m_clientCreationURL;
     SecurityOriginData m_topOrigin;
     URL m_scope;
 };
@@ -67,16 +66,12 @@ private:
 template<class Encoder>
 void ServiceWorkerRegistrationKey::encode(Encoder& encoder) const
 {
-    encoder << m_clientCreationURL << m_topOrigin << m_scope;
+    encoder << m_topOrigin << m_scope;
 }
 
 template<class Decoder>
 std::optional<ServiceWorkerRegistrationKey> ServiceWorkerRegistrationKey::decode(Decoder& decoder)
 {
-    URL clientCreationURL;
-    if (!decoder.decode(clientCreationURL))
-        return std::nullopt;
-
     std::optional<SecurityOriginData> topOrigin;
     decoder >> topOrigin;
     if (!topOrigin)
@@ -86,7 +81,7 @@ std::optional<ServiceWorkerRegistrationKey> ServiceWorkerRegistrationKey::decode
     if (!decoder.decode(scope))
         return std::nullopt;
 
-    return { { WTFMove(clientCreationURL), WTFMove(*topOrigin), WTFMove(scope) } };
+    return ServiceWorkerRegistrationKey { WTFMove(*topOrigin), WTFMove(scope) };
 }
 
 } // namespace WebCore
@@ -102,8 +97,8 @@ struct ServiceWorkerRegistrationKeyHash {
 template<> struct HashTraits<WebCore::ServiceWorkerRegistrationKey> : GenericHashTraits<WebCore::ServiceWorkerRegistrationKey> {
     static WebCore::ServiceWorkerRegistrationKey emptyValue() { return WebCore::ServiceWorkerRegistrationKey::emptyKey(); }
 
-    static void constructDeletedValue(WebCore::ServiceWorkerRegistrationKey& slot) { slot.setClientCreationURL(WebCore::URL(HashTableDeletedValue)); }
-    static bool isDeletedValue(const WebCore::ServiceWorkerRegistrationKey& slot) { return slot.clientCreationURL().isHashTableDeletedValue(); }
+    static void constructDeletedValue(WebCore::ServiceWorkerRegistrationKey& slot) { slot.setScope(WebCore::URL(HashTableDeletedValue)); }
+    static bool isDeletedValue(const WebCore::ServiceWorkerRegistrationKey& slot) { return slot.scope().isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::ServiceWorkerRegistrationKey> {