Bug 1094067 - CSP: Parser should follow path production from RFC 3986 - parser tests (r=sstamm)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Fri, 14 Nov 2014 15:06:27 -0800
changeset 218778 5866fd3c075cccca4a1ad009db4410a021fa426d
parent 218777 80de5f55ca1ef321442f91ebbd2724a530070ad1
child 218779 bf25101e66cf062c98ffd807be3de1c68228570d
push id27944
push usercbook@mozilla.com
push dateTue, 09 Dec 2014 11:54:28 +0000
treeherderautoland@acf5660d2048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstamm
bugs1094067
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1094067 - CSP: Parser should follow path production from RFC 3986 - parser tests (r=sstamm)
dom/base/test/TestCSPParser.cpp
--- a/dom/base/test/TestCSPParser.cpp
+++ b/dom/base/test/TestCSPParser.cpp
@@ -273,19 +273,19 @@ nsresult TestIgnoreUpperLowerCasePolicie
     { "script-src 'SHA256-siVR8vAcqP06h2ppeNwqgjr0yZ6yned4X2VF84j4GmI='",
       "script-src 'sha256-siVR8vAcqP06h2ppeNwqgjr0yZ6yned4X2VF84j4GmI='" }
   };
 
   uint32_t policyCount = sizeof(policies) / sizeof(PolicyTest);
   return runTestSuite(policies, policyCount, 1);
 }
 
-// ============================= TestIgnorePaths ========================
+// ============================= TestPaths ========================
 
-nsresult TestIgnorePaths() {
+nsresult TestPaths() {
 
   static const PolicyTest policies[] =
   {
     { "script-src http://www.example.com",
       "script-src http://www.example.com" },
     { "script-src http://www.example.com/",
       "script-src http://www.example.com/" },
     { "script-src http://www.example.com/path-1",
@@ -355,16 +355,22 @@ nsresult TestIgnorePaths() {
     { "report-uri http://www.example.com:8888/asdf",
       "report-uri http://www.example.com:8888/asdf" },
     { "report-uri http://www.example.com:8888/path_1/path_2",
       "report-uri http://www.example.com:8888/path_1/path_2" },
     { "report-uri http://www.example.com:8888/path_1/path_2/report.sjs&301",
       "report-uri http://www.example.com:8888/path_1/path_2/report.sjs&301" },
     { "report-uri /examplepath",
       "report-uri http://www.selfuri.com/examplepath" },
+    { "connect-src http://www.example.com/foo%3Bsessionid=12%2C34",
+      "connect-src http://www.example.com/foo;sessionid=12,34" },
+    { "connect-src http://www.example.com/foo%3bsessionid=12%2c34",
+      "connect-src http://www.example.com/foo;sessionid=12,34" },
+    { "connect-src http://test.com/pathIncludingAz19-._~!$&'()*+=:@",
+      "connect-src http://test.com/pathincludingaz19-._~!$&'()*+=:@" },
   };
 
   uint32_t policyCount = sizeof(policies) / sizeof(PolicyTest);
   return runTestSuite(policies, policyCount, 1);
 }
 
 // ============================= TestSimplePolicies ========================
 
@@ -487,16 +493,20 @@ nsresult TestPoliciesWithInvalidSrc() {
     { "script-src http://www.example.com:88/.js",
       "script-src 'none'" },
     { "script-src http://www.example.com:88.js",
       "script-src 'none'" },
     { "script-src http://www.example.com:*.js",
       "script-src 'none'" },
     { "script-src http://www.example.com:*.",
       "script-src 'none'" },
+    { "connect-src http://www.example.com/foo%zz;",
+      "connect-src 'none'" },
+    { "script-src https://foo.com/%$",
+      "script-src 'none'" },
   };
 
   uint32_t policyCount = sizeof(policies) / sizeof(PolicyTest);
   return runTestSuite(policies, policyCount, 1);
 }
 
 // ============================= TestBadPolicies ========================
 
@@ -1078,17 +1088,17 @@ int main(int argc, char** argv) {
   ScopedXPCOM xpcom("ContentSecurityPolicyParser");
   if (xpcom.failed()) {
     return 1;
   }
 
   if (NS_FAILED(TestDirectives()))                           { return 1; }
   if (NS_FAILED(TestKeywords()))                             { return 1; }
   if (NS_FAILED(TestIgnoreUpperLowerCasePolicies()))         { return 1; }
-  if (NS_FAILED(TestIgnorePaths()))                          { return 1; }
+  if (NS_FAILED(TestPaths()))                                { return 1; }
   if (NS_FAILED(TestSimplePolicies()))                       { return 1; }
   if (NS_FAILED(TestPoliciesWithInvalidSrc()))               { return 1; }
   if (NS_FAILED(TestBadPolicies()))                          { return 1; }
   if (NS_FAILED(TestGoodGeneratedPolicies()))                { return 1; }
   if (NS_FAILED(TestBadGeneratedPolicies()))                 { return 1; }
   if (NS_FAILED(TestGoodGeneratedPoliciesForPathHandling())) { return 1; }
   if (NS_FAILED(TestBadGeneratedPoliciesForPathHandling()))  { return 1; }
   if (NS_FAILED(TestShorteningPolicies()))                   { return 1; }