Changeset 90340 in webkit


Ignore:
Timestamp:
Jul 3, 2011 8:58:38 AM (13 years ago)
Author:
vsevik@chromium.org
Message:

2011-07-03 Vsevolod Vlasov <vsevik@chromium.org>

Reviewed by Alexey Proskuryakov.

Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
https://bugs.webkit.org/show_bug.cgi?id=63712

  • http/tests/inspector/network-preflight-options-expected.txt:
  • http/tests/inspector/network-preflight-options.html:

2011-07-03 Vsevolod Vlasov <vsevik@chromium.org>

Reviewed by Alexey Proskuryakov.

Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
https://bugs.webkit.org/show_bug.cgi?id=63712

Added InspectorInstrumentation calls to preflight OPTIONS requests callbacks in DocumentThreadableLoader.

  • loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): (WebCore::DocumentThreadableLoader::didReceiveResponse): (WebCore::DocumentThreadableLoader::didReceiveData): (WebCore::DocumentThreadableLoader::didFinishLoading): (WebCore::DocumentThreadableLoader::didFail): (WebCore::DocumentThreadableLoader::loadRequest):
  • loader/DocumentThreadableLoader.h:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90339 r90340  
     12011-07-03  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
     6        https://bugs.webkit.org/show_bug.cgi?id=63712
     7
     8        * http/tests/inspector/network-preflight-options-expected.txt:
     9        * http/tests/inspector/network-preflight-options.html:
     10
    1112011-07-03  Robert Hogan  <robert@webkit.org>
    212
  • trunk/LayoutTests/http/tests/inspector/network-preflight-options-expected.txt

    r77379 r90340  
     1CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
     2CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
    13CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
    24CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
     
    79OPTIONS http://localhost:8000/inspector/resources/cors-target.php
    810POST http://localhost:8000/inspector/resources/cors-target.php
     11POST http://localhost:8000/inspector/resources/cors-target.php?deny=yes
     12OPTIONS http://localhost:8000/inspector/resources/cors-target.php?deny=yes
     13OPTIONS http://localhost:8000/inspector/resources/cors-target.php?async=yes
     14POST http://localhost:8000/inspector/resources/cors-target.php?async=yes
    915
  • trunk/LayoutTests/http/tests/inspector/network-preflight-options.html

    r82713 r90340  
    44<script type="text/javascript">
    55
    6 function sendXHR(url, forcePreflight)
     6function sendXHR(url, forcePreflight, async)
    77{
    88    var xhr = new XMLHttpRequest();
    9     xhr.open("POST", url, false);
     9    xhr.open("POST", url, async);
    1010    xhr.setRequestHeader("Content-Type", forcePreflight ? "application/xml" : "text/plain");
    1111    try {
     
    1818{
    1919    var targetURL = "http://localhost:8000/inspector/resources/cors-target.php";
     20
    2021    // Failed POSTs with no preflight check should result in a POST request being logged
    21     sendXHR(targetURL + "?deny=yes", false);
     22    sendXHR(targetURL + "?deny=yes", false, false);
    2223    // Failed POSTs with preflight check should result in an OPTIONS request being logged
    23     sendXHR(targetURL + "?deny=yes", true);
     24    sendXHR(targetURL + "?deny=yes", true, false);
    2425    // Successful POSTs with preflight check should result in an OPTIONS request followed by POST request being logged
    25     // Generate request name based on timestamp to defeat caching (this is only relevant for repeated invocations of the test in signle instance of DRT)
    26     sendXHR(targetURL + "?date=" + Date.now(), true);
     26    // Generate request name based on timestamp to defeat OPTIONS request caching (this is only relevant for repeated invocations of the test in signle instance of DRT)
     27    sendXHR(targetURL + "?date=" + Date.now(), true, false);
     28
     29    // And now send the same requests asynchronously
     30    // Add redundant async parameter to ensure this request differs from the one above.
     31    sendXHR(targetURL + "?deny=yes", false, true);
     32    sendXHR(targetURL + "?deny=yes", true, true);
     33    sendXHR(targetURL + "?async=yes&date=" + Date.now(), true, true);
    2734}
    2835
    2936var test = function()
    3037{
     38    var postRequestsCount = 0;
    3139    function onResource(event)
    3240    {
    3341        var resource = event.data;
    3442        InspectorTest.addResult(resource.requestMethod + " " +  resource.url.replace(/[&?]date=\d+/, ""));
    35         if (resource.requestMethod === "POST" && !/\?deny=yes/.test(resource.url))
     43        if (resource.requestMethod === "POST" && ++postRequestsCount == 4)
    3644            InspectorTest.completeTest();
    3745    }
  • trunk/Source/WebCore/ChangeLog

    r90338 r90340  
     12011-07-03  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
     6        https://bugs.webkit.org/show_bug.cgi?id=63712
     7
     8        Added InspectorInstrumentation calls to preflight OPTIONS requests callbacks in DocumentThreadableLoader.
     9
     10        * loader/DocumentThreadableLoader.cpp:
     11        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
     12        (WebCore::DocumentThreadableLoader::didReceiveResponse):
     13        (WebCore::DocumentThreadableLoader::didReceiveData):
     14        (WebCore::DocumentThreadableLoader::didFinishLoading):
     15        (WebCore::DocumentThreadableLoader::didFail):
     16        (WebCore::DocumentThreadableLoader::loadRequest):
     17        * loader/DocumentThreadableLoader.h:
     18
    1192011-06-23  Robert Hogan  <robert@webkit.org>
    220
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r89086 r90340  
    4747#include <wtf/UnusedParam.h>
    4848
     49#if ENABLE(INSPECTOR)
     50#include "InspectorInstrumentation.h"
     51#include "ProgressTracker.h"
     52#endif
     53
    4954namespace WebCore {
    5055
     
    7075    , m_sameOriginRequest(securityOrigin()->canRequest(request.url()))
    7176    , m_async(blockingBehavior == LoadAsynchronously)
     77#if ENABLE(INSPECTOR)
     78    , m_preflightRequestIdentifier(0)
     79#endif
    7280{
    7381    ASSERT(document);
     
    178186{
    179187    ASSERT(m_client);
     188
     189#if ENABLE(INSPECTOR)
     190    if (m_preflightRequestIdentifier) {
     191        DocumentLoader* loader = m_document->frame()->loader()->documentLoader();
     192        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document->frame(), m_preflightRequestIdentifier, response);
     193        InspectorInstrumentation::didReceiveResourceResponse(cookie, m_preflightRequestIdentifier, loader, response);
     194    }
     195#endif
    180196
    181197    String accessControlErrorDescription;
     
    212228    ASSERT_UNUSED(loader, loader == m_loader);
    213229
     230#if ENABLE(INSPECTOR)
     231    if (m_preflightRequestIdentifier)
     232        InspectorInstrumentation::didReceiveContentLength(m_document->frame(), m_preflightRequestIdentifier, 0, dataLength);
     233#endif
     234
    214235    // Preflight data should be invisible to clients.
    215236    if (m_actualRequest)
     
    240261void DocumentThreadableLoader::didFinishLoading(unsigned long identifier, double finishTime)
    241262{
     263#if ENABLE(INSPECTOR)
     264    if (m_preflightRequestIdentifier)
     265        InspectorInstrumentation::didFinishLoading(m_document->frame(), m_document->frame()->loader()->documentLoader(), m_preflightRequestIdentifier, finishTime);
     266#endif
     267
    242268    if (m_actualRequest) {
    243269        ASSERT(!m_sameOriginRequest);
     
    253279    // m_loader may be null if we arrive here via SubresourceLoader::create in the ctor
    254280    ASSERT_UNUSED(loader, loader == m_loader || !m_loader);
     281
     282#if ENABLE(INSPECTOR)
     283    if (m_preflightRequestIdentifier)
     284        InspectorInstrumentation::didFailLoading(m_document->frame(), m_document->frame()->loader()->documentLoader(), m_preflightRequestIdentifier, error);
     285#endif
    255286
    256287    m_client->didFail(error);
     
    324355        bool shouldBufferData = m_options.shouldBufferData || m_actualRequest;
    325356
     357#if ENABLE(INSPECTOR)
     358        if (m_actualRequest) {
     359            ResourceRequest newRequest(request);
     360            // Because willSendRequest only gets called during redirects, we initialize the identifier and the first willSendRequest here.
     361            m_preflightRequestIdentifier = m_document->frame()->page()->progress()->createUniqueIdentifier();
     362            ResourceResponse redirectResponse = ResourceResponse();
     363            InspectorInstrumentation::willSendRequest(m_document->frame(), m_preflightRequestIdentifier, m_document->frame()->loader()->documentLoader(), newRequest, redirectResponse);
     364        }
     365#endif
     366
    326367        // Clear the loader so that any callbacks from SubresourceLoader::create will not have the old loader.
    327368        m_loader = 0;
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.h

    r89086 r90340  
    106106        bool m_async;
    107107        OwnPtr<ResourceRequest> m_actualRequest;  // non-null during Access Control preflight checks
     108
     109#if ENABLE(INSPECTOR)
     110        unsigned long m_preflightRequestIdentifier;
     111#endif
    108112    };
    109113
Note: See TracChangeset for help on using the changeset viewer.