Bug 1147026 - CSP should ignore query string when checking a resource load - tests (r=dveditz)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Wed, 25 Mar 2015 22:40:25 -0700
changeset 236047 fc15fab6d75b
parent 236046 2b7ca45e0968
child 236048 638492d777fc
push id28488
push userryanvm@gmail.com
push dateFri, 27 Mar 2015 16:19:11 +0000
treeherdermozilla-central@44e454b5e93b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz
bugs1147026
milestone39.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 1147026 - CSP should ignore query string when checking a resource load - tests (r=dveditz)
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
@@ -81,16 +81,17 @@ support-files =
   file_CSP_bug941404_xhr.html
   file_CSP_bug941404_xhr.html^headers^
   file_hash_source.html
   file_dual_header_testserver.sjs
   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;
   }
 }