Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for Content Security Policy "no eval" in crypto.getCRMFRequest()</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | </div> |
michael@0 | 12 | <iframe style="width:100%;height:300px;" id='cspframe'></iframe> |
michael@0 | 13 | <iframe style="width:100%;height:300px;" id='cspframe2'></iframe> |
michael@0 | 14 | <iframe style="width:100%;height:300px;" id='cspframe3'></iframe> |
michael@0 | 15 | <iframe style="width:100%;height:300px;" id='cspframe4'></iframe> |
michael@0 | 16 | <script class="testbody" type="text/javascript"> |
michael@0 | 17 | |
michael@0 | 18 | var path = "/tests/content/base/test/csp/"; |
michael@0 | 19 | |
michael@0 | 20 | var evalScriptsThatRan = 0; |
michael@0 | 21 | var evalScriptsBlocked = 0; |
michael@0 | 22 | var evalScriptsTotal = 4; |
michael@0 | 23 | |
michael@0 | 24 | // called by scripts that run |
michael@0 | 25 | var scriptRan = function(shouldrun, testname, data) { |
michael@0 | 26 | evalScriptsThatRan++; |
michael@0 | 27 | ok(shouldrun, 'EVAL SCRIPT RAN: ' + testname + '(' + data + ')'); |
michael@0 | 28 | checkTestResults(); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | // called when a script is blocked |
michael@0 | 32 | var scriptBlocked = function(shouldrun, testname, data) { |
michael@0 | 33 | evalScriptsBlocked++; |
michael@0 | 34 | ok(!shouldrun, 'EVAL SCRIPT BLOCKED: ' + testname + '(' + data + ')'); |
michael@0 | 35 | checkTestResults(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | // Check to see if all the tests have run |
michael@0 | 39 | var checkTestResults = function() { |
michael@0 | 40 | // if any test is incomplete, keep waiting |
michael@0 | 41 | if (evalScriptsTotal - evalScriptsBlocked - evalScriptsThatRan > 0) |
michael@0 | 42 | return; |
michael@0 | 43 | |
michael@0 | 44 | // ... otherwise, finish |
michael@0 | 45 | SimpleTest.finish(); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | ////////////////////////////////////////////////////////////////////// |
michael@0 | 49 | // set up and go |
michael@0 | 50 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 51 | |
michael@0 | 52 | SpecialPowers.pushPrefEnv( |
michael@0 | 53 | {'set':[["security.csp.speccompliant", true]]}, |
michael@0 | 54 | function() { |
michael@0 | 55 | // save this for last so that our listeners are registered. |
michael@0 | 56 | // ... this loads the testbed of good and bad requests. |
michael@0 | 57 | document.getElementById('cspframe').src = 'file_CSP_evalscript_main_getCRMFRequest.html'; |
michael@0 | 58 | document.getElementById('cspframe2').src = 'file_CSP_evalscript_main_spec_compliant_getCRMFRequest.html'; |
michael@0 | 59 | document.getElementById('cspframe3').src = 'file_CSP_evalscript_main_spec_compliant_allowed_getCRMFRequest.html'; |
michael@0 | 60 | document.getElementById('cspframe4').src = 'file_CSP_evalscript_no_CSP_at_all.html'; |
michael@0 | 61 | }); |
michael@0 | 62 | </script> |
michael@0 | 63 | </pre> |
michael@0 | 64 | </body> |
michael@0 | 65 | </html> |