Changeset 133325 in webkit


Ignore:
Timestamp:
Nov 2, 2012, 11:54:46 AM (12 years ago)
Author:
mkwst@chromium.org
Message:

Measure the usage of the various CSP headers.
https://bugs.webkit.org/show_bug.cgi?id=100974

Reviewed by Adam Barth.

Currently, we're collecting metrics regarding usage of the
'X-WebKit-CSP' and 'X-WebKit-CSP-Report-Only' HTTP headers. We've
recently added support for the canonical 'Content-Security-Policy'
and 'Content-Security-Policy-Report-Only' headers. This patch adds
those headers explicitly into the metrics, giving insight into uptake
of the unprefixed header, and into usage of pure reporting vs.
enforcement.

No visible functionality should change; all Content Security Policy
tests should continue to pass.

  • page/ContentSecurityPolicy.cpp:

(WebCore::ContentSecurityPolicy::didReceiveHeader):

Convert the CSP header type into a FeatureObserver::Feature, and
observe it.

  • page/FeatureObserver.h:

Add three new values to the enum to cover the new header types.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r133324 r133325  
     12012-11-02  Mike West  <mkwst@chromium.org>
     2
     3        Measure the usage of the various CSP headers.
     4        https://bugs.webkit.org/show_bug.cgi?id=100974
     5
     6        Reviewed by Adam Barth.
     7
     8        Currently, we're collecting metrics regarding usage of the
     9        'X-WebKit-CSP' and 'X-WebKit-CSP-Report-Only' HTTP headers. We've
     10        recently added support for the canonical 'Content-Security-Policy'
     11        and 'Content-Security-Policy-Report-Only' headers. This patch adds
     12        those headers explicitly into the metrics, giving insight into uptake
     13        of the unprefixed header, and into usage of pure reporting vs.
     14        enforcement.
     15
     16        No visible functionality should change; all Content Security Policy
     17        tests should continue to pass.
     18
     19        * page/ContentSecurityPolicy.cpp:
     20        (WebCore::ContentSecurityPolicy::didReceiveHeader):
     21            Convert the CSP header type into a FeatureObserver::Feature, and
     22            observe it.
     23        * page/FeatureObserver.h:
     24            Add three new values to the enum to cover the new header types.
     25
    1262012-11-02  Ojan Vafai  <ojan@chromium.org>
    227
  • trunk/Source/WebCore/page/ContentSecurityPolicy.cpp

    r133323 r133325  
    141141#endif
    142142    );
     143}
     144
     145FeatureObserver::Feature getFeatureObserverType(ContentSecurityPolicy::HeaderType type)
     146{
     147    switch (type) {
     148    case ContentSecurityPolicy::EnforceAllDirectives:
     149        return FeatureObserver::PrefixedContentSecurityPolicy;
     150    case ContentSecurityPolicy::EnforceStableDirectives:
     151        return FeatureObserver::ContentSecurityPolicy;
     152    case ContentSecurityPolicy::ReportAllDirectives:
     153        return FeatureObserver::PrefixedContentSecurityPolicyReportOnly;
     154    case ContentSecurityPolicy::ReportStableDirectives:
     155        return FeatureObserver::ContentSecurityPolicyReportOnly;
     156    }
     157    ASSERT_NOT_REACHED();
     158    return FeatureObserver::NumberOfFeatures;
    143159}
    144160
     
    13301346        Document* document = static_cast<Document*>(m_scriptExecutionContext);
    13311347        if (document->domWindow())
    1332             FeatureObserver::observe(document->domWindow(), FeatureObserver::PrefixedContentSecurityPolicy);
     1348            FeatureObserver::observe(document->domWindow(), getFeatureObserverType(type));
    13331349    }
    13341350
  • trunk/Source/WebCore/page/FeatureObserver.h

    r132125 r133325  
    5555        UnprefixedRequestAnimationFrame,
    5656        PrefixedRequestAnimationFrame,
     57        ContentSecurityPolicy,
     58        ContentSecurityPolicyReportOnly,
     59        PrefixedContentSecurityPolicyReportOnly,
    5760        // Add new features above this line.
    5861        NumberOfFeatures, // This enum value must be last.
Note: See TracChangeset for help on using the changeset viewer.