Changeset 62957 in webkit


Ignore:
Timestamp:
Jul 9, 2010 8:55:57 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-09 Michael Nordman <Michael Nordman>

Reviewed by Dumitru Daniliuc.

Add a layout test to verify the expected number of progress events are raised by the appcache,
and that those events have properly set 'lengthComputable', 'loaded', and 'total' attributes.
Also update a couple of other tests that depend on counting the number of progress events to
determine success or failure to now expect the additional final progress event that is being
raised.
https://bugs.webkit.org/show_bug.cgi?id=37602

  • http/tests/appcache/foreign-iframe-main-expected.txt:
  • http/tests/appcache/progress-counter-expected.txt: Added.
  • http/tests/appcache/progress-counter.html: Added.
  • http/tests/appcache/resources/different-https-origin-resource.html:
  • http/tests/appcache/resources/progress-counter.manifest: Added.

2010-07-09 Michael Nordman <Michael Nordman>

Reviewed by Dumitru Daniliuc.

Use class ProgressEvent when raising appcache related progress events and
set the 'total', 'loaded', and 'lengthComputable' attributes.
Also raise the final progress event with the 'total' and 'loaded' attribute
values are equal to one another to keep pace with the spec for this feature.
https://bugs.webkit.org/show_bug.cgi?id=37602

Test: http/tests/appcache/progress-counter.html

  • loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::ApplicationCacheGroup): (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete): (WebCore::ApplicationCacheGroup::startLoadingEntry): (WebCore::CallCacheListenerTask::create): (WebCore::CallCacheListenerTask::performTask): (WebCore::CallCacheListenerTask::CallCacheListenerTask): (WebCore::ApplicationCacheGroup::postListenerTask):
  • loader/appcache/ApplicationCacheGroup.h: (WebCore::ApplicationCacheGroup::postListenerTask):
  • loader/appcache/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::notifyDOMApplicationCache): (WebCore::ApplicationCacheHost::stopDeferringEvents): (WebCore::ApplicationCacheHost::dispatchDOMEvent):
  • loader/appcache/ApplicationCacheHost.h: (WebCore::ApplicationCacheHost::DeferredEvent::DeferredEvent):

2010-07-09 Michael Nordman <Michael Nordman>

Reviewed by Dumitru Daniliuc.

Use class ProgressEvent when raising appcache related progress events and
set the 'total', 'loaded', and 'lengthComputable' attributes.
Also raise the final progress event with the 'total' and 'loaded' attribute
values are equal to one another to keep pace with the spec for this feature.
https://bugs.webkit.org/show_bug.cgi?id=37602

  • src/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::notifyDOMApplicationCache): (WebCore::ApplicationCacheHost::stopDeferringEvents): (WebCore::ApplicationCacheHost::dispatchDOMEvent):
  • src/ApplicationCacheHostInternal.h: (WebCore::ApplicationCacheHostInternal::notifyEventListener): (WebCore::ApplicationCacheHostInternal::notifyProgressEventListener):
Location:
trunk
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62952 r62957  
     12010-07-09  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Dumitru Daniliuc.
     4
     5        Add a layout test to verify the expected number of progress events are raised by the appcache,
     6        and that those events have properly set 'lengthComputable', 'loaded', and 'total' attributes.
     7        Also update a couple of other tests that depend on counting the number of progress events to
     8        determine success or failure to now expect the additional final progress event that is being
     9        raised.
     10        https://bugs.webkit.org/show_bug.cgi?id=37602
     11
     12        * http/tests/appcache/foreign-iframe-main-expected.txt:
     13        * http/tests/appcache/progress-counter-expected.txt: Added.
     14        * http/tests/appcache/progress-counter.html: Added.
     15        * http/tests/appcache/resources/different-https-origin-resource.html:
     16        * http/tests/appcache/resources/progress-counter.manifest: Added.
     17
    1182010-07-09  Ben Murdoch  <benm@google.com>
    219
  • trunk/LayoutTests/http/tests/appcache/foreign-iframe-main-expected.txt

    r40354 r62957  
    66progress
    77progress
     8progress
    89cached
    910SUCCESS
  • trunk/LayoutTests/http/tests/appcache/resources/different-https-origin-resource.html

    r58433 r62957  
    2121    finish();
    2222}
     23function progressHandler(e)
     24{
     25    // The only resource listed in the manifest file is in a different https origin and should be skipped.
     26    if (e.loaded != 0 || e.total != 0)
     27        fail();
     28}
    2329
    24 applicationCache.onprogress = function() { fail(); }
     30applicationCache.onprogress = progressHandler;
    2531applicationCache.onnoupdate = function() { finish(); }
    2632applicationCache.oncached = function() { finish(); }
  • trunk/WebCore/ChangeLog

    r62955 r62957  
     12010-07-09  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Dumitru Daniliuc.
     4
     5        Use class ProgressEvent when raising appcache related progress events and
     6        set the 'total', 'loaded', and 'lengthComputable' attributes.
     7        Also raise the final progress event with the 'total' and 'loaded' attribute
     8        values are equal to one another to keep pace with the spec for this feature.
     9        https://bugs.webkit.org/show_bug.cgi?id=37602
     10
     11        Test: http/tests/appcache/progress-counter.html
     12
     13        * loader/appcache/ApplicationCacheGroup.cpp:
     14        (WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
     15        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
     16        (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
     17        (WebCore::ApplicationCacheGroup::startLoadingEntry):
     18        (WebCore::CallCacheListenerTask::create):
     19        (WebCore::CallCacheListenerTask::performTask):
     20        (WebCore::CallCacheListenerTask::CallCacheListenerTask):
     21        (WebCore::ApplicationCacheGroup::postListenerTask):
     22        * loader/appcache/ApplicationCacheGroup.h:
     23        (WebCore::ApplicationCacheGroup::postListenerTask):
     24        * loader/appcache/ApplicationCacheHost.cpp:
     25        (WebCore::ApplicationCacheHost::notifyDOMApplicationCache):
     26        (WebCore::ApplicationCacheHost::stopDeferringEvents):
     27        (WebCore::ApplicationCacheHost::dispatchDOMEvent):
     28        * loader/appcache/ApplicationCacheHost.h:
     29        (WebCore::ApplicationCacheHost::DeferredEvent::DeferredEvent):
     30
    1312010-07-09  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
    232
  • trunk/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r62927 r62957  
    5858    , m_updateStatus(Idle)
    5959    , m_downloadingPendingMasterResourceLoadersCount(0)
     60    , m_progressTotal(0)
     61    , m_progressDone(0)
    6062    , m_frame(0)
    6163    , m_storageID(0)
     
    752754    m_cacheBeingUpdated->setFallbackURLs(manifest.fallbackURLs);
    753755    m_cacheBeingUpdated->setAllowsAllNetworkRequests(manifest.allowAllNetworkRequests);
    754    
     756
     757    m_progressTotal = m_pendingEntries.size();
     758    m_progressDone = 0;
     759
    755760    startLoadingEntry();
    756761}
     
    860865            if (oldNewestCache)
    861866                cacheStorage().remove(oldNewestCache.get());
    862             // Fire the success events.
     867
     868            // Fire the final progress event.
     869            ASSERT(m_progressDone == m_progressTotal);
     870            postListenerTask(ApplicationCacheHost::PROGRESS_EVENT, m_progressTotal, m_progressDone, m_associatedDocumentLoaders);
     871
     872            // Fire the success event.
    863873            postListenerTask(isUpgradeAttempt ? ApplicationCacheHost::UPDATEREADY_EVENT : ApplicationCacheHost::CACHED_EVENT, m_associatedDocumentLoaders);
    864874        } else {
     
    927937    EntryMap::const_iterator it = m_pendingEntries.begin();
    928938
    929     postListenerTask(ApplicationCacheHost::PROGRESS_EVENT, m_associatedDocumentLoaders);
     939    postListenerTask(ApplicationCacheHost::PROGRESS_EVENT, m_progressTotal, m_progressDone, m_associatedDocumentLoaders);
     940    m_progressDone++;
    930941
    931942    ASSERT(!m_currentHandle);
     
    10261037class CallCacheListenerTask : public ScriptExecutionContext::Task {
    10271038public:
    1028     static PassOwnPtr<CallCacheListenerTask> create(PassRefPtr<DocumentLoader> loader, ApplicationCacheHost::EventID eventID)
     1039    static PassOwnPtr<CallCacheListenerTask> create(PassRefPtr<DocumentLoader> loader, ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone)
    10291040    {
    1030         return adoptPtr(new CallCacheListenerTask(loader, eventID));
     1041        return adoptPtr(new CallCacheListenerTask(loader, eventID, progressTotal, progressDone));
    10311042    }
    10321043
     
    10411052        ASSERT(frame->loader()->documentLoader() == m_documentLoader.get());
    10421053
    1043         m_documentLoader->applicationCacheHost()->notifyDOMApplicationCache(m_eventID);
     1054        m_documentLoader->applicationCacheHost()->notifyDOMApplicationCache(m_eventID, m_progressTotal, m_progressDone);
    10441055    }
    10451056
    10461057private:
    1047     CallCacheListenerTask(PassRefPtr<DocumentLoader> loader, ApplicationCacheHost::EventID eventID)
     1058    CallCacheListenerTask(PassRefPtr<DocumentLoader> loader, ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone)
    10481059        : m_documentLoader(loader)
    10491060        , m_eventID(eventID)
     1061        , m_progressTotal(progressTotal)
     1062        , m_progressDone(progressDone)
    10501063    {
    10511064    }
     
    10531066    RefPtr<DocumentLoader> m_documentLoader;
    10541067    ApplicationCacheHost::EventID m_eventID;
     1068    int m_progressTotal;
     1069    int m_progressDone;
    10551070};
    10561071
    1057 void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, const HashSet<DocumentLoader*>& loaderSet)
     1072void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone, const HashSet<DocumentLoader*>& loaderSet)
    10581073{
    10591074    HashSet<DocumentLoader*>::const_iterator loaderSetEnd = loaderSet.end();
    10601075    for (HashSet<DocumentLoader*>::const_iterator iter = loaderSet.begin(); iter != loaderSetEnd; ++iter)
    1061         postListenerTask(eventID, *iter);
    1062 }
    1063 
    1064 void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, DocumentLoader* loader)
     1076        postListenerTask(eventID, progressTotal, progressDone, *iter);
     1077}
     1078
     1079void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone, DocumentLoader* loader)
    10651080{
    10661081    Frame* frame = loader->frame();
     
    10701085    ASSERT(frame->loader()->documentLoader() == loader);
    10711086
    1072     frame->document()->postTask(CallCacheListenerTask::create(loader, eventID));
     1087    frame->document()->postTask(CallCacheListenerTask::create(loader, eventID, progressTotal, progressDone));
    10731088}
    10741089
  • trunk/WebCore/loader/appcache/ApplicationCacheGroup.h

    r62502 r62957  
    9393
    9494private:
    95     static void postListenerTask(ApplicationCacheHost::EventID, const HashSet<DocumentLoader*>&);
    96     static void postListenerTask(ApplicationCacheHost::EventID, DocumentLoader*);
     95    static void postListenerTask(ApplicationCacheHost::EventID id, const HashSet<DocumentLoader*>& set) { postListenerTask(id, 0, 0, set); }
     96    static void postListenerTask(ApplicationCacheHost::EventID id, DocumentLoader* loader)  { postListenerTask(id, 0, 0, loader); }
     97    static void postListenerTask(ApplicationCacheHost::EventID, int progressTotal, int progressDone, const HashSet<DocumentLoader*>&);
     98    static void postListenerTask(ApplicationCacheHost::EventID, int progressTotal, int progressDone, DocumentLoader*);
     99
    97100    void scheduleReachedMaxAppCacheSizeCallback();
    98101
     
    152155    typedef HashMap<String, unsigned> EntryMap;
    153156    EntryMap m_pendingEntries;
     157   
     158    // The total number of items to be processed to update the cache group and the number that have been done.
     159    int m_progressTotal;
     160    int m_progressDone;
    154161
    155162    // Frame used for fetching resources when updating.
  • trunk/WebCore/loader/appcache/ApplicationCacheHost.cpp

    r54044 r62957  
    3838#include "FrameLoaderClient.h"
    3939#include "MainResourceLoader.h"
     40#include "ProgressEvent.h"
    4041#include "ResourceLoader.h"
    4142#include "ResourceRequest.h"
     
    229230}
    230231
    231 void ApplicationCacheHost::notifyDOMApplicationCache(EventID id)
     232void ApplicationCacheHost::notifyDOMApplicationCache(EventID id, int total, int done)
    232233{
    233234    if (m_defersEvents) {
    234         // Events are deferred until document.onload has fired.
    235         m_deferredEvents.append(id);
     235        // Event dispatching is deferred until document.onload has fired.
     236        m_deferredEvents.append(DeferredEvent(id, total, done));
    236237        return;
    237238    }
    238     if (m_domApplicationCache) {
    239         ExceptionCode ec = 0;
    240         m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec);
    241         ASSERT(!ec);   
    242     }
     239    dispatchDOMEvent(id, total, done);
    243240}
    244241
     
    247244    RefPtr<DocumentLoader> protect(documentLoader());
    248245    for (unsigned i = 0; i < m_deferredEvents.size(); ++i) {
    249         EventID id = m_deferredEvents[i];
    250         if (m_domApplicationCache) {
    251             ExceptionCode ec = 0;
    252             m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec);
    253             ASSERT(!ec);
    254         }
     246        const DeferredEvent& deferred = m_deferredEvents[i];
     247        dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.progressDone);
    255248    }
    256249    m_deferredEvents.clear();
    257250    m_defersEvents = false;
     251}
     252
     253void ApplicationCacheHost::dispatchDOMEvent(EventID id, int total, int done)
     254{
     255    if (m_domApplicationCache) {
     256        const AtomicString& eventType = DOMApplicationCache::toEventType(id);
     257        ExceptionCode ec = 0;
     258        RefPtr<Event> event;
     259        if (id == PROGRESS_EVENT)
     260            event = ProgressEvent::create(eventType, true, done, total);
     261        else
     262            event = Event::create(eventType, false, false);
     263        m_domApplicationCache->dispatchEvent(event, ec);
     264        ASSERT(!ec);
     265    }
    258266}
    259267
  • trunk/WebCore/loader/appcache/ApplicationCacheHost.h

    r62508 r62957  
    108108        bool swapCache();
    109109
    110         void setDOMApplicationCache(DOMApplicationCache* domApplicationCache);
    111         void notifyDOMApplicationCache(EventID id);
     110        void setDOMApplicationCache(DOMApplicationCache*);
     111        void notifyDOMApplicationCache(EventID, int progressTotal, int progressDone);
    112112
    113113        void stopDeferringEvents(); // Also raises the events that have been queued up.
     
    119119        DocumentLoader* documentLoader() const { return m_documentLoader; }
    120120
     121        struct DeferredEvent {
     122            EventID eventID;
     123            int progressTotal;
     124            int progressDone;
     125            DeferredEvent(EventID id, int total, int done) : eventID(id), progressTotal(total), progressDone(done) { }
     126        };
     127
    121128        DOMApplicationCache* m_domApplicationCache;
    122129        DocumentLoader* m_documentLoader;
    123130        bool m_defersEvents; // Events are deferred until after document onload.
    124         Vector<EventID> m_deferredEvents;
     131        Vector<DeferredEvent> m_deferredEvents;
     132
     133        void dispatchDOMEvent(EventID, int progressTotal, int progressDone);
    125134
    126135#if PLATFORM(CHROMIUM)
  • trunk/WebKit/chromium/ChangeLog

    r62950 r62957  
     12010-07-09  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Dumitru Daniliuc.
     4
     5        Use class ProgressEvent when raising appcache related progress events and
     6        set the 'total', 'loaded', and 'lengthComputable' attributes.
     7        Also raise the final progress event with the 'total' and 'loaded' attribute
     8        values are equal to one another to keep pace with the spec for this feature.
     9        https://bugs.webkit.org/show_bug.cgi?id=37602
     10
     11        * src/ApplicationCacheHost.cpp:
     12        (WebCore::ApplicationCacheHost::notifyDOMApplicationCache):
     13        (WebCore::ApplicationCacheHost::stopDeferringEvents):
     14        (WebCore::ApplicationCacheHost::dispatchDOMEvent):
     15        * src/ApplicationCacheHostInternal.h:
     16        (WebCore::ApplicationCacheHostInternal::notifyEventListener):
     17        (WebCore::ApplicationCacheHostInternal::notifyProgressEventListener):
     18
    1192010-07-09  David Holloway  <dhollowa@chromium.org>
    220
  • trunk/WebKit/chromium/src/ApplicationCacheHost.cpp

    r54044 r62957  
    3838#include "DOMApplicationCache.h"
    3939#include "Frame.h"
     40#include "ProgressEvent.h"
    4041#include "Settings.h"
    4142#include "WebURL.h"
     
    196197}
    197198
    198 void ApplicationCacheHost::notifyDOMApplicationCache(EventID id)
     199void ApplicationCacheHost::notifyDOMApplicationCache(EventID id, int total, int done)
    199200{
    200201    if (m_defersEvents) {
    201         m_deferredEvents.append(id);
     202        // Event dispatching is deferred until document.onload has fired.
     203        m_deferredEvents.append(DeferredEvent(id, total, done));
    202204        return;
    203205    }
    204     if (m_domApplicationCache) {
    205         ExceptionCode ec = 0;
    206         m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec);
    207         ASSERT(!ec);
    208     }
     206    dispatchDOMEvent(id, total, done);
    209207}
    210208
     
    213211    RefPtr<DocumentLoader> protect(documentLoader());
    214212    for (unsigned i = 0; i < m_deferredEvents.size(); ++i) {
    215         EventID id = m_deferredEvents[i];
    216         if (m_domApplicationCache) {
    217             ExceptionCode ec = 0;
    218             m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec);
    219             ASSERT(!ec);
    220         }
     213        const DeferredEvent& deferred = m_deferredEvents[i];
     214        dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.progressDone);
    221215    }
    222216    m_deferredEvents.clear();
    223217    m_defersEvents = false;
     218}
     219
     220void ApplicationCacheHost::dispatchDOMEvent(EventID id, int total, int done)
     221{
     222    if (m_domApplicationCache) {
     223        const AtomicString& eventType = DOMApplicationCache::toEventType(id);
     224        ExceptionCode ec = 0;
     225        RefPtr<Event> event;
     226        if (id == PROGRESS_EVENT)
     227            event = ProgressEvent::create(eventType, true, done, total);
     228        else
     229            event = Event::create(eventType, false, false);
     230        m_domApplicationCache->dispatchEvent(event, ec);
     231        ASSERT(!ec);
     232    }
    224233}
    225234
  • trunk/WebKit/chromium/src/ApplicationCacheHostInternal.h

    r61856 r62957  
    5656    virtual void notifyEventListener(WebKit::WebApplicationCacheHost::EventID eventID)
    5757    {
    58         m_innerHost->notifyDOMApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID));
     58        m_innerHost->notifyDOMApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID), 0, 0);
    5959    }
    6060
    61     virtual void notifyProgressEventListener(const WebKit::WebURL&, int num_total, int num_complete)
     61    virtual void notifyProgressEventListener(const WebKit::WebURL&, int progressTotal, int progressDone)
    6262    {
    63         // FIXME: Modify webcore's progress event handling to carry the extra info and alter the
    64         // layout tests to not fail when the more recently specified 'final' event is raised.
    65         // For now, we're eating the extra info and that last event.
    66         // See https://bugs.webkit.org/show_bug.cgi?id=37602
    67         if (num_complete == num_total)
    68             return;
    69         notifyEventListener(WebKit::WebApplicationCacheHost::ProgressEvent);
     63        m_innerHost->notifyDOMApplicationCache(ApplicationCacheHost::PROGRESS_EVENT, progressTotal, progressDone);
    7064    }
    7165
Note: See TracChangeset for help on using the changeset viewer.