Changeset 139513 in webkit


Ignore:
Timestamp:
Jan 11, 2013, 3:54:56 PM (12 years ago)
Author:
simonjam@chromium.org
Message:

[Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
https://bugs.webkit.org/show_bug.cgi?id=106409

Reviewed by Nate Chapin.

Source/WebCore:

The initiator is passed through ThreadableLoaderOptions to the CachedResourceRequest. This is
optional, so other users of ThreadableLoader will have the default initiator of 'request'. Note
that synchronous XHRs don't show up in the Resource Timing buffer yet.

Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::loadRequest):

  • loader/ThreadableLoader.h:

(ThreadableLoaderOptions):

  • loader/cache/CachedResourceRequestInitiators.cpp:

(WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):

  • loader/cache/CachedResourceRequestInitiators.h:

(CachedResourceRequestInitiators):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::createRequest):

LayoutTests:

  • http/tests/w3c/webperf/resources/all_resource_types.htm:
  • http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt:
  • http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139512 r139513  
     12013-01-11  James Simonsen  <simonjam@chromium.org>
     2
     3        [Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
     4        https://bugs.webkit.org/show_bug.cgi?id=106409
     5
     6        Reviewed by Nate Chapin.
     7
     8        * http/tests/w3c/webperf/resources/all_resource_types.htm:
     9        * http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt:
     10        * http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html:
     11
    1122013-01-11  Stephen Chenney  <schenney@chromium.org>
    213
  • trunk/LayoutTests/http/tests/w3c/webperf/resources/all_resource_types.htm

    r135450 r139513  
    1515        <script src="empty_script.js"></script>
    1616        <script>
    17             var xhr = new XMLHttpRequest;
    18             xhr.open("GET", "blank_page_yellow.htm", false);
    19             xhr.send();
     17            var async_xhr = new XMLHttpRequest;
     18            async_xhr.open("GET", "generate_resource.php?type=image&id=async_xhr", true);
     19            async_xhr.onreadystatechange = function() {
     20                if (async_xhr.readyState == 4 && async_xhr.status == 200 && parent.hasOwnProperty('on_async_xhr_done'))
     21                    parent.on_async_xhr_done();
     22            }
     23            async_xhr.send();
    2024        </script>
    2125        <style>
  • trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types-expected.txt

    r135450 r139513  
    88PASS /w3c/webperf/resources/blank_image.png is expected to have initiatorType img
    99PASS /w3c/webperf/resources/blank_page_green.htm is expected to have initiatorType iframe
    10 PASS /w3c/webperf/resources/blank_page_yellow.htm is expected to have initiatorType xmlhttprequest
    1110PASS /w3c/webperf/resources/empty_script.js is expected to have initiatorType script
    1211PASS /w3c/webperf/resources/generate_resource.php?type=css&id=embed is expected to have initiatorType embed
     
    1514PASS /w3c/webperf/resources/generate_resource.php?type=image&id=1 is expected to have initiatorType css
    1615PASS /w3c/webperf/resources/generate_resource.php?type=image&id=2 is expected to have initiatorType css
     16PASS /w3c/webperf/resources/generate_resource.php?type=image&id=async_xhr is expected to have initiatorType xmlhttprequest
    1717PASS /w3c/webperf/resources/generate_resource.php?type=image&id=body is expected to have initiatorType body
    1818PASS /w3c/webperf/resources/generate_resource.php?type=image&id=input is expected to have initiatorType input
     
    2020PASS /w3c/webperf/resources/generate_resource.php?type=image&id=object is expected to have initiatorType object
    2121PASS /w3c/webperf/resources/generate_resource.php?type=image&id=poster is expected to have initiatorType video
     22PASS /w3c/webperf/resources/generate_resource.php?type=image&id=sync_xhr is expected to have initiatorType xmlhttprequest
    2223PASS /w3c/webperf/resources/nested.css is expected to have initiatorType link
    2324
  • trunk/LayoutTests/http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html

    r135450 r139513  
    1616var ol_font_loaded = false;
    1717var ul_font_loaded = false;
     18var xhr_loaded = false;
    1819
    1920function check_finished() {
     
    2425        ol_font_loaded = check_font_loaded('ol');
    2526    }
    26     if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded) {
     27    if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded && xhr_loaded) {
    2728        perform_test();
    2829    }
     
    6465
    6566    var expected_entries = {
    66         '/w3c/webperf/resources/generate_resource.php?type=image&id=body': 'body',
    67         '/w3c/webperf/resources/nested.css': 'link',
     67        '/w3c/webperf/resources/Ahem.ttf': 'css',
    6868        '/w3c/webperf/resources/blank_image.png': 'img',
    6969        '/w3c/webperf/resources/blank_page_green.htm': 'iframe',
    7070        '/w3c/webperf/resources/empty_script.js': 'script',
    71         '/w3c/webperf/resources/blank_page_yellow.htm': 'xmlhttprequest',
     71        '/w3c/webperf/resources/generate_resource.php?type=css&id=embed': 'embed',
     72        '/w3c/webperf/resources/generate_resource.php?type=css&id=n1': 'css',
     73        '/w3c/webperf/resources/generate_resource.php?type=font&id=n1': 'css',
    7274        '/w3c/webperf/resources/generate_resource.php?type=image&id=1': 'css',
    7375        '/w3c/webperf/resources/generate_resource.php?type=image&id=2': 'css',
    74         '/w3c/webperf/resources/Ahem.ttf': 'css',
    75         '/w3c/webperf/resources/generate_resource.php?type=css&id=n1': 'css',
    76         '/w3c/webperf/resources/generate_resource.php?type=font&id=n1': 'css',
     76        '/w3c/webperf/resources/generate_resource.php?type=image&id=async_xhr': 'xmlhttprequest',
     77        '/w3c/webperf/resources/generate_resource.php?type=image&id=body': 'body',
     78        '/w3c/webperf/resources/generate_resource.php?type=image&id=input': 'input',
    7779        '/w3c/webperf/resources/generate_resource.php?type=image&id=n1': 'css',
    78         '/w3c/webperf/resources/generate_resource.php?type=css&id=embed': 'embed',
    79         '/w3c/webperf/resources/generate_resource.php?type=image&id=input': 'input',
    8080        '/w3c/webperf/resources/generate_resource.php?type=image&id=object': 'object',
    8181        '/w3c/webperf/resources/generate_resource.php?type=image&id=poster': 'video',
     82        '/w3c/webperf/resources/nested.css': 'link',
    8283    };
    8384
     
    8788
    8889window.on_test_body_created = check_finished;
     90window.on_async_xhr_done = function() {
     91    xhr_loaded = true;
     92    check_finished();
     93}
    8994</script>
    9095</head>
  • trunk/Source/WebCore/ChangeLog

    r139509 r139513  
     12013-01-11  James Simonsen  <simonjam@chromium.org>
     2
     3        [Resource Timing] XMLHttpRequests should have initiator type 'xmlhttprequest'
     4        https://bugs.webkit.org/show_bug.cgi?id=106409
     5
     6        Reviewed by Nate Chapin.
     7
     8        The initiator is passed through ThreadableLoaderOptions to the CachedResourceRequest. This is
     9        optional, so other users of ThreadableLoader will have the default initiator of 'request'. Note
     10        that synchronous XHRs don't show up in the Resource Timing buffer yet.
     11
     12        Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_initiator_types.html
     13
     14        * loader/DocumentThreadableLoader.cpp:
     15        (WebCore::DocumentThreadableLoader::loadRequest):
     16        * loader/ThreadableLoader.h:
     17        (ThreadableLoaderOptions):
     18        * loader/cache/CachedResourceRequestInitiators.cpp:
     19        (WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
     20        * loader/cache/CachedResourceRequestInitiators.h:
     21        (CachedResourceRequestInitiators):
     22        * xml/XMLHttpRequest.cpp:
     23        (WebCore::XMLHttpRequest::createRequest):
     24
    1252013-01-11  James Simonsen  <simonjam@chromium.org>
    226
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r138285 r139513  
    376376
    377377        CachedResourceRequest newRequest(request, options);
     378#if ENABLE(RESOURCE_TIMING)
     379        newRequest.setInitiator(m_options.initiator);
     380#endif
    378381#if ENABLE(INSPECTOR)
    379382        if (m_actualRequest) {
  • trunk/Source/WebCore/loader/ThreadableLoader.h

    r95901 r139513  
    6565        CrossOriginRequestPolicy crossOriginRequestPolicy;
    6666        RefPtr<SecurityOrigin> securityOrigin;
     67#if ENABLE(RESOURCE_TIMING)
     68        AtomicString initiator;
     69#endif
    6770    };
    6871
  • trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp

    r134930 r139513  
    3232    : css("css", AtomicString::ConstructFromLiteral)
    3333    , icon("icon", AtomicString::ConstructFromLiteral)
     34    , xmlhttprequest("xmlhttprequest", AtomicString::ConstructFromLiteral)
    3435{
    3536}
  • trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h

    r134930 r139513  
    3535    const AtomicString css;
    3636    const AtomicString icon;
     37    const AtomicString xmlhttprequest;
    3738    WTF_MAKE_NONCOPYABLE(CachedResourceRequestInitiators); WTF_MAKE_FAST_ALLOCATED;
    3839private:
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r138817 r139513  
    6565#include <wtf/text/CString.h>
    6666
     67#if ENABLE(RESOURCE_TIMING)
     68#include "CachedResourceRequestInitiators.h"
     69#endif
     70
    6771#if USE(JSC)
    6872#include "JSDOMBinding.h"
     
    787791    options.crossOriginRequestPolicy = UseAccessControl;
    788792    options.securityOrigin = securityOrigin();
     793#if ENABLE(RESOURCE_TIMING)
     794    options.initiator = cachedResourceRequestInitiators().xmlhttprequest;
     795#endif
    789796
    790797#if ENABLE(XHR_TIMEOUT)
Note: See TracChangeset for help on using the changeset viewer.