Diff
Modified: trunk/ChangeLog (120683 => 120684)
--- trunk/ChangeLog 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/ChangeLog 2012-06-19 07:27:33 UTC (rev 120684)
@@ -1,3 +1,12 @@
+2012-06-19 Mike West <[email protected]>
+
+ Add a scheme registry for bypassing Content Security Policy.
+ https://bugs.webkit.org/show_bug.cgi?id=89373
+
+ Reviewed by Adam Barth.
+
+ * Source/autotools/symbols.filter:
+
2012-06-18 Rob Buis <[email protected]>
[BlackBerry] Enable LEGACY_VIEWPORT_ADAPTION
Modified: trunk/LayoutTests/ChangeLog (120683 => 120684)
--- trunk/LayoutTests/ChangeLog 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/LayoutTests/ChangeLog 2012-06-19 07:27:33 UTC (rev 120684)
@@ -1,3 +1,13 @@
+2012-06-19 Mike West <[email protected]>
+
+ Add a scheme registry for bypassing Content Security Policy.
+ https://bugs.webkit.org/show_bug.cgi?id=89373
+
+ Reviewed by Adam Barth.
+
+ * http/tests/security/contentSecurityPolicy/register-bypassing-scheme-expected.txt: Added.
+ * http/tests/security/contentSecurityPolicy/register-bypassing-scheme.html: Added.
+
2012-06-18 Ryosuke Niwa <[email protected]>
Use testRunner instead of layoutTestController in fast/canvas, clip, compact, constructors, cookies, and css* tests
Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme-expected.txt (0 => 120684)
--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme-expected.txt 2012-06-19 07:27:33 UTC (rev 120684)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Refused to load the image 'http://127.0.0.1:8000/security/resources/abe.png' because it violates the following Content Security Policy directive: "img-src https:".
+
+ALERT: PASS (2/3)
+CONSOLE MESSAGE: Refused to load the image 'http://127.0.0.1:8000/security/resources/abe.png' because it violates the following Content Security Policy directive: "img-src https:".
+
+This test ensures that registering a scheme as bypassing CSP actually bypasses CSP. This test passes if three PASSes are generated.
Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme.html (0 => 120684)
--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/register-bypassing-scheme.html 2012-06-19 07:27:33 UTC (rev 120684)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="X-WebKit-CSP" content="img-src https:; script-src 'unsafe-inline'">
+<script>
+ if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ }
+
+ function test1() {
+ var img = document.createElement('img');
+ img._onload_ = function () { alert('FAIL'); };
+ img._onerror_ = function () { alert('PASS (1/3)'); };
+ try {
+ img.src = ""
+ } catch (e) {
+ alert("PASS (1/3)");
+ }
+ test2();
+ }
+
+ function test2() {
+ internals.registerURLSchemeAsBypassingContentSecurityPolicy('http');
+ var img = document.createElement('img');
+ img._onload_ = function () {
+ alert('PASS (2/3)');
+ test3();
+ };
+ try {
+ img.src = ""
+ } catch (e) {
+ alert('FAIL');
+ test3();
+ }
+ }
+
+ function test3() {
+ internals.removeURLSchemeRegisteredAsBypassingContentSecurityPolicy('http');
+ var img = document.createElement('img');
+ img._onload_ = function () { alert('FAIL'); };
+ img._onerror_ = function () { alert('PASS (2/3)'); };
+ try {
+ img.src = ""
+ } catch (e) {
+ alert("PASS (3/3)");
+ }
+ finishTesting();
+ }
+
+ function finishTesting() {
+ if (window.testRunner) {
+ setTimeout(function () { testRunner.notifyDone(); }, 0);
+ }
+ return true;
+ }
+</script>
+</head>
+<body _onload_='test1();'>
+ <p>
+ This test ensures that registering a scheme as bypassing CSP actually bypasses CSP.
+ This test passes if three PASSes are generated.
+ </p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (120683 => 120684)
--- trunk/Source/WebCore/ChangeLog 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/ChangeLog 2012-06-19 07:27:33 UTC (rev 120684)
@@ -1,3 +1,47 @@
+2012-06-19 Mike West <[email protected]>
+
+ Add a scheme registry for bypassing Content Security Policy.
+ https://bugs.webkit.org/show_bug.cgi?id=89373
+
+ Reviewed by Adam Barth.
+
+ The Content Security Policy specification notes that "Enforcing a CSP
+ policy should not interfere with the operation of user-supplied scripts
+ such as third-party user-agent add-ons and _javascript_ bookmarklets."
+ (https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#processing-model)
+ This use case can be at least partially addressed by adding a scheme
+ registry for certain types of URLs whose resources should be loaded
+ regardless of a page's defined policy directives.
+
+ See http://crbug.com/133223 for additional context.
+
+ Test: http/tests/security/contentSecurityPolicy/register-bypassing-scheme.html
+
+ * WebCore.exp.in:
+ Exporting new symbols for use by Internals.
+ * page/ContentSecurityPolicy.cpp:
+ (WebCore::isAllowedByAllWithURL):
+ Adding a check against the new SchemeRegistry method to determine
+ whether or not we should proceed with checking the URL against the
+ policy.
+ * platform/SchemeRegistry.cpp:
+ (WebCore::CSPBypassingSchemes):
+ (WebCore):
+ (WebCore::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy):
+ (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy):
+ (WebCore::SchemeRegistry::schemeShouldBypassContentSecurityPolicy):
+ * platform/SchemeRegistry.h:
+ (SchemeRegistry):
+ Adding the scheme registry for CSP-bypassing URL schemes.
+ * testing/Internals.cpp:
+ (WebCore):
+ (WebCore::Internals::registerURLSchemeAsBypassingContentSecurityPolicy):
+ (WebCore::Internals::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy):
+ * testing/Internals.h:
+ (Internals):
+ * testing/Internals.idl:
+ Adding a method to Internals so that we can write a layout test.
+
2012-06-18 Andy Estes <[email protected]>
[Mac] Editor::fontAttributesForSelectionStart() leaks a NSShadow
Modified: trunk/Source/WebCore/WebCore.exp.in (120683 => 120684)
--- trunk/Source/WebCore/WebCore.exp.in 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-06-19 07:27:33 UTC (rev 120684)
@@ -274,6 +274,8 @@
__ZN7WebCore14SchemeRegistry40setDomainRelaxationForbiddenForURLSchemeEbRKN3WTF6StringE
__ZN7WebCore14SchemeRegistry58registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsingERKN3WTF6StringE
__ZN7WebCore14SchemeRegistry62registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsingERKN3WTF6StringE
+__ZN7WebCore14SchemeRegistry49registerURLSchemeAsBypassingContentSecurityPolicyERKN3WTF6StringE
+__ZN7WebCore14SchemeRegistry57removeURLSchemeRegisteredAsBypassingContentSecurityPolicyERKN3WTF6StringE
__ZN7WebCore14ScrollableArea15contentsResizedEv
__ZN7WebCore14ScrollableArea16handleWheelEventERKNS_18PlatformWheelEventE
__ZN7WebCore14ScrollableArea17willEndLiveResizeEv
Modified: trunk/Source/WebCore/page/ContentSecurityPolicy.cpp (120683 => 120684)
--- trunk/Source/WebCore/page/ContentSecurityPolicy.cpp 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/page/ContentSecurityPolicy.cpp 2012-06-19 07:27:33 UTC (rev 120684)
@@ -34,6 +34,7 @@
#include "InspectorInstrumentation.h"
#include "InspectorValues.h"
#include "PingLoader.h"
+#include "SchemeRegistry.h"
#include "ScriptCallStack.h"
#include "SecurityOrigin.h"
#include "TextEncoding.h"
@@ -1018,6 +1019,9 @@
template<bool (CSPDirectiveList::*allowFromURL)(const KURL&) const>
bool isAllowedByAllWithURL(const CSPDirectiveListVector& policies, const KURL& url)
{
+ if (SchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
+ return true;
+
for (size_t i = 0; i < policies.size(); ++i) {
if (!(policies[i].get()->*allowFromURL)(url))
return false;
Modified: trunk/Source/WebCore/platform/SchemeRegistry.cpp (120683 => 120684)
--- trunk/Source/WebCore/platform/SchemeRegistry.cpp 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/platform/SchemeRegistry.cpp 2012-06-19 07:27:33 UTC (rev 120684)
@@ -164,6 +164,12 @@
return CORSEnabledSchemes;
}
+static URLSchemesMap& ContentSecurityPolicyBypassingSchemes()
+{
+ DEFINE_STATIC_LOCAL(URLSchemesMap, schemes, ());
+ return schemes;
+}
+
bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
{
if (scheme.isEmpty())
@@ -297,4 +303,21 @@
return CORSEnabledSchemes().contains(scheme);
}
+void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme)
+{
+ ContentSecurityPolicyBypassingSchemes().add(scheme);
+}
+
+void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme)
+{
+ ContentSecurityPolicyBypassingSchemes().remove(scheme);
+}
+
+bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& scheme)
+{
+ if (scheme.isEmpty())
+ return false;
+ return ContentSecurityPolicyBypassingSchemes().contains(scheme);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/SchemeRegistry.h (120683 => 120684)
--- trunk/Source/WebCore/platform/SchemeRegistry.h 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/platform/SchemeRegistry.h 2012-06-19 07:27:33 UTC (rev 120684)
@@ -82,6 +82,12 @@
// Allow non-HTTP schemes to be registered to allow CORS requests.
static void registerURLSchemeAsCORSEnabled(const String& scheme);
static bool shouldTreatURLSchemeAsCORSEnabled(const String& scheme);
+
+ // Allow resources from some schemes to load on a page, regardless of its
+ // Content Security Policy.
+ static void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
+ static void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
+ static bool schemeShouldBypassContentSecurityPolicy(const String& scheme);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (120683 => 120684)
--- trunk/Source/WebCore/testing/Internals.cpp 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/testing/Internals.cpp 2012-06-19 07:27:33 UTC (rev 120684)
@@ -58,6 +58,7 @@
#include "Range.h"
#include "RenderObject.h"
#include "RenderTreeAsText.h"
+#include "SchemeRegistry.h"
#include "Settings.h"
#include "ShadowRoot.h"
#include "SpellChecker.h"
@@ -1144,4 +1145,15 @@
document->webkitDidExitFullScreenForElement(element);
}
#endif
+
+void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme);
}
+
+void Internals::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme)
+{
+ SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(scheme);
+}
+
+}
Modified: trunk/Source/WebCore/testing/Internals.h (120683 => 120684)
--- trunk/Source/WebCore/testing/Internals.h 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/testing/Internals.h 2012-06-19 07:27:33 UTC (rev 120684)
@@ -190,6 +190,9 @@
void webkitDidExitFullScreenForElement(Document*, Element*);
#endif
+ void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
+ void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
+
private:
explicit Internals(Document*);
DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
Modified: trunk/Source/WebCore/testing/Internals.idl (120683 => 120684)
--- trunk/Source/WebCore/testing/Internals.idl 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebCore/testing/Internals.idl 2012-06-19 07:27:33 UTC (rev 120684)
@@ -163,6 +163,9 @@
void webkitWillExitFullScreenForElement(in Document document, in Element element);
void webkitDidExitFullScreenForElement(in Document document, in Element element);
#endif
+
+ void registerURLSchemeAsBypassingContentSecurityPolicy(in DOMString scheme);
+ void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(in DOMString scheme);
};
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (120683 => 120684)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-19 07:27:33 UTC (rev 120684)
@@ -1,3 +1,16 @@
+2012-06-19 Mike West <[email protected]>
+
+ Add a scheme registry for bypassing Content Security Policy.
+ https://bugs.webkit.org/show_bug.cgi?id=89373
+
+ Reviewed by Adam Barth.
+
+ * public/WebSecurityPolicy.h:
+ (WebSecurityPolicy):
+ * src/WebSecurityPolicy.cpp:
+ (WebKit::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy):
+ (WebKit):
+
2012-06-18 Adam Barth <[email protected]>
[Chromium] GesturePinchBegin and friends are gesture events
Modified: trunk/Source/WebKit/chromium/public/WebSecurityPolicy.h (120683 => 120684)
--- trunk/Source/WebKit/chromium/public/WebSecurityPolicy.h 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit/chromium/public/WebSecurityPolicy.h 2012-06-19 07:27:33 UTC (rev 120684)
@@ -61,9 +61,12 @@
// included by an HTTPS page.
WEBKIT_EXPORT static void registerURLSchemeAsSecure(const WebString&);
- // Registers a non-HTTP URL scheme which can be sent CORS requests.
+ // Registers a non-HTTP URL scheme which can be sent CORS requests.
WEBKIT_EXPORT static void registerURLSchemeAsCORSEnabled(const WebString&);
+ // Registers a URL scheme whose resources can be loaded regardless of a page's Content Security Policy.
+ WEBKIT_EXPORT static void registerURLSchemeAsBypassingContentSecurityPolicy(const WebString&);
+
// Registers a URL scheme as strictly empty documents, allowing them to
// commit synchronously.
WEBKIT_EXPORT static void registerURLSchemeAsEmptyDocument(const WebString&);
Modified: trunk/Source/WebKit/chromium/src/WebSecurityPolicy.cpp (120683 => 120684)
--- trunk/Source/WebKit/chromium/src/WebSecurityPolicy.cpp 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit/chromium/src/WebSecurityPolicy.cpp 2012-06-19 07:27:33 UTC (rev 120684)
@@ -68,6 +68,11 @@
SchemeRegistry::registerURLSchemeAsCORSEnabled(scheme);
}
+void WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme);
+}
+
void WebSecurityPolicy::registerURLSchemeAsEmptyDocument(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsEmptyDocument(scheme);
Modified: trunk/Source/WebKit2/ChangeLog (120683 => 120684)
--- trunk/Source/WebKit2/ChangeLog 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit2/ChangeLog 2012-06-19 07:27:33 UTC (rev 120684)
@@ -1,3 +1,13 @@
+2012-06-19 Mike West <[email protected]>
+
+ Add a scheme registry for bypassing Content Security Policy.
+ https://bugs.webkit.org/show_bug.cgi?id=89373
+
+ Reviewed by Adam Barth.
+
+ * win/WebKit2.def:
+ * win/WebKit2CFLite.def:
+
2012-06-16 Adam Barth <[email protected]>
Settings::devicePixelRatio doesn't do anything and is confusing
Modified: trunk/Source/WebKit2/win/WebKit2.def (120683 => 120684)
--- trunk/Source/WebKit2/win/WebKit2.def 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit2/win/WebKit2.def 2012-06-19 07:27:33 UTC (rev 120684)
@@ -268,3 +268,5 @@
?profilerEnabled@InspectorController@WebCore@@QAE_NXZ
?setProfilerEnabled@InspectorController@WebCore@@QAEX_N@Z
?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@U?$PtrHash@PAVStringImpl@WTF@@@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
+ ?registerURLSchemeAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z
+ ?removeURLSchemeRegisteredAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z
Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (120683 => 120684)
--- trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-06-19 07:27:33 UTC (rev 120684)
@@ -257,3 +257,5 @@
?profilerEnabled@InspectorController@WebCore@@QAE_NXZ
?setProfilerEnabled@InspectorController@WebCore@@QAEX_N@Z
?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@U?$PtrHash@PAVStringImpl@WTF@@@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
+ ?registerURLSchemeAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z
+ ?removeURLSchemeRegisteredAsBypassingContentSecurityPolicy@SchemeRegistry@WebCore@@SAXABVString@WTF@@@Z
Modified: trunk/Source/autotools/symbols.filter (120683 => 120684)
--- trunk/Source/autotools/symbols.filter 2012-06-19 07:23:13 UTC (rev 120683)
+++ trunk/Source/autotools/symbols.filter 2012-06-19 07:27:33 UTC (rev 120684)
@@ -58,6 +58,8 @@
_ZN7WebCore14ClientRectListC1Ev;
_ZN7WebCore14ClientRectListD1Ev;
_ZN7WebCore14FrameSelection19absoluteCaretBoundsEv;
+_ZN7WebCore14SchemeRegistry49registerURLSchemeAsBypassingContentSecurityPolicyERKN3WTF6StringE;
+_ZN7WebCore14SchemeRegistry57removeURLSchemeRegisteredAsBypassingContentSecurityPolicyERKN3WTF6StringE;
_ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi;
_ZN7WebCore15toDOMStringListEPN3JSC9ExecStateENS0_7JSValueE;
_ZN7WebCore16HTMLInputElement17setSuggestedValueERKN3WTF6StringE;