Changeset 228591 in webkit


Ignore:
Timestamp:
Feb 16, 2018 5:43:32 PM (6 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r228575.

Introduced LayoutTest crashes under GuardMalloc.

Reverted changeset:

"Use ResourceLoader to load appcache manifest"
https://bugs.webkit.org/show_bug.cgi?id=182861
https://trac.webkit.org/changeset/228575

Location:
trunk
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r228587 r228591  
     12018-02-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r228575.
     4
     5        Introduced LayoutTest crashes under GuardMalloc.
     6
     7        Reverted changeset:
     8
     9        "Use ResourceLoader to load appcache manifest"
     10        https://bugs.webkit.org/show_bug.cgi?id=182861
     11        https://trac.webkit.org/changeset/228575
     12
    1132018-02-16  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt

    r228575 r228591  
    1 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    2 CONSOLE MESSAGE: Application Cache manifest could not be fetched, because the manifest had a 404 response.
    31CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    42CONSOLE MESSAGE: Application Cache manifest could not be fetched, because the manifest had a 404 response.
    53CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    64CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
     5CONSOLE MESSAGE: Application Cache manifest could not be fetched, because the manifest had a 404 response.
     6CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    77SUCCESS: No crash.
  • trunk/LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt

    r228575 r228591  
    11CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    2 CONSOLE MESSAGE: Application Cache manifest could not be fetched, because a redirection was attempted.
    32Test that a redirect makes resource caching fail.
    43
  • trunk/LayoutTests/http/tests/appcache/offline-access-expected.txt

    r228575 r228591  
    11CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    22CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    3 CONSOLE MESSAGE: Application Cache manifest could not be fetched, because a redirection was attempted.
    43CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
    54Test that offline applications work when there is no network access (simulated).
  • trunk/Source/WebCore/ChangeLog

    r228590 r228591  
     12018-02-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r228575.
     4
     5        Introduced LayoutTest crashes under GuardMalloc.
     6
     7        Reverted changeset:
     8
     9        "Use ResourceLoader to load appcache manifest"
     10        https://bugs.webkit.org/show_bug.cgi?id=182861
     11        https://trac.webkit.org/changeset/228575
     12
    1132018-02-16  Dean Jackson  <dino@apple.com>
    214
  • trunk/Source/WebCore/Sources.txt

    r228575 r228591  
    12541254loader/appcache/ApplicationCacheHost.cpp
    12551255loader/appcache/ApplicationCacheResource.cpp
    1256 loader/appcache/ApplicationCacheResourceLoader.cpp
    12571256loader/appcache/ApplicationCacheStorage.cpp
    12581257loader/appcache/DOMApplicationCache.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r228575 r228591  
    71047104                418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = "<group>"; };
    71057105                418F88030FF957AE0080F045 /* JSAbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAbstractWorker.h; sourceTree = "<group>"; };
    7106                 41945694203502A5004BA277 /* ApplicationCacheResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheResourceLoader.cpp; sourceTree = "<group>"; };
    7107                 41945696203502A6004BA277 /* ApplicationCacheResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheResourceLoader.h; sourceTree = "<group>"; };
    71087106                419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetch.h; sourceTree = "<group>"; };
    71097107                419ACF901F97E7D6009F1A83 /* ServiceWorkerFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerFetch.cpp; sourceTree = "<group>"; };
     
    1569515693                                1A8F6BB50DB55CDC001DB794 /* ApplicationCacheResource.cpp */,
    1569615694                                1A8F6BB60DB55CDC001DB794 /* ApplicationCacheResource.h */,
    15697                                 41945694203502A5004BA277 /* ApplicationCacheResourceLoader.cpp */,
    15698                                 41945696203502A6004BA277 /* ApplicationCacheResourceLoader.h */,
    1569915695                                1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */,
    1570015696                                1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */,
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r228575 r228591  
    15391539    ASSERT(!mainResourceLoader() || mainResourceLoader() != loader);
    15401540
    1541     // Application Cache loaders are handled by their ApplicationCacheGroup directly.
    1542     if (loader->options().applicationCacheMode == ApplicationCacheMode::Bypass)
    1543         return;
    1544 
    15451541    // A page in the PageCache or about to enter PageCache should not be able to start loads.
    15461542    ASSERT_WITH_SECURITY_IMPLICATION(!document() || document()->pageCacheState() == Document::NotInPageCache);
  • trunk/Source/WebCore/loader/ResourceLoaderOptions.h

    r228575 r228591  
    102102};
    103103
    104 enum class ApplicationCacheMode {
    105     Use,
    106     Bypass
    107 };
    108 
    109104enum class ContentEncodingSniffingPolicy {
    110105    Sniff,
     
    146141    InitiatorContext initiatorContext { InitiatorContext::Document };
    147142    ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
    148     ApplicationCacheMode applicationCacheMode { ApplicationCacheMode::Use };
    149143#if ENABLE(SERVICE_WORKER)
    150144    std::optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier;
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r228575 r228591  
    3030#include "ApplicationCacheHost.h"
    3131#include "ApplicationCacheResource.h"
    32 #include "ApplicationCacheResourceLoader.h"
    3332#include "ApplicationCacheStorage.h"
    3433#include "Chrome.h"
     
    316315void ApplicationCacheGroup::stopLoading()
    317316{
    318     if (m_loader) {
    319         m_loader->cancel();
    320         m_loader = nullptr;
    321     }
    322 
     317    if (m_manifestHandle) {
     318        ASSERT(!m_currentHandle);
     319
     320        ASSERT(m_manifestHandle->client() == this);
     321        m_manifestHandle->clearClient();
     322
     323        m_manifestHandle->cancel();
     324        m_manifestHandle = nullptr;
     325    }
     326   
    323327    if (m_currentHandle) {
    324         ASSERT(!m_loader);
     328        ASSERT(!m_manifestHandle);
    325329        ASSERT(m_cacheBeingUpdated);
    326330
     
    433437    }
    434438   
    435     ASSERT(!m_loader);
     439    ASSERT(!m_manifestHandle);
    436440    ASSERT(!m_manifestResource);
    437441    ASSERT(!m_currentHandle);
     
    440444
    441445    // FIXME: Handle defer loading
    442 
    443     auto request = createRequest(URL { m_manifestURL }, m_newestCache ? m_newestCache->manifestResource() : nullptr);
    444 
    445     m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier();
    446     InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { });
    447 
    448     m_loader = ApplicationCacheResourceLoader::create(documentLoader.cachedResourceLoader(), WTFMove(request), [this] (auto&& resourceOrError) {
    449         if (!resourceOrError.has_value()) {
    450             auto error = resourceOrError.error();
    451             if (error == ApplicationCacheResourceLoader::Error::Abort)
    452                 return;
    453             if (error == ApplicationCacheResourceLoader::Error::CannotCreateResource) {
    454                 // FIXME: We should get back the error from ApplicationCacheResourceLoader level.
    455                 InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, ResourceError { ResourceError::Type::General });
    456                 this->cacheUpdateFailed();
    457                 return;
    458             }
    459             this->didFailLoadingManifest(error);
    460             ASSERT(!m_loader);
    461             return;
    462         }
    463 
    464         m_manifestResource = WTFMove(resourceOrError.value());
    465         this->didFinishLoadingManifest();
    466         ASSERT(!m_loader);
    467     });
    468 }
    469 
    470 ResourceRequest ApplicationCacheGroup::createRequest(URL&& url, ApplicationCacheResource* resource)
    471 {
    472     ResourceRequest request { WTFMove(url) };
    473     m_frame->loader().applyUserAgentIfNeeded(request);
    474     request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
    475 
    476     if (resource) {
    477         const String& lastModified = resource->response().httpHeaderField(HTTPHeaderName::LastModified);
    478         if (!lastModified.isEmpty())
    479             request.setHTTPHeaderField(HTTPHeaderName::IfModifiedSince, lastModified);
    480 
    481         const String& eTag = resource->response().httpHeaderField(HTTPHeaderName::ETag);
    482         if (!eTag.isEmpty())
    483             request.setHTTPHeaderField(HTTPHeaderName::IfNoneMatch, eTag);
    484     }
    485     return request;
     446    m_manifestHandle = createResourceHandle(m_manifestURL, m_newestCache ? m_newestCache->manifestResource() : 0);
    486447}
    487448
     
    533494    ASSERT(m_frame);
    534495    InspectorInstrumentation::didReceiveResourceResponse(*m_frame, m_currentResourceIdentifier, m_frame->loader().documentLoader(), response, nullptr);
     496
     497    if (handle == m_manifestHandle) {
     498        didReceiveManifestResponse(response);
     499        completionHandler();
     500        return;
     501    }
    535502
    536503    ASSERT(handle == m_currentHandle);
     
    612579{
    613580    UNUSED_PARAM(encodedDataLength);
    614     ASSERT_UNUSED(handle, handle == m_currentHandle);
    615581
    616582    InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifier, 0, length, 0);
    617583
     584    if (handle == m_manifestHandle) {
     585        didReceiveManifestData(data, length);
     586        return;
     587    }
     588   
     589    ASSERT(handle == m_currentHandle);
     590   
    618591    ASSERT(m_currentResource);
    619592    m_currentResource->data().append(data, length);
     
    625598    NetworkLoadMetrics emptyMetrics;
    626599    InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, emptyMetrics, nullptr);
     600
     601    if (handle == m_manifestHandle) {
     602        didFinishLoadingManifest();
     603        return;
     604    }
    627605
    628606    ASSERT(m_currentHandle == handle);
     
    655633{
    656634    InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, error);
     635
     636    if (handle == m_manifestHandle) {
     637        // A network error is logged elsewhere, no need to log again. Also, it's normal for manifest fetching to fail when working offline.
     638        cacheUpdateFailed();
     639        return;
     640    }
    657641
    658642    ASSERT(handle == m_currentHandle);
     
    682666}
    683667
     668void ApplicationCacheGroup::didReceiveManifestResponse(const ResourceResponse& response)
     669{
     670    ASSERT(!m_manifestResource);
     671    ASSERT(m_manifestHandle);
     672
     673    if (response.httpStatusCode() == 404 || response.httpStatusCode() == 410) {
     674        InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestHandle->firstRequest()));
     675        m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", String::number(response.httpStatusCode()), " response."));
     676        manifestNotFound();
     677        return;
     678    }
     679
     680    if (response.httpStatusCode() == 304)
     681        return;
     682
     683    if (response.httpStatusCode() / 100 != 2) {
     684        InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestHandle->firstRequest()));
     685        m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", String::number(response.httpStatusCode()), " response."));
     686        cacheUpdateFailed();
     687        return;
     688    }
     689
     690    if (response.url() != m_manifestHandle->firstRequest().url()) {
     691        InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestHandle->firstRequest()));
     692        m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, ASCIILiteral("Application Cache manifest could not be fetched, because a redirection was attempted."));
     693        cacheUpdateFailed();
     694        return;
     695    }
     696
     697    m_manifestResource = ApplicationCacheResource::create(m_manifestHandle->firstRequest().url(), response, ApplicationCacheResource::Manifest);
     698}
     699
     700void ApplicationCacheGroup::didReceiveManifestData(const char* data, int length)
     701{
     702    if (m_manifestResource)
     703        m_manifestResource->data().append(data, length);
     704}
     705
    684706void ApplicationCacheGroup::didFinishLoadingManifest()
    685707{
     
    693715    }
    694716
    695     m_loader = nullptr;
     717    m_manifestHandle = nullptr;
    696718
    697719    // Check if the manifest was not modified.
     
    757779
    758780    startLoadingEntry();
    759 }
    760 
    761 void ApplicationCacheGroup::didFailLoadingManifest(ApplicationCacheResourceLoader::Error error)
    762 {
    763     ASSERT(error != ApplicationCacheResourceLoader::Error::Abort && error != ApplicationCacheResourceLoader::Error::CannotCreateResource);
    764 
    765     InspectorInstrumentation::didReceiveResourceResponse(*m_frame, m_currentResourceIdentifier, m_frame->loader().documentLoader(), m_loader->resource()->response(), nullptr);
    766     switch (error) {
    767     case ApplicationCacheResourceLoader::Error::NetworkError:
    768         cacheUpdateFailed();
    769         break;
    770     case ApplicationCacheResourceLoader::Error::NotFound:
    771         InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_loader->resource()->resourceRequest()));
    772         m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", String::number(m_loader->resource()->response().httpStatusCode()), " response."));
    773         manifestNotFound();
    774         break;
    775     case ApplicationCacheResourceLoader::Error::NotOK:
    776         InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_loader->resource()->resourceRequest()));
    777         m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", String::number(m_loader->resource()->response().httpStatusCode()), " response."));
    778         cacheUpdateFailed();
    779         break;
    780     case ApplicationCacheResourceLoader::Error::RedirectForbidden:
    781         InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_loader->resource()->resourceRequest()));
    782         m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because a redirection was attempted."));
    783         cacheUpdateFailed();
    784         break;
    785     case ApplicationCacheResourceLoader::Error::CannotCreateResource:
    786     case ApplicationCacheResourceLoader::Error::Abort:
    787         break;
    788     }
    789781}
    790782
     
    857849void ApplicationCacheGroup::checkIfLoadIsComplete()
    858850{
    859     if (m_loader || !m_pendingEntries.isEmpty() || m_downloadingPendingMasterResourceLoadersCount)
    860         return;
    861 
     851    if (m_manifestHandle || !m_pendingEntries.isEmpty() || m_downloadingPendingMasterResourceLoadersCount)
     852        return;
     853   
    862854    // We're done, all resources have finished downloading (successfully or not).
    863855
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h

    r228575 r228591  
    2626#pragma once
    2727
    28 #include "ApplicationCacheResourceLoader.h"
    2928#include "DOMApplicationCache.h"
    3029#include "URL.h"
     
    120119    void didFail(ResourceHandle*, const ResourceError&) final;
    121120
     121    void didReceiveManifestResponse(const ResourceResponse&);
     122    void didReceiveManifestData(const char*, int);
    122123    void didFinishLoadingManifest();
    123     void didFailLoadingManifest(ApplicationCacheResourceLoader::Error);
    124 
    125124    void didReachMaxAppCacheSize();
    126125    void didReachOriginQuota(int64_t totalSpaceNeeded);
     
    138137   
    139138    void stopLoading();
    140 
    141     ResourceRequest createRequest(URL&&, ApplicationCacheResource*);
    142139
    143140    Ref<ApplicationCacheStorage> m_storage;
     
    199196
    200197    RefPtr<ApplicationCacheResource> m_manifestResource;
    201 
    202     RefPtr<ApplicationCacheResourceLoader> m_loader;
     198    RefPtr<ResourceHandle> m_manifestHandle;
    203199
    204200    int64_t m_availableSpaceInQuota;
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp

    r228575 r228591  
    170170bool ApplicationCacheHost::maybeLoadResource(ResourceLoader& loader, const ResourceRequest& request, const URL& originalURL)
    171171{
    172     if (loader.options().applicationCacheMode != ApplicationCacheMode::Use)
    173         return false;
    174 
    175172    if (!isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request))
    176173        return false;
     
    189186bool ApplicationCacheHost::maybeLoadFallbackForRedirect(ResourceLoader* resourceLoader, ResourceRequest& request, const ResourceResponse& redirectResponse)
    190187{
    191     if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)
    192         return false;
    193 
    194188    if (!redirectResponse.isNull() && !protocolHostAndPortAreEqual(request.url(), redirectResponse.url())) {
    195189        if (scheduleLoadFallbackResourceFromApplicationCache(resourceLoader))
     
    201195bool ApplicationCacheHost::maybeLoadFallbackForResponse(ResourceLoader* resourceLoader, const ResourceResponse& response)
    202196{
    203     if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)
    204         return false;
    205 
    206197    if (response.httpStatusCode() / 100 == 4 || response.httpStatusCode() / 100 == 5) {
    207198        if (scheduleLoadFallbackResourceFromApplicationCache(resourceLoader))
     
    213204bool ApplicationCacheHost::maybeLoadFallbackForError(ResourceLoader* resourceLoader, const ResourceError& error)
    214205{
    215     if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)
    216         return false;
    217 
    218206    if (!error.isCancellation()) {
    219207        if (resourceLoader == m_documentLoader.mainResourceLoader())
Note: See TracChangeset for help on using the changeset viewer.