Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=918397
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 918397</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=918397">Mozilla Bug 918397</a>
14 <p id="display"></p>
16 <iframe id="cspframe"></iframe>
18 <pre id="test">
19 <script class="testbody" type="text/javascript">
20 // Load locale strings during mochitest
21 var stringBundleService = SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"]
22 .getService(SpecialPowers.Ci.nsIStringBundleService);
23 var localizer = stringBundleService.createBundle("chrome://global/locale/security/security.properties");
24 var depreHeadersMsg = localizer.GetStringFromName("OldCSPHeaderDeprecated", 0)
25 var dualHeadersMsg = localizer.GetStringFromName("BothCSPHeadersPresent", 0)
27 function cleanup() {
28 SpecialPowers.postConsoleSentinel();
29 SimpleTest.finish();
30 }
32 // listen on the console before loading the iframe
33 SpecialPowers.registerConsoleListener(function ConsoleMsgListener(aMsg) {
34 // Note: We do not want to see the deprecation warning appear in the console.
35 // This test can only be sure that the deprecation warning does not appear
36 // iff the deprecation warning appears before the dual header warning appears
37 // in the console.
38 if (aMsg.message.indexOf(depreHeadersMsg) > -1) {
39 ok(false, "Deprecated CSP header warning should not be present.");
40 return;
41 } else if (aMsg.message.indexOf(dualHeadersMsg) > -1) {
42 ok(true, "Dual CSP header warning present.");
43 SimpleTest.executeSoon(cleanup);
44 } else {
45 // if some other console message is present, we wait
46 return;
47 }
48 });
50 // get ready and test
51 SimpleTest.waitForExplicitFinish();
52 SpecialPowers.pushPrefEnv(
53 {'set': [["security.csp.speccompliant", true]]},
54 function() {
55 document.getElementById('cspframe').src = 'file_dual_headers_warning.html';
56 });
57 </script>
58 </body>
59 </html>