Bug 1147026 - CSP should ignore query string when checking a resource load - tests. r=dveditz, a=sledru
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Wed, 25 Mar 2015 22:40:25 -0700
changeset 258333 6d1efbb2c76c
parent 258332 c2f29d6648e8
child 258334 4f2f00d1331c
push id4647
push userryanvm@gmail.com
push date2015-04-07 21:15 +0000
treeherdermozilla-beta@6d1efbb2c76c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, sledru
bugs1147026
milestone38.0
Bug 1147026 - CSP should ignore query string when checking a resource load - tests. r=dveditz, a=sledru
dom/base/test/csp/file_csp_path_matching_incl_query.html
dom/base/test/csp/mochitest.ini
dom/base/test/csp/test_csp_path_matching.html
new file mode 100644
--- /dev/null
+++ b/dom/base/test/csp/file_csp_path_matching_incl_query.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <title>Bug 1147026 - CSP should ignore query string when checking a resource load</title>
+  </head>
+  <body>
+  <div id="testdiv">blocked</div>
+  <script src="http://test1.example.com/tests/dom/base/test/csp/file_csp_path_matching.js?val=foo"></script>
+</body>
+</html>
--- a/dom/base/test/csp/mochitest.ini
+++ b/dom/base/test/csp/mochitest.ini
@@ -79,16 +79,17 @@ support-files =
   file_CSP_bug941404.html
   file_CSP_bug941404_xhr.html
   file_CSP_bug941404_xhr.html^headers^
   file_hash_source.html
   file_hash_source.html^headers^
   file_self_none_as_hostname_confusion.html
   file_self_none_as_hostname_confusion.html^headers^
   file_csp_path_matching.html
+  file_csp_path_matching_incl_query.html
   file_csp_path_matching.js
   file_csp_path_matching_redirect.html
   file_csp_path_matching_redirect_server.sjs
   file_csp_testserver.sjs
   file_report_uri_missing_in_report_only_header.html
   file_report_uri_missing_in_report_only_header.html^headers^
   file_csp_report.html
   file_redirect_content.sjs
--- a/dom/base/test/csp/test_csp_path_matching.html
+++ b/dom/base/test/csp/test_csp_path_matching.html
@@ -74,19 +74,24 @@ var counter = 0;
 var policy;
 
 function loadNextTest() {
   if (counter == policies.length) {
     SimpleTest.finish();
   }
   else {
     policy = policies[counter++];
-    var src = "file_csp_testserver.sjs";
+    var src = "file_csp_testserver.sjs?file=";
     // append the file that should be served
-    src += "?file=" + escape("tests/dom/base/test/csp/file_csp_path_matching.html");
+    src += (counter % 2 == 0)
+               // load url including ref: example.com#foo
+             ? escape("tests/dom/base/test/csp/file_csp_path_matching.html")
+               // load url including query: example.com?val=foo (bug 1147026)
+             : escape("tests/dom/base/test/csp/file_csp_path_matching_incl_query.html");
+
     // append the CSP that should be used to serve the file
     src += "&csp=" + escape("default-src 'none'; script-src " + policy[1]);
 
     document.getElementById("testframe").addEventListener("load", test, false);
     document.getElementById("testframe").src = src;
   }
 }