Changeset 39474 in webkit


Ignore:
Timestamp:
Dec 25, 2008 1:12:07 PM (15 years ago)
Author:
ap@webkit.org
Message:

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=22993
Application cache shouldn't be inherited by subframes

<rdar://problem/6284708> AppCache crashes in ApplicationCacheResource::addType()
This crash happened because main resource for subframe was looked up in top frame's
appcache. If not for the spec change, it could have been fixed by preventing the load
altogether.

Test: http/tests/appcache/foreign-iframe-main.html
I intend to write additional tests for the behavior change.

  • loader/DocumentLoader.cpp: (WebCore::DocumentLoader::shouldLoadResourceFromApplicationCache):
  • loader/DocumentLoader.h: (WebCore::DocumentLoader::applicationCache):
  • loader/MainResourceLoader.cpp: (WebCore::MainResourceLoader::load):
  • loader/appcache/DOMApplicationCache.cpp: (WebCore::DOMApplicationCache::associatedCache): Removed DocumentLoader::topLevelApplicationCache(), and changed callers accordingly.
  • loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::selectCache): (WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL): Removed checks for the frame being top-level one, now that subframes are cached independently.
Location:
trunk
Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r39469 r39474  
     12008-12-25  Alexey Proskuryakov  <ap@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=22993
     6        Application cache shouldn't be inherited by subframes
     7
     8        <rdar://problem/6284708> AppCache crashes in ApplicationCacheResource::addType()
     9
     10        * http/tests/appcache/foreign-iframe-main-expected.txt: Added.
     11        * http/tests/appcache/foreign-iframe-main.html: Added.
     12        * http/tests/appcache/resources/foreign-iframe-subresource.js: Added.
     13        * http/tests/appcache/resources/foreign-iframe.html: Added.
     14        * http/tests/appcache/resources/foreign-iframe.manifest: Added.
     15
    1162008-12-24  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/WebCore/ChangeLog

    r39473 r39474  
     12008-12-25  Alexey Proskuryakov  <ap@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=22993
     6        Application cache shouldn't be inherited by subframes
     7
     8        <rdar://problem/6284708> AppCache crashes in ApplicationCacheResource::addType()
     9        This crash happened because main resource for subframe was looked up in top frame's
     10        appcache. If not for the spec change, it could have been fixed by preventing the load
     11        altogether.
     12
     13        Test: http/tests/appcache/foreign-iframe-main.html
     14        I intend to write additional tests for the behavior change.
     15
     16        * loader/DocumentLoader.cpp:
     17        (WebCore::DocumentLoader::shouldLoadResourceFromApplicationCache):
     18        * loader/DocumentLoader.h:
     19        (WebCore::DocumentLoader::applicationCache):
     20        * loader/MainResourceLoader.cpp:
     21        (WebCore::MainResourceLoader::load):
     22        * loader/appcache/DOMApplicationCache.cpp:
     23        (WebCore::DOMApplicationCache::associatedCache):
     24        Removed DocumentLoader::topLevelApplicationCache(), and changed callers accordingly.
     25
     26        * loader/appcache/ApplicationCacheGroup.cpp:
     27        (WebCore::ApplicationCacheGroup::selectCache):
     28        (WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL):
     29        Removed checks for the frame being top-level one, now that subframes are cached independently.
     30
    1312008-12-25  Antti Koivisto  <antti@apple.com>
    232
  • trunk/WebCore/loader/DocumentLoader.cpp

    r39304 r39474  
    853853}
    854854
    855 ApplicationCache* DocumentLoader::topLevelApplicationCache() const
    856 {
    857     if (!m_frame)
    858         return 0;
    859    
    860     if (m_applicationCache)
    861         return m_applicationCache.get();
    862    
    863     if (Page* page = m_frame->page())
    864         return page->mainFrame()->loader()->documentLoader()->applicationCache();
    865    
    866     return 0;
    867 }
    868 
    869855ApplicationCache* DocumentLoader::mainResourceApplicationCache() const
    870856{
     
    878864bool DocumentLoader::shouldLoadResourceFromApplicationCache(const ResourceRequest& request, ApplicationCacheResource*& resource)
    879865{
    880     ApplicationCache* cache = topLevelApplicationCache();   
     866    ApplicationCache* cache = applicationCache();
    881867    if (!cache)
    882868        return false;
  • trunk/WebCore/loader/DocumentLoader.h

    r38728 r39474  
    206206        void setApplicationCache(PassRefPtr<ApplicationCache> applicationCache);
    207207        ApplicationCache* applicationCache() const { return m_applicationCache.get(); }
    208         ApplicationCache* topLevelApplicationCache() const;
    209208
    210209        ApplicationCache* mainResourceApplicationCache() const;
  • trunk/WebCore/loader/MainResourceLoader.cpp

    r39432 r39474  
    434434        ASSERT(!m_applicationCache);
    435435
    436         if (Page* page = frameLoader()->frame()->page()) {
    437             if (frameLoader()->frame() == page->mainFrame())
    438                 m_applicationCache = ApplicationCacheGroup::cacheForMainRequest(r, m_documentLoader.get());
    439             else
    440                 m_applicationCache = frameLoader()->documentLoader()->topLevelApplicationCache();
    441         }
     436        m_applicationCache = ApplicationCacheGroup::cacheForMainRequest(r, m_documentLoader.get());
    442437           
    443438        if (m_applicationCache) {
  • trunk/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r39437 r39474  
    113113    ApplicationCache* mainResourceCache = documentLoader->mainResourceApplicationCache();
    114114   
    115     // Check if the main resource is being loaded as part of navigation of the main frame
    116     bool isMainFrame = frame->page()->mainFrame() == frame;
    117    
    118     if (!isMainFrame) {
    119         if (mainResourceCache && manifestURL != mainResourceCache->group()->manifestURL()) {
    120             ApplicationCacheResource* resource = mainResourceCache->resourceForURL(documentLoader->originalURL());
    121             ASSERT(resource);
    122            
    123             resource->addType(ApplicationCacheResource::Foreign);
    124         }
    125 
    126         return;
    127     }
    128    
    129115    if (mainResourceCache) {
    130116        if (manifestURL == mainResourceCache->group()->m_manifestURL) {
     
    201187
    202188    ApplicationCache* mainResourceCache = documentLoader->mainResourceApplicationCache();
    203     bool isMainFrame = frame->page()->mainFrame() == frame;
    204 
    205     if (isMainFrame && mainResourceCache) {
     189
     190    if (mainResourceCache) {
    206191        mainResourceCache->group()->associateDocumentLoaderWithCache(documentLoader, mainResourceCache);
    207192        mainResourceCache->group()->update(frame);
  • trunk/WebCore/loader/appcache/DOMApplicationCache.cpp

    r38845 r39474  
    5656        return 0;
    5757 
    58     return m_frame->loader()->documentLoader()->topLevelApplicationCache();
     58    return m_frame->loader()->documentLoader()->applicationCache();
    5959}
    6060
Note: See TracChangeset for help on using the changeset viewer.