Changeset 125681 in webkit


Ignore:
Timestamp:
Aug 15, 2012 9:50:13 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Source/WebCore: Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
https://bugs.webkit.org/show_bug.cgi?id=91630

Patch by Pavel Chadnov <chadnov@google.com> on 2012-08-15
Reviewed by Vsevolod Vlasov.

CachedResource object for XHR response is now taken from ResourceLoader (if it's possible).

Test: http/tests/inspector/network/network-xhr-async-double.html

  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
(WebCore::InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didReceiveResourceResponse):

  • inspector/InspectorResourceAgent.cpp:

(WebCore::InspectorResourceAgent::willSendRequest):
(WebCore::InspectorResourceAgent::didReceiveResponse):

  • inspector/InspectorResourceAgent.h:

(WebCore):
(InspectorResourceAgent):

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::didReceiveResponse):

  • loader/ResourceLoadNotifier.cpp:

(WebCore::ResourceLoadNotifier::didReceiveResponse):
(WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):

  • loader/ResourceLoadNotifier.h:

(ResourceLoadNotifier):

  • loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::isSubresourceLoader):
(WebCore):

  • loader/ResourceLoader.h:

(ResourceLoader):

  • loader/SubresourceLoader.cpp:

(WebCore::SubresourceLoader::cachedResource):
(WebCore):
(WebCore::SubresourceLoader::isSubresourceLoader):

  • loader/SubresourceLoader.h:

(SubresourceLoader):

  • loader/appcache/ApplicationCacheGroup.cpp:

(WebCore::ApplicationCacheGroup::didReceiveResponse):

LayoutTests: Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
https://bugs.webkit.org/show_bug.cgi?id=91630

Patch by Pavel Chadnov <chadnov@google.com> on 2012-08-15
Reviewed by Vsevolod Vlasov.

New test for two async XHRs sent synchronously.

  • http/tests/inspector/network-test.js:

(doXHR):
(doXHRWithPayload.xhr.onreadystatechange):
(doXHRWithPayload):

  • http/tests/inspector/network/network-xhr-async-double-expected.txt: Added.
  • http/tests/inspector/network/network-xhr-async-double.html: Added.
  • http/tests/inspector/network/resources/echo-payload.php: Added.
  • platform/chromium/http/tests/inspector/console-xhr-logging-async-expected.txt:
  • platform/chromium/http/tests/inspector/console-xhr-logging-expected.txt:
Location:
trunk
Files:
3 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125670 r125681  
     12012-08-15  Pavel Chadnov  <chadnov@google.com>
     2
     3        Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
     4        https://bugs.webkit.org/show_bug.cgi?id=91630
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        New test for two async XHRs sent synchronously.
     9
     10        * http/tests/inspector/network-test.js:
     11        (doXHR):
     12        (doXHRWithPayload.xhr.onreadystatechange):
     13        (doXHRWithPayload):
     14        * http/tests/inspector/network/network-xhr-async-double-expected.txt: Added.
     15        * http/tests/inspector/network/network-xhr-async-double.html: Added.
     16        * http/tests/inspector/network/resources/echo-payload.php: Added.
     17        * platform/chromium/http/tests/inspector/console-xhr-logging-async-expected.txt:
     18        * platform/chromium/http/tests/inspector/console-xhr-logging-expected.txt:
     19
    1202012-08-15  Christophe Dumez  <christophe.dumez@intel.com>
    221
  • trunk/LayoutTests/http/tests/inspector/network-test.js

    r113863 r125681  
    2828function doXHR(method, url, async, callback)
    2929{
     30    doXHRWithPayload(method, url, async, null, callback);
     31}
     32
     33function doXHRWithPayload(method, url, async, payload, callback)
     34{
    3035    var xhr = new XMLHttpRequest();
    3136    xhr.onreadystatechange = function()
     
    3540                callback();
    3641        }
    37     };
     42    }
    3843    xhr.open(method, url, async);
    39     xhr.send(null);
     44    xhr.send(payload);
    4045}
    4146
  • trunk/LayoutTests/platform/chromium/http/tests/inspector/console-xhr-logging-async-expected.txt

    r121871 r125681  
    44
    55Bug 79229
    6 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html". network-test.js:39
     6XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html". network-test.js:44
    77Done. console-xhr-logging-async.html:14
    88
  • trunk/LayoutTests/platform/chromium/http/tests/inspector/console-xhr-logging-expected.txt

    r110693 r125681  
    1212
    1313sending a GET request to resources/xhr-exists.html console-xhr-logging.html:10
    14 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html". network-test.js:39
     14XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html". network-test.js:44
    1515sending a GET request to resources/xhr-does-not-exist.html console-xhr-logging.html:10
    16 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found) network-test.js:39
    17 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html". network-test.js:39
     16GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found) network-test.js:44
     17XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html". network-test.js:44
    1818sending a POST request to resources/post-target.cgi console-xhr-logging.html:10
    19 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/post-target.cgi". network-test.js:39
     19XHR finished loading: "http://127.0.0.1:8000/inspector/resources/post-target.cgi". network-test.js:44
    2020sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html console-xhr-logging.html:10
    2121XMLHttpRequest cannot load http://localhost:8000/inspector/resources/xhr-exists.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
    2222sending a GET request to resources/xhr-exists.html console-xhr-logging.html:10
    2323sending a GET request to resources/xhr-does-not-exist.html console-xhr-logging.html:10
    24 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found) network-test.js:39
     24GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found) network-test.js:44
    2525sending a POST request to resources/post-target.cgi console-xhr-logging.html:10
    2626sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html console-xhr-logging.html:10
  • trunk/Source/WebCore/ChangeLog

    r125677 r125681  
     12012-08-15  Pavel Chadnov  <chadnov@google.com>
     2
     3        Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
     4        https://bugs.webkit.org/show_bug.cgi?id=91630
     5       
     6        Reviewed by Vsevolod Vlasov.
     7
     8        CachedResource object for XHR response is now taken from ResourceLoader (if it's possible).
     9
     10        Test: http/tests/inspector/network/network-xhr-async-double.html
     11
     12        * inspector/InspectorInstrumentation.cpp:
     13        (WebCore):
     14        (WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
     15        (WebCore::InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl):
     16        * inspector/InspectorInstrumentation.h:
     17        (InspectorInstrumentation):
     18        (WebCore::InspectorInstrumentation::didReceiveResourceResponse):
     19        * inspector/InspectorResourceAgent.cpp:
     20        (WebCore::InspectorResourceAgent::willSendRequest):
     21        (WebCore::InspectorResourceAgent::didReceiveResponse):
     22        * inspector/InspectorResourceAgent.h:
     23        (WebCore):
     24        (InspectorResourceAgent):
     25        * loader/DocumentThreadableLoader.cpp:
     26        (WebCore::DocumentThreadableLoader::didReceiveResponse):
     27        * loader/ResourceLoadNotifier.cpp:
     28        (WebCore::ResourceLoadNotifier::didReceiveResponse):
     29        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
     30        * loader/ResourceLoadNotifier.h:
     31        (ResourceLoadNotifier):
     32        * loader/ResourceLoader.cpp:
     33        (WebCore::ResourceLoader::isSubresourceLoader):
     34        (WebCore):
     35        * loader/ResourceLoader.h:
     36        (ResourceLoader):
     37        * loader/SubresourceLoader.cpp:
     38        (WebCore::SubresourceLoader::cachedResource):
     39        (WebCore):
     40        (WebCore::SubresourceLoader::isSubresourceLoader):
     41        * loader/SubresourceLoader.h:
     42        (SubresourceLoader):
     43        * loader/appcache/ApplicationCacheGroup.cpp:
     44        (WebCore::ApplicationCacheGroup::didReceiveResponse):
     45
    1462012-08-15  Taiju Tsuiki  <tzik@chromium.org>
    247
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r125277 r125681  
    675675}
    676676
    677 void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
     677void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
    678678{
    679679    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
     
    685685        return;
    686686    if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
    687         resourceAgent->didReceiveResponse(identifier, loader, response);
     687        resourceAgent->didReceiveResponse(identifier, loader, response, resourceLoader);
    688688    if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
    689689        consoleAgent->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
     
    693693{
    694694    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(frame, identifier, r);
    695     InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r);
     695    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r, 0);
    696696}
    697697
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r125277 r125681  
    173173    static void didReceiveResourceData(const InspectorInstrumentationCookie&);
    174174    static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&);
    175     static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
     175    static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
    176176    static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
    177177    static void continueWithPolicyDownload(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     
    352352    static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&);
    353353    static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InstrumentingAgents*, unsigned long identifier, const ResourceResponse&, Frame*);
    354     static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
     354    static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
    355355    static void didReceiveResourceResponseButCanceledImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
    356356    static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     
    10831083}
    10841084
    1085 inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
     1085inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
    10861086{
    10871087#if ENABLE(INSPECTOR)
    10881088    // Call this unconditionally so that we're able to log to console with no front-end attached.
    1089     didReceiveResourceResponseImpl(cookie, identifier, loader, response);
     1089    didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
    10901090#endif
    10911091}
  • trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp

    r124032 r125681  
    5555#include "ProgressTracker.h"
    5656#include "ResourceError.h"
     57#include "ResourceLoader.h"
    5758#include "ResourceRequest.h"
    5859#include "ResourceResponse.h"
     
    6061#include "ScriptCallStackFactory.h"
    6162#include "ScriptableDocumentParser.h"
     63#include "SubresourceLoader.h"
    6264#include "WebSocketFrame.h"
    6365#include "WebSocketHandshakeRequest.h"
     
    222224
    223225    if (m_state->getBoolean(ResourceAgentState::cacheDisabled)) {
     226        request.setHTTPHeaderField("Pragma", "no-cache");
    224227        request.setCachePolicy(ReloadIgnoringCacheData);
    225         request.setHTTPHeaderField("Pragma", "no-cache");
    226228        request.setHTTPHeaderField("Cache-Control", "no-cache");
    227229    }
     
    236238}
    237239
    238 void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
     240void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
    239241{
    240242    String requestId = IdentifiersFactory::requestId(identifier);
     
    243245    long cachedResourceSize = 0;
    244246
     247    bool isNotModified = response.httpStatusCode() == 304;
    245248    if (loader) {
    246         CachedResource* cachedResource = InspectorPageAgent::cachedResource(loader->frame(), response.url());
     249        CachedResource* cachedResource = 0;
     250        if (resourceLoader && resourceLoader->isSubresourceLoader() && !isNotModified)
     251            cachedResource = static_cast<SubresourceLoader*>(resourceLoader)->cachedResource();
     252        if (!cachedResource)
     253            cachedResource = InspectorPageAgent::cachedResource(loader->frame(), response.url());
    247254        if (cachedResource) {
    248255            type = InspectorPageAgent::cachedResourceType(*cachedResource);
     
    269276    // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
    270277    // as there will be no calls to didReceiveData from the network stack.
    271     if (cachedResourceSize && response.httpStatusCode() == 304)
     278    if (cachedResourceSize && isNotModified)
    272279        didReceiveData(identifier, 0, cachedResourceSize, 0);
    273280}
  • trunk/Source/WebCore/inspector/InspectorResourceAgent.h

    r125249 r125681  
    6363class Page;
    6464class ResourceError;
     65class ResourceLoader;
    6566class ResourceRequest;
    6667class ResourceResponse;
     
    9293    void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
    9394    void markResourceAsCached(unsigned long identifier);
    94     void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&);
     95    void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&, ResourceLoader*);
    9596    void didReceiveData(unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
    9697    void didFinishLoading(unsigned long identifier, DocumentLoader*, double finishTime);
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r121803 r125681  
    250250        DocumentLoader* loader = m_document->frame()->loader()->documentLoader();
    251251        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document->frame(), m_preflightRequestIdentifier, response);
    252         InspectorInstrumentation::didReceiveResourceResponse(cookie, m_preflightRequestIdentifier, loader, response);
     252        InspectorInstrumentation::didReceiveResourceResponse(cookie, m_preflightRequestIdentifier, loader, response, 0);
    253253    }
    254254#endif
  • trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp

    r111361 r125681  
    7272        page->progress()->incrementProgress(loader->identifier(), r);
    7373
    74     dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r);
     74    dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r, loader);
    7575}
    7676
     
    124124}
    125125
    126 void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
     126void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader)
    127127{
    128128    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, identifier, r);
    129129    m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r);
    130     InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r);
     130    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r, resourceLoader);
    131131}
    132132
  • trunk/Source/WebCore/loader/ResourceLoadNotifier.h

    r111361 r125681  
    6060    void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
    6161    void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
    62     void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
     62    void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, ResourceLoader* = 0);
    6363    void dispatchDidReceiveData(DocumentLoader*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
    6464    void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier, double finishTime);
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r124884 r125681  
    215215}
    216216
     217bool ResourceLoader::isSubresourceLoader()
     218{
     219    return false;
     220}
     221
    217222void ResourceLoader::willSendRequest(ResourceRequest& request, const ResourceResponse& redirectResponse)
    218223{
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r122920 r125681  
    7676        virtual PassRefPtr<SharedBuffer> resourceData();
    7777        void clearResourceData();
     78        virtual bool isSubresourceLoader();
    7879       
    7980        virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r125265 r125681  
    123123}
    124124
     125CachedResource* SubresourceLoader::cachedResource()
     126{
     127    return m_resource;
     128}
     129
    125130void SubresourceLoader::cancelIfNotFinishing()
    126131{
     
    148153    m_state = Initialized;
    149154    m_documentLoader->addSubresourceLoader(this);
     155    return true;
     156}
     157
     158bool SubresourceLoader::isSubresourceLoader()
     159{
    150160    return true;
    151161}
  • trunk/Source/WebCore/loader/SubresourceLoader.h

    r125265 r125681  
    4747
    4848    void cancelIfNotFinishing();
     49    virtual bool isSubresourceLoader();
     50    CachedResource* cachedResource();
    4951
    5052    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r125615 r125681  
    525525    DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader()->documentLoader();
    526526    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, m_currentResourceIdentifier, response);
    527     InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResourceIdentifier, loader, response);
     527    InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResourceIdentifier, loader, response, 0);
    528528#endif
    529529
Note: See TracChangeset for help on using the changeset viewer.