Changeset 136329 in webkit


Ignore:
Timestamp:
Dec 2, 2012 3:23:04 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: [Resource Timing] implementation of cross origin resouce timing restrictions.
https://bugs.webkit.org/show_bug.cgi?id=84886.

Patch by Pan Deng <pan.deng@intel.com> on 2012-12-02
Reviewed by Tony Gentilcore.

This patch implemented resource timing behaviors of cross origin. By default, detailed timing info is hided in cross origin resource timing, only startTime, duration, fetchStart and responseEnd can be observed. Exceptions are, server side allow its origin can be timing by another through a header with "timing-allow-origin" field.

Tests: http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request.html

http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request.html

  • page/Performance.cpp:

(WebCore::passesTimingAllowCheck):
(WebCore):
(WebCore::Performance::addResourceTiming):

  • page/Performance.h:

(WebCore):
(Performance):

  • page/PerformanceResourceTiming.cpp:

(WebCore):

  • page/PerformanceResourceTiming.h:

(WebCore::PerformanceResourceTiming::create):
(PerformanceResourceTiming):

LayoutTests: [Resource Timing]Test cases of cross origin resource timing.
https://bugs.webkit.org/show_bug.cgi?id=84886.

Patch by Pan Deng <pan.deng@intel.com> on 2012-12-02
Reviewed by Tony Gentilcore.

Test cases in this patch validate resource timing behavior when cross origin request with/without "allow-timing-origin" response header.

  • http/tests/w3c/webperf/resources/blank_page_green_with_allow_timing.php: Added.
  • http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request-expected.txt: Added.
  • http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request.html: Added.
  • http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request-expected.txt: Added.
  • http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request.html: Added.
Location:
trunk
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136326 r136329  
     12012-12-02  Pan Deng  <pan.deng@intel.com>
     2
     3        [Resource Timing]Test cases of cross origin resource timing.
     4        https://bugs.webkit.org/show_bug.cgi?id=84886.
     5
     6        Reviewed by Tony Gentilcore.
     7
     8        Test cases in this patch validate resource timing behavior when cross origin request with/without "allow-timing-origin" response header.
     9
     10        * http/tests/w3c/webperf/resources/blank_page_green_with_allow_timing.php: Added.
     11        * http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request-expected.txt: Added.
     12        * http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request.html: Added.
     13        * http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request-expected.txt: Added.
     14        * http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request.html: Added.
     15
    1162012-12-02  Justin Novosad  <junov@google.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r136328 r136329  
     12012-12-02  Pan Deng  <pan.deng@intel.com>
     2
     3        [Resource Timing] implementation of cross origin resouce timing restrictions.
     4        https://bugs.webkit.org/show_bug.cgi?id=84886.
     5
     6        Reviewed by Tony Gentilcore.
     7
     8        This patch implemented resource timing behaviors of cross origin. By default, detailed timing info is hided in cross origin resource timing, only startTime, duration, fetchStart and responseEnd can be observed. Exceptions are, server side allow its origin can be timing by another through a header with "timing-allow-origin" field.
     9
     10        Tests: http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_resource_request.html
     11               http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_timing_allow_cross_origin_resource_request.html
     12
     13        * page/Performance.cpp:
     14        (WebCore::passesTimingAllowCheck):
     15        (WebCore):
     16        (WebCore::Performance::addResourceTiming):
     17        * page/Performance.h:
     18        (WebCore):
     19        (Performance):
     20        * page/PerformanceResourceTiming.cpp:
     21        (WebCore):
     22        * page/PerformanceResourceTiming.h:
     23        (WebCore::PerformanceResourceTiming::create):
     24        (PerformanceResourceTiming):
     25
    1262012-12-02  Elliott Sprehn  <esprehn@gmail.com>
    227
  • trunk/Source/WebCore/page/PerformanceResourceTiming.cpp

    r135458 r136329  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
     3 * Copyright (C) 2012 Intel Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    4546namespace WebCore {
    4647
    47 double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
     48static double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
    4849{
    4950    ASSERT(seconds >= 0.0);
    5051    return document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(seconds) * 1000.0;
     52}
     53
     54static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument)
     55{
     56    AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicString("timing-allow-origin"));
     57
     58    const String& timingAllowOriginString = response.httpHeaderField(timingAllowOrigin);
     59    if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOriginString, "null"))
     60        return false;
     61
     62    if (timingAllowOriginString == "*")
     63        return true;
     64
     65    const String& securityOrigin = requestingDocument->securityOrigin()->toString();
     66    Vector<String> timingAllowOrigins;
     67    timingAllowOriginString.split(" ", timingAllowOrigins);
     68    for (size_t i = 0; i < timingAllowOrigins.size(); ++i)
     69        if (timingAllowOrigins[i] == securityOrigin)
     70            return true;
     71
     72    return false;
    5173}
    5274
     
    5678    , m_timing(response.resourceLoadTiming())
    5779    , m_finishTime(finishTime)
     80    , m_shouldReportDetails(passesTimingAllowCheck(response, requestingDocument))
    5881    , m_requestingDocument(requestingDocument)
    5982{
     
    7497{
    7598    // FIXME: Need to track and report redirects for resources.
     99    if (!m_shouldReportDetails)
     100        return 0.0;
    76101    return 0;
    77102}
     
    79104double PerformanceResourceTiming::redirectEnd() const
    80105{
     106    if (!m_shouldReportDetails)
     107        return 0.0;
    81108    return 0;
    82109}
     
    90117double PerformanceResourceTiming::domainLookupStart() const
    91118{
     119    if (!m_shouldReportDetails)
     120        return 0.0;
     121
    92122    if (!m_timing || m_timing->dnsStart < 0)
    93123        return fetchStart();
     
    98128double PerformanceResourceTiming::domainLookupEnd() const
    99129{
     130    if (!m_shouldReportDetails)
     131        return 0.0;
     132
    100133    if (!m_timing || m_timing->dnsEnd < 0)
    101134        return domainLookupStart();
     
    106139double PerformanceResourceTiming::connectStart() const
    107140{
     141    if (!m_shouldReportDetails)
     142        return 0.0;
     143
    108144    if (!m_timing || m_timing->connectStart < 0) // Connection was reused.
    109145        return domainLookupEnd();
     
    119155double PerformanceResourceTiming::connectEnd() const
    120156{
     157    if (!m_shouldReportDetails)
     158        return 0.0;
     159
    121160    if (!m_timing || m_timing->connectEnd < 0) // Connection was reused.
    122161        return connectStart();
     
    127166double PerformanceResourceTiming::secureConnectionStart() const
    128167{
     168    if (!m_shouldReportDetails)
     169        return 0.0;
     170
    129171    if (!m_timing || m_timing->sslStart < 0) // Secure connection not negotiated.
    130172        return 0.0;
     
    135177double PerformanceResourceTiming::requestStart() const
    136178{
     179    if (!m_shouldReportDetails)
     180        return 0.0;
     181
    137182    if (!m_timing)
    138183        return connectEnd();
     184
    139185    return resourceTimeToDocumentMilliseconds(m_timing->sendStart);
    140186}
     
    142188double PerformanceResourceTiming::responseStart() const
    143189{
     190    if (!m_shouldReportDetails)
     191        return 0.0;
     192
    144193    if (!m_timing)
    145194        return requestStart();
     
    150199double PerformanceResourceTiming::responseEnd() const
    151200{
     201    if (!m_shouldReportDetails)
     202        return 0.0;
     203
    152204    if (!m_timing)
    153205        return responseStart();
     206
    154207    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_finishTime);
    155208}
  • trunk/Source/WebCore/page/PerformanceResourceTiming.h

    r135458 r136329  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
     3 * Copyright (C) 2012 Intel Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    7980    RefPtr<ResourceLoadTiming> m_timing;
    8081    double m_finishTime;
     82    bool m_shouldReportDetails;
    8183    RefPtr<Document> m_requestingDocument;
    8284};
Note: See TracChangeset for help on using the changeset viewer.