Bug 1370468 - Files for frame-ancestor tests including userpass added draft
authorvinoth <cegvinoth@gmail.com>
Mon, 04 Sep 2017 09:06:00 +0200
changeset 658461 c7a53893c9674d5d8b0894e8209840ec9bc867d2
parent 657524 9f702a7dde2df2de6235709e8e7af725785003f6
child 658598 c88d638d10b3fae5a204a6c0bc857ed05d22e1a7
push id77784
push userbmo:cegvinoth@gmail.com
push dateMon, 04 Sep 2017 07:06:41 +0000
bugs1370468
milestone57.0a1
Bug 1370468 - Files for frame-ancestor tests including userpass added MozReview-Commit-ID: B84u5i7EPyw
dom/security/test/csp/file_frame_a.html
dom/security/test/csp/file_frame_b.html
dom/security/test/csp/file_frame_c.html
dom/security/test/csp/file_frame_c.html^headers^
dom/security/test/csp/file_frame_d.html
dom/security/test/csp/file_frame_d.html^headers^
dom/security/test/csp/file_frameancestors_userpass.html
dom/security/test/csp/file_frameancestors_userpass_frame_a.html
dom/security/test/csp/file_frameancestors_userpass_frame_b.html
dom/security/test/csp/file_frameancestors_userpass_frame_c.html
dom/security/test/csp/file_frameancestors_userpass_frame_c.html^headers^
dom/security/test/csp/file_frameancestors_userpass_frame_d.html
dom/security/test/csp/file_frameancestors_userpass_frame_d.html^headers^
dom/security/test/csp/mochitest.ini
dom/security/test/csp/test_frameancestors_userpass.html
dom/security/test/gtest/TestCSPParser.cpp
deleted file mode 100644
--- a/dom/security/test/csp/file_frame_a.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
-  <head>
-    <title>Nested frame</title>
-    <script>
-          parent.parent.postMessage({call: "frameLoaded", testname: "frame_a", uri: window.location.toString()}, "*");
-    </script>
-  </head>
-  <body>
-
-    <tt>  IFRAME C</tt><br/>
-    <iframe src='http://sampleuser:samplepass@mochi.test:8888/tests/dom/security/test/csp/file_frame_c.html'></iframe><br/>
-
-  </body>
-</html>
deleted file mode 100644
--- a/dom/security/test/csp/file_frame_b.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
-  <head>
-    <title>Nested frame</title>
-    <script>
-          parent.parent.postMessage({call: "frameLoaded", testname: "frame_b", uri: window.location.toString()}, "*");
-    </script>
-  </head>
-  <body>
-
-    <tt>  IFRAME D</tt><br/>
-    <iframe src='http://sampleuser:samplepass@example.com/tests/dom/security/test/csp/file_frame_d.html'></iframe><br/>
-
-  </body>
-</html>
deleted file mode 100644
--- a/dom/security/test/csp/file_frame_c.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-  <head>
-    <title>Nested frame</title>
-  </head>
-  <body>
-         nested frame C content
-  </body>
-</html>
deleted file mode 100644
--- a/dom/security/test/csp/file_frame_d.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-  <head>
-    <title>Nested frame</title>
-  </head>
-  <body>
-         nested frame D content
-  </body>
-</html>
--- a/dom/security/test/csp/file_frameancestors_userpass.html
+++ b/dom/security/test/csp/file_frameancestors_userpass.html
@@ -1,15 +1,10 @@
 <html>
   <head>
     <title>CSP frame ancestors tests</title>
-
   </head>
   <body>
-
-<tt>  IFRAME A</tt><br/>
-<iframe src='http://sampleuser:samplepass@mochi.test:8888/tests/dom/security/test/csp/file_frame_a.html'></iframe><br/>
-
-<tt>  IFRAME B</tt><br/>
-<iframe src='http://sampleuser:samplepass@example.com/tests/dom/security/test/csp/file_frame_b.html'></iframe><br/>
-
+    <tt>Nested Frames</tt><br/>
+    <iframe src='http://sampleuser:samplepass@mochi.test:8888/tests/dom/security/test/csp/file_frameancestors_userpass_frame_a.html'></iframe><br/>
+    <iframe src='http://sampleuser:samplepass@example.com/tests/dom/security/test/csp/file_frameancestors_userpass_frame_b.html'></iframe><br/>
   </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/dom/security/test/csp/file_frameancestors_userpass_frame_a.html
@@ -0,0 +1,12 @@
+<html>
+  <head>
+    <title>Nested frame</title>
+    <script>
+          parent.parent.postMessage({call: "frameLoaded", testname: "frame_a", uri: window.location.toString()}, "*");
+    </script>
+  </head>
+  <body>
+    <tt>IFRAME A</tt><br/>
+    <iframe src='http://sampleuser:samplepass@mochi.test:8888/tests/dom/security/test/csp/file_frameancestors_userpass_frame_c.html'></iframe><br/>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/security/test/csp/file_frameancestors_userpass_frame_b.html
@@ -0,0 +1,12 @@
+<html>
+  <head>
+    <title>Nested frame</title>
+    <script>
+          parent.parent.postMessage({call: "frameLoaded", testname: "frame_b", uri: window.location.toString()}, "*");
+    </script>
+  </head>
+  <body>
+    <tt>IFRAME B</tt><br/>
+    <iframe src='http://sampleuser:samplepass@example.com/tests/dom/security/test/csp/file_frameancestors_userpass_frame_d.html'></iframe><br/>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/security/test/csp/file_frameancestors_userpass_frame_c.html
@@ -0,0 +1,8 @@
+<html>
+  <head>
+    <title>Nested frame</title>
+  </head>
+  <body>
+        Nested frame C content
+  </body>
+</html>
rename from dom/security/test/csp/file_frame_c.html^headers^
rename to dom/security/test/csp/file_frameancestors_userpass_frame_c.html^headers^
new file mode 100644
--- /dev/null
+++ b/dom/security/test/csp/file_frameancestors_userpass_frame_d.html
@@ -0,0 +1,8 @@
+<html>
+  <head>
+    <title>Nested frame</title>
+  </head>
+  <body>
+         Nested frame D content
+  </body>
+</html>
rename from dom/security/test/csp/file_frame_d.html^headers^
rename to dom/security/test/csp/file_frameancestors_userpass_frame_d.html^headers^
--- a/dom/security/test/csp/mochitest.ini
+++ b/dom/security/test/csp/mochitest.ini
@@ -27,22 +27,22 @@ support-files =
   file_evalscript_main.html
   file_evalscript_main.html^headers^
   file_evalscript_main_allowed.html
   file_evalscript_main_allowed.html^headers^
   file_frameancestors_main.html
   file_frameancestors_main.js
   file_frameancestors.sjs
   file_frameancestors_userpass.html
-  file_frame_a.html
-  file_frame_b.html
-  file_frame_c.html
-  file_frame_c.html^headers^
-  file_frame_d.html
-  file_frame_d.html^headers^
+  file_frameancestors_userpass_frame_a.html
+  file_frameancestors_userpass_frame_b.html
+  file_frameancestors_userpass_frame_c.html
+  file_frameancestors_userpass_frame_c.html^headers^
+  file_frameancestors_userpass_frame_d.html
+  file_frameancestors_userpass_frame_d.html^headers^
   file_inlinescript.html
   file_inlinestyle_main.html
   file_inlinestyle_main.html^headers^
   file_inlinestyle_main_allowed.html
   file_inlinestyle_main_allowed.html^headers^
   file_invalid_source_expression.html
   file_main.html
   file_main.html^headers^
--- a/dom/security/test/csp/test_frameancestors_userpass.html
+++ b/dom/security/test/csp/test_frameancestors_userpass.html
@@ -72,39 +72,37 @@ var frameLoaded = function(testname, uri
   if (window.framesThatShouldLoad[testname] != -1)
     return;
 
   if (typeof window.framesThatShouldLoad[testname] === 'undefined') {
     // uh-oh, we're not expecting this frame to load!
     ok(false, testname + ' framed site should not have loaded: ' + uri);
   } else {
     //Check if @ symbol is there in URI.
-    if(uri.includes('@'))
-    {
+    if (uri.includes('@')) {
       ok(false, ' URI contains userpass. Fetched URI is ' + uri);
-    }
-    else {
+    } else {
       framesThatShouldLoad[testname] = true;
       ok(true, ' URI doesn\'t contain userpass. Fetched URI is ' + uri);
     }
   }
   checkTestResults();
 }
 
 // called when a frame is blocked
 // -- we can't determine *which* frame was blocked, but at least we can count them
 var frameBlocked = function(uri, policy) {
 
   //Check if @ symbol is there in URI or in csp policy.
-  if(policy.includes('@') || uri.includes('@'))
-  {
-    ok(false, ' a CSP policy blocked frame from being loaded. But contains userpass. Policy is: ' + policy + ';URI is: ' + uri );
-  }
-  else {
-    ok(true, ' a CSP policy blocked frame from being loaded. Doesn\'t contain userpass. Policy is: ' + policy + ';URI is: ' + uri );
+  if (policy.includes('@') || uri.includes('@')) {
+    ok(false, ' a CSP policy blocked frame from being loaded. But contains' +
+      ' userpass. Policy is: ' + policy + ';URI is: ' + uri );
+  } else {
+    ok(true, ' a CSP policy blocked frame from being loaded. Doesn\'t contain'+
+      ' userpass. Policy is: ' + policy + ';URI is: ' + uri );
   }
   expectedViolationsLeft--;
   checkTestResults();
 }
 
 
 // Check to see if all the tests have run
 var checkTestResults = function() {
--- a/dom/security/test/gtest/TestCSPParser.cpp
+++ b/dom/security/test/gtest/TestCSPParser.cpp
@@ -793,16 +793,18 @@ TEST(CSPParser, GoodGeneratedPolicies)
     { "frame-ancestors 'self'",
       "frame-ancestors http://www.selfuri.com" },
     { "frame-ancestors http://self.com:88",
       "frame-ancestors http://self.com:88" },
     { "frame-ancestors http://a.b.c.d.e.f.g.h.i.j.k.l.x.com",
       "frame-ancestors http://a.b.c.d.e.f.g.h.i.j.k.l.x.com" },
     { "frame-ancestors https://self.com:34",
       "frame-ancestors https://self.com:34" },
+    { "frame-ancestors http://sampleuser:samplepass@example.com",
+      "frame-ancestors http://sampleuser:samplepass@example.com" },
     { "default-src 'none'; frame-ancestors 'self'",
       "default-src 'none'; frame-ancestors http://www.selfuri.com" },
     { "frame-ancestors http://self:80",
       "frame-ancestors http://self:80" },
     { "frame-ancestors http://self.com/bar",
       "frame-ancestors http://self.com/bar" },
     { "default-src 'self'; frame-ancestors 'self'",
       "default-src http://www.selfuri.com; frame-ancestors http://www.selfuri.com" },
@@ -1123,9 +1125,8 @@ TEST(CSPParser, FuzzyPoliciesIncDirLimAS
       uint32_t inputIndex = rand() % sizeof(input);
       testPol[0].policy[i] = input[inputIndex];
     }
     ASSERT_TRUE(NS_SUCCEEDED(runTestSuite(testPol, 1,
                                           kFuzzyExpectedPolicyCount)));
   }
 }
 #endif
-