Title: [250283] trunk
Revision
250283
Author
commit-qu...@webkit.org
Date
2019-09-23 22:25:11 -0700 (Mon, 23 Sep 2019)

Log Message

Fix WPT test html/browsers/offline/application-cache-api/api_swapcache_error.https.html
https://bugs.webkit.org/show_bug.cgi?id=202056
<rdar://problem/55523986>

Patch by Alex Christensen <achristen...@webkit.org> on 2019-09-23
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https-expected.txt:

Source/WebCore:

The test makes sure we throw an exception when we are in an invalid state, which we should definitely do.

* loader/appcache/ApplicationCache.cpp:
(WebCore::ApplicationCache::setGroup):
(WebCore::ApplicationCache::setManifestResource):
* loader/appcache/ApplicationCache.h:
(WebCore::ApplicationCache::manifestResource const):
(WebCore::ApplicationCache::group const):
* loader/appcache/ApplicationCacheGroup.h:
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::candidateApplicationCacheGroup const):
(WebCore::ApplicationCacheHost::failedLoadingMainResource):
(WebCore::ApplicationCacheHost::setCandidateApplicationCacheGroup):
(WebCore::ApplicationCacheHost::swapCache):
* loader/appcache/ApplicationCacheHost.h:
(WebCore::ApplicationCacheHost::candidateApplicationCacheGroup const): Deleted.
* loader/appcache/ApplicationCacheResource.h:

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (250282 => 250283)


--- trunk/LayoutTests/ChangeLog	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/LayoutTests/ChangeLog	2019-09-24 05:25:11 UTC (rev 250283)
@@ -1,3 +1,13 @@
+2019-09-23  Alex Christensen  <achristen...@webkit.org>
+
+        Fix WPT test html/browsers/offline/application-cache-api/api_swapcache_error.https.html
+        https://bugs.webkit.org/show_bug.cgi?id=202056
+        <rdar://problem/55523986>
+
+        Reviewed by Youenn Fablet.
+
+        * TestExpectations:
+
 2019-09-23  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Import SVG web-platform-tests

Modified: trunk/LayoutTests/TestExpectations (250282 => 250283)


--- trunk/LayoutTests/TestExpectations	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/LayoutTests/TestExpectations	2019-09-24 05:25:11 UTC (rev 250283)
@@ -378,7 +378,6 @@
 [ Release ] imported/w3c/web-platform-tests/html/rendering/replaced-elements/embedded-content/video-controls-vertical-writing-mode.html [ ImageOnlyFailure ]
 
 # Newly imported WPT tests that are crashing.
-[ Debug ] imported/w3c/web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https.html [ Crash ]
 [ Debug ] imported/w3c/web-platform-tests/html/rendering/replaced-elements/embedded-content/video-controls-vertical-writing-mode.html [ Crash ]
 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-embed-element/embed-represent-nothing-04.html [ ImageOnlyFailure Crash ]
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (250282 => 250283)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-09-24 05:25:11 UTC (rev 250283)
@@ -1,3 +1,13 @@
+2019-09-23  Alex Christensen  <achristen...@webkit.org>
+
+        Fix WPT test html/browsers/offline/application-cache-api/api_swapcache_error.https.html
+        https://bugs.webkit.org/show_bug.cgi?id=202056
+        <rdar://problem/55523986>
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https-expected.txt:
+
 2019-09-23  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Update WPT tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https-expected.txt (250282 => 250283)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https-expected.txt	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/offline/application-cache-api/api_swapcache_error.https-expected.txt	2019-09-24 05:25:11 UTC (rev 250283)
@@ -1,4 +1,4 @@
 CONSOLE MESSAGE: line 2: ApplicationCache is deprecated. Please use ServiceWorkers instead.
 
-FAIL INVALID_STATE_ERR error test assert_throws: function "function (){cache.swapCache();}" did not throw
+PASS INVALID_STATE_ERR error test 
 

Modified: trunk/Source/WebCore/ChangeLog (250282 => 250283)


--- trunk/Source/WebCore/ChangeLog	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/ChangeLog	2019-09-24 05:25:11 UTC (rev 250283)
@@ -1,3 +1,29 @@
+2019-09-23  Alex Christensen  <achristen...@webkit.org>
+
+        Fix WPT test html/browsers/offline/application-cache-api/api_swapcache_error.https.html
+        https://bugs.webkit.org/show_bug.cgi?id=202056
+        <rdar://problem/55523986>
+
+        Reviewed by Youenn Fablet.
+
+        The test makes sure we throw an exception when we are in an invalid state, which we should definitely do.
+
+        * loader/appcache/ApplicationCache.cpp:
+        (WebCore::ApplicationCache::setGroup):
+        (WebCore::ApplicationCache::setManifestResource):
+        * loader/appcache/ApplicationCache.h:
+        (WebCore::ApplicationCache::manifestResource const):
+        (WebCore::ApplicationCache::group const):
+        * loader/appcache/ApplicationCacheGroup.h:
+        * loader/appcache/ApplicationCacheHost.cpp:
+        (WebCore::ApplicationCacheHost::candidateApplicationCacheGroup const):
+        (WebCore::ApplicationCacheHost::failedLoadingMainResource):
+        (WebCore::ApplicationCacheHost::setCandidateApplicationCacheGroup):
+        (WebCore::ApplicationCacheHost::swapCache):
+        * loader/appcache/ApplicationCacheHost.h:
+        (WebCore::ApplicationCacheHost::candidateApplicationCacheGroup const): Deleted.
+        * loader/appcache/ApplicationCacheResource.h:
+
 2019-09-23  Chris Dumez  <cdu...@apple.com>
 
         PlugInClient::didStartFromOrigin() does not need a sessionID

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCache.cpp (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCache.cpp	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCache.cpp	2019-09-24 05:25:11 UTC (rev 250283)
@@ -54,7 +54,7 @@
 void ApplicationCache::setGroup(ApplicationCacheGroup* group)
 {
     ASSERT(!m_group || group == m_group);
-    m_group = group;
+    m_group = makeWeakPtr(group);
 }
 
 bool ApplicationCache::isComplete()
@@ -62,12 +62,22 @@
     return m_group && m_group->cacheIsComplete(*this);
 }
 
+ApplicationCacheResource* ApplicationCache::manifestResource() const
+{
+    return m_manifest.get();
+}
+
+ApplicationCacheGroup* ApplicationCache::group() const
+{
+    return m_group.get();
+}
+
 void ApplicationCache::setManifestResource(Ref<ApplicationCacheResource>&& manifest)
 {
     ASSERT(!m_manifest);
     ASSERT(manifest->type() & ApplicationCacheResource::Manifest);
 
-    m_manifest = manifest.ptr();
+    m_manifest = makeWeakPtr(manifest.get());
 
     addResource(WTFMove(manifest));
 }

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCache.h (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCache.h	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCache.h	2019-09-24 05:25:11 UTC (rev 250283)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
@@ -45,10 +46,10 @@
     void addResource(Ref<ApplicationCacheResource>&&);
 
     void setManifestResource(Ref<ApplicationCacheResource>&&);
-    ApplicationCacheResource* manifestResource() const { return m_manifest; }
+    ApplicationCacheResource* manifestResource() const;
 
     void setGroup(ApplicationCacheGroup*);
-    ApplicationCacheGroup* group() const { return m_group; }
+    ApplicationCacheGroup* group() const;
 
     bool isComplete();
 
@@ -83,9 +84,9 @@
 private:
     ApplicationCache();
 
-    ApplicationCacheGroup* m_group { nullptr };
+    WeakPtr<ApplicationCacheGroup> m_group;
     ResourceMap m_resources;
-    ApplicationCacheResource* m_manifest { nullptr };
+    WeakPtr<ApplicationCacheResource> m_manifest;
 
     bool m_allowAllNetworkRequests { false };
     Vector<URL> m_onlineWhitelist;

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h	2019-09-24 05:25:11 UTC (rev 250283)
@@ -31,6 +31,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/URL.h>
+#include <wtf/WeakPtr.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -48,7 +49,7 @@
     ApplicationCacheUpdateWithoutBrowsingContext
 };
 
-class ApplicationCacheGroup {
+class ApplicationCacheGroup : public CanMakeWeakPtr<ApplicationCacheGroup> {
     WTF_MAKE_NONCOPYABLE(ApplicationCacheGroup);
     WTF_MAKE_FAST_ALLOCATED;
 public:

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2019-09-24 05:25:11 UTC (rev 250283)
@@ -63,6 +63,11 @@
         m_candidateApplicationCacheGroup->disassociateDocumentLoader(m_documentLoader);
 }
 
+ApplicationCacheGroup* ApplicationCacheHost::candidateApplicationCacheGroup() const
+{
+    return m_candidateApplicationCacheGroup.get();
+}
+
 void ApplicationCacheHost::selectCacheWithoutManifest()
 {
     ASSERT(m_documentLoader.frame());
@@ -144,7 +149,7 @@
 
 void ApplicationCacheHost::failedLoadingMainResource()
 {
-    auto* group = m_candidateApplicationCacheGroup;
+    auto* group = m_candidateApplicationCacheGroup.get();
     if (!group && m_applicationCache) {
         if (mainResourceApplicationCache()) {
             // Even when the main resource is being loaded from an application cache, loading can fail if aborted.
@@ -389,7 +394,7 @@
 void ApplicationCacheHost::setCandidateApplicationCacheGroup(ApplicationCacheGroup* group)
 {
     ASSERT(!m_applicationCache);
-    m_candidateApplicationCacheGroup = group;
+    m_candidateApplicationCacheGroup = makeWeakPtr(group);
 }
     
 void ApplicationCacheHost::setApplicationCache(RefPtr<ApplicationCache>&& applicationCache)
@@ -519,19 +524,23 @@
     auto* cache = applicationCache();
     if (!cache)
         return false;
+    
+    auto* group = cache->group();
+    if (!group)
+        return false;
 
     // If the group of application caches to which cache belongs has the lifecycle status obsolete, unassociate document from cache.
-    if (cache->group()->isObsolete()) {
-        cache->group()->disassociateDocumentLoader(m_documentLoader);
+    if (group->isObsolete()) {
+        group->disassociateDocumentLoader(m_documentLoader);
         return true;
     }
 
     // If there is no newer cache, raise an InvalidStateError exception.
-    auto* newestCache = cache->group()->newestCache();
-    if (cache == newestCache)
+    auto* newestCache = group->newestCache();
+    if (!newestCache || cache == newestCache)
         return false;
     
-    ASSERT(cache->group() == newestCache->group());
+    ASSERT(group == newestCache->group());
     setApplicationCache(newestCache);
     InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader.frame());
     return true;

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h	2019-09-24 05:25:11 UTC (rev 250283)
@@ -141,7 +141,7 @@
 
     bool scheduleLoadFallbackResourceFromApplicationCache(ResourceLoader*, ApplicationCache* = nullptr);
     void setCandidateApplicationCacheGroup(ApplicationCacheGroup*);
-    ApplicationCacheGroup* candidateApplicationCacheGroup() const { return m_candidateApplicationCacheGroup; }
+    ApplicationCacheGroup* candidateApplicationCacheGroup() const;
     void setApplicationCache(RefPtr<ApplicationCache>&&);
     ApplicationCache* applicationCache() const { return m_applicationCache.get(); }
     ApplicationCache* mainResourceApplicationCache() const { return m_mainResourceApplicationCache.get(); }
@@ -158,7 +158,7 @@
 
     // Before an application cache has finished loading, this will be the candidate application
     // group that the document loader is associated with.
-    ApplicationCacheGroup* m_candidateApplicationCacheGroup { nullptr };
+    WeakPtr<ApplicationCacheGroup> m_candidateApplicationCacheGroup;
 
     // This is the application cache the main resource was loaded from (if any).
     RefPtr<ApplicationCache> m_mainResourceApplicationCache;

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheResource.h (250282 => 250283)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheResource.h	2019-09-24 05:11:41 UTC (rev 250282)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheResource.h	2019-09-24 05:25:11 UTC (rev 250283)
@@ -26,10 +26,11 @@
 #pragma once
 
 #include "SubstituteResource.h"
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
-class ApplicationCacheResource : public SubstituteResource {
+class ApplicationCacheResource : public SubstituteResource, public CanMakeWeakPtr<ApplicationCacheResource> {
 public:
     enum Type {
         Master = 1 << 0,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to