Changeset 228591 in webkit
- Timestamp:
- Feb 16, 2018 5:43:32 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228587 r228591 1 2018-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 1 13 2018-02-16 Youenn Fablet <youenn@apple.com> 2 14 -
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.3 1 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 4 2 CONSOLE MESSAGE: Application Cache manifest could not be fetched, because the manifest had a 404 response. 5 3 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 6 4 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 5 CONSOLE MESSAGE: Application Cache manifest could not be fetched, because the manifest had a 404 response. 6 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 7 7 SUCCESS: No crash. -
trunk/LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt
r228575 r228591 1 1 CONSOLE 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.3 2 Test that a redirect makes resource caching fail. 4 3 -
trunk/LayoutTests/http/tests/appcache/offline-access-expected.txt
r228575 r228591 1 1 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 2 2 CONSOLE 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.4 3 CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead. 5 4 Test that offline applications work when there is no network access (simulated). -
trunk/Source/WebCore/ChangeLog
r228590 r228591 1 2018-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 1 13 2018-02-16 Dean Jackson <dino@apple.com> 2 14 -
trunk/Source/WebCore/Sources.txt
r228575 r228591 1254 1254 loader/appcache/ApplicationCacheHost.cpp 1255 1255 loader/appcache/ApplicationCacheResource.cpp 1256 loader/appcache/ApplicationCacheResourceLoader.cpp1257 1256 loader/appcache/ApplicationCacheStorage.cpp 1258 1257 loader/appcache/DOMApplicationCache.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r228575 r228591 7104 7104 418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = "<group>"; }; 7105 7105 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>"; };7108 7106 419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetch.h; sourceTree = "<group>"; }; 7109 7107 419ACF901F97E7D6009F1A83 /* ServiceWorkerFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerFetch.cpp; sourceTree = "<group>"; }; … … 15695 15693 1A8F6BB50DB55CDC001DB794 /* ApplicationCacheResource.cpp */, 15696 15694 1A8F6BB60DB55CDC001DB794 /* ApplicationCacheResource.h */, 15697 41945694203502A5004BA277 /* ApplicationCacheResourceLoader.cpp */,15698 41945696203502A6004BA277 /* ApplicationCacheResourceLoader.h */,15699 15695 1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */, 15700 15696 1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */, -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r228575 r228591 1539 1539 ASSERT(!mainResourceLoader() || mainResourceLoader() != loader); 1540 1540 1541 // Application Cache loaders are handled by their ApplicationCacheGroup directly.1542 if (loader->options().applicationCacheMode == ApplicationCacheMode::Bypass)1543 return;1544 1545 1541 // A page in the PageCache or about to enter PageCache should not be able to start loads. 1546 1542 ASSERT_WITH_SECURITY_IMPLICATION(!document() || document()->pageCacheState() == Document::NotInPageCache); -
trunk/Source/WebCore/loader/ResourceLoaderOptions.h
r228575 r228591 102 102 }; 103 103 104 enum class ApplicationCacheMode {105 Use,106 Bypass107 };108 109 104 enum class ContentEncodingSniffingPolicy { 110 105 Sniff, … … 146 141 InitiatorContext initiatorContext { InitiatorContext::Document }; 147 142 ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All }; 148 ApplicationCacheMode applicationCacheMode { ApplicationCacheMode::Use };149 143 #if ENABLE(SERVICE_WORKER) 150 144 std::optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier; -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
r228575 r228591 30 30 #include "ApplicationCacheHost.h" 31 31 #include "ApplicationCacheResource.h" 32 #include "ApplicationCacheResourceLoader.h"33 32 #include "ApplicationCacheStorage.h" 34 33 #include "Chrome.h" … … 316 315 void ApplicationCacheGroup::stopLoading() 317 316 { 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 323 327 if (m_currentHandle) { 324 ASSERT(!m_ loader);328 ASSERT(!m_manifestHandle); 325 329 ASSERT(m_cacheBeingUpdated); 326 330 … … 433 437 } 434 438 435 ASSERT(!m_ loader);439 ASSERT(!m_manifestHandle); 436 440 ASSERT(!m_manifestResource); 437 441 ASSERT(!m_currentHandle); … … 440 444 441 445 // 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); 486 447 } 487 448 … … 533 494 ASSERT(m_frame); 534 495 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 } 535 502 536 503 ASSERT(handle == m_currentHandle); … … 612 579 { 613 580 UNUSED_PARAM(encodedDataLength); 614 ASSERT_UNUSED(handle, handle == m_currentHandle);615 581 616 582 InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifier, 0, length, 0); 617 583 584 if (handle == m_manifestHandle) { 585 didReceiveManifestData(data, length); 586 return; 587 } 588 589 ASSERT(handle == m_currentHandle); 590 618 591 ASSERT(m_currentResource); 619 592 m_currentResource->data().append(data, length); … … 625 598 NetworkLoadMetrics emptyMetrics; 626 599 InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader().documentLoader(), m_currentResourceIdentifier, emptyMetrics, nullptr); 600 601 if (handle == m_manifestHandle) { 602 didFinishLoadingManifest(); 603 return; 604 } 627 605 628 606 ASSERT(m_currentHandle == handle); … … 655 633 { 656 634 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 } 657 641 658 642 ASSERT(handle == m_currentHandle); … … 682 666 } 683 667 668 void 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 700 void ApplicationCacheGroup::didReceiveManifestData(const char* data, int length) 701 { 702 if (m_manifestResource) 703 m_manifestResource->data().append(data, length); 704 } 705 684 706 void ApplicationCacheGroup::didFinishLoadingManifest() 685 707 { … … 693 715 } 694 716 695 m_ loader= nullptr;717 m_manifestHandle = nullptr; 696 718 697 719 // Check if the manifest was not modified. … … 757 779 758 780 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 }789 781 } 790 782 … … 857 849 void ApplicationCacheGroup::checkIfLoadIsComplete() 858 850 { 859 if (m_ loader|| !m_pendingEntries.isEmpty() || m_downloadingPendingMasterResourceLoadersCount)860 return; 861 851 if (m_manifestHandle || !m_pendingEntries.isEmpty() || m_downloadingPendingMasterResourceLoadersCount) 852 return; 853 862 854 // We're done, all resources have finished downloading (successfully or not). 863 855 -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
r228575 r228591 26 26 #pragma once 27 27 28 #include "ApplicationCacheResourceLoader.h"29 28 #include "DOMApplicationCache.h" 30 29 #include "URL.h" … … 120 119 void didFail(ResourceHandle*, const ResourceError&) final; 121 120 121 void didReceiveManifestResponse(const ResourceResponse&); 122 void didReceiveManifestData(const char*, int); 122 123 void didFinishLoadingManifest(); 123 void didFailLoadingManifest(ApplicationCacheResourceLoader::Error);124 125 124 void didReachMaxAppCacheSize(); 126 125 void didReachOriginQuota(int64_t totalSpaceNeeded); … … 138 137 139 138 void stopLoading(); 140 141 ResourceRequest createRequest(URL&&, ApplicationCacheResource*);142 139 143 140 Ref<ApplicationCacheStorage> m_storage; … … 199 196 200 197 RefPtr<ApplicationCacheResource> m_manifestResource; 201 202 RefPtr<ApplicationCacheResourceLoader> m_loader; 198 RefPtr<ResourceHandle> m_manifestHandle; 203 199 204 200 int64_t m_availableSpaceInQuota; -
trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
r228575 r228591 170 170 bool ApplicationCacheHost::maybeLoadResource(ResourceLoader& loader, const ResourceRequest& request, const URL& originalURL) 171 171 { 172 if (loader.options().applicationCacheMode != ApplicationCacheMode::Use)173 return false;174 175 172 if (!isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request)) 176 173 return false; … … 189 186 bool ApplicationCacheHost::maybeLoadFallbackForRedirect(ResourceLoader* resourceLoader, ResourceRequest& request, const ResourceResponse& redirectResponse) 190 187 { 191 if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)192 return false;193 194 188 if (!redirectResponse.isNull() && !protocolHostAndPortAreEqual(request.url(), redirectResponse.url())) { 195 189 if (scheduleLoadFallbackResourceFromApplicationCache(resourceLoader)) … … 201 195 bool ApplicationCacheHost::maybeLoadFallbackForResponse(ResourceLoader* resourceLoader, const ResourceResponse& response) 202 196 { 203 if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)204 return false;205 206 197 if (response.httpStatusCode() / 100 == 4 || response.httpStatusCode() / 100 == 5) { 207 198 if (scheduleLoadFallbackResourceFromApplicationCache(resourceLoader)) … … 213 204 bool ApplicationCacheHost::maybeLoadFallbackForError(ResourceLoader* resourceLoader, const ResourceError& error) 214 205 { 215 if (resourceLoader && resourceLoader->options().applicationCacheMode != ApplicationCacheMode::Use)216 return false;217 218 206 if (!error.isCancellation()) { 219 207 if (resourceLoader == m_documentLoader.mainResourceLoader())
Note: See TracChangeset
for help on using the changeset viewer.