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.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | Testing Whitelist of Resource Schemed for Mixed Content Blocker |
michael@0 | 5 | https://bugzilla.mozilla.org/show_bug.cgi?id=803225 |
michael@0 | 6 | --> |
michael@0 | 7 | <head> |
michael@0 | 8 | <meta charset="utf-8"> |
michael@0 | 9 | <title>Tests for Bug 803225</title> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | |
michael@0 | 13 | <script> |
michael@0 | 14 | |
michael@0 | 15 | var origBlockDisplay = SpecialPowers.getBoolPref("security.mixed_content.block_display_content"); |
michael@0 | 16 | var origBlockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content"); |
michael@0 | 17 | |
michael@0 | 18 | var counter = 0; |
michael@0 | 19 | var settings = [ [true, true], [true, false], [false, true], [false, false] ]; |
michael@0 | 20 | |
michael@0 | 21 | var blockActive; |
michael@0 | 22 | var blockDisplay; |
michael@0 | 23 | |
michael@0 | 24 | //Cycle through 4 different preference settings. |
michael@0 | 25 | function changePrefs(x) { |
michael@0 | 26 | SpecialPowers.setBoolPref("security.mixed_content.block_display_content", settings[x][0]); |
michael@0 | 27 | SpecialPowers.setBoolPref("security.mixed_content.block_active_content", settings[x][1]); |
michael@0 | 28 | blockDisplay = SpecialPowers.getBoolPref("security.mixed_content.block_display_content"); |
michael@0 | 29 | blockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content"); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | //Set the first set of settings (true, true) and increment the counter. |
michael@0 | 33 | changePrefs(counter); |
michael@0 | 34 | counter++; |
michael@0 | 35 | |
michael@0 | 36 | var testsToRun = { |
michael@0 | 37 | /* https - Tests already run as part of bug 62178. */ |
michael@0 | 38 | about: false, |
michael@0 | 39 | mozicon: false, |
michael@0 | 40 | resource: false, |
michael@0 | 41 | unsafe_about: false, |
michael@0 | 42 | data_protocol: false, |
michael@0 | 43 | javascript: false, |
michael@0 | 44 | mailto: false, |
michael@0 | 45 | wss: false, |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | function log(msg) { |
michael@0 | 49 | document.getElementById("log").textContent += "\n" + msg; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function checkTestsCompleted() { |
michael@0 | 53 | for (var prop in testsToRun) { |
michael@0 | 54 | // some test hasn't run yet so we're not done |
michael@0 | 55 | if (!testsToRun[prop]) |
michael@0 | 56 | return; |
michael@0 | 57 | } |
michael@0 | 58 | //if the testsToRun are all completed, change the pref and run the tests again until we have cycled through all the prefs. |
michael@0 | 59 | if(counter < 4) { |
michael@0 | 60 | for (var prop in testsToRun) { |
michael@0 | 61 | testsToRun[prop] = false; |
michael@0 | 62 | } |
michael@0 | 63 | //call to change the preferences |
michael@0 | 64 | changePrefs(counter); |
michael@0 | 65 | counter++; |
michael@0 | 66 | log("\nblockDisplay set to "+blockDisplay+", blockActive set to "+blockActive+"."); |
michael@0 | 67 | document.getElementById('framediv').innerHTML = '<iframe id="testHarness" src="https://example.com/tests/content/base/test/file_mixed_content_main_bug803225.html"></iframe>'; |
michael@0 | 68 | } |
michael@0 | 69 | else { |
michael@0 | 70 | //set the prefs back to what they were set to originally |
michael@0 | 71 | SpecialPowers.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay); |
michael@0 | 72 | SpecialPowers.setBoolPref("security.mixed_content.block_active_content", origBlockActive); |
michael@0 | 73 | SimpleTest.finish(); |
michael@0 | 74 | } |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | var firstTest = true; |
michael@0 | 78 | |
michael@0 | 79 | // listen for a messages from the mixed content test harness |
michael@0 | 80 | window.addEventListener("message", receiveMessage, false); |
michael@0 | 81 | function receiveMessage(event) { |
michael@0 | 82 | if(firstTest) { |
michael@0 | 83 | log("blockDisplay set to "+blockDisplay+", blockActive set to "+blockActive+"."); |
michael@0 | 84 | firstTest = false; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | log("test: "+event.data.test+", msg: "+event.data.msg + " logging message."); |
michael@0 | 88 | // test that the load type matches the pref for this type of content |
michael@0 | 89 | // (i.e. active vs. display) |
michael@0 | 90 | |
michael@0 | 91 | switch(event.data.test) { |
michael@0 | 92 | |
michael@0 | 93 | /* Mixed Script tests */ |
michael@0 | 94 | case "about": |
michael@0 | 95 | ok(event.data.msg == "resource with about protocol loaded", "resource with about protocol did not load"); |
michael@0 | 96 | testsToRun["about"] = true; |
michael@0 | 97 | break; |
michael@0 | 98 | |
michael@0 | 99 | case "resource": |
michael@0 | 100 | ok(event.data.msg == "resource with resource protocol loaded", "resource with resource protocol did not load"); |
michael@0 | 101 | testsToRun["resource"] = true; |
michael@0 | 102 | break; |
michael@0 | 103 | |
michael@0 | 104 | case "mozicon": |
michael@0 | 105 | ok(event.data.msg == "resource with mozicon protocol loaded", "resource with mozicon protocol did not load"); |
michael@0 | 106 | testsToRun["mozicon"] = true; |
michael@0 | 107 | break; |
michael@0 | 108 | |
michael@0 | 109 | case "unsafe_about": |
michael@0 | 110 | // This one should not load |
michael@0 | 111 | ok(event.data.msg == "resource with unsafe about protocol did not load", "resource with unsafe about protocol loaded"); |
michael@0 | 112 | testsToRun["unsafe_about"] = true; |
michael@0 | 113 | break; |
michael@0 | 114 | |
michael@0 | 115 | case "data_protocol": |
michael@0 | 116 | ok(event.data.msg == "resource with data protocol loaded", "resource with data protocol did not load"); |
michael@0 | 117 | testsToRun["data_protocol"] = true; |
michael@0 | 118 | break; |
michael@0 | 119 | |
michael@0 | 120 | case "javascript": |
michael@0 | 121 | ok(event.data.msg == "resource with javascript protocol loaded", "resource with javascript protocol did not load"); |
michael@0 | 122 | testsToRun["javascript"] = true; |
michael@0 | 123 | break; |
michael@0 | 124 | |
michael@0 | 125 | case "wss": |
michael@0 | 126 | ok(event.data.msg == "resource with wss protocol loaded", "resource with wss protocol did not load"); |
michael@0 | 127 | testsToRun["wss"] = true; |
michael@0 | 128 | break; |
michael@0 | 129 | |
michael@0 | 130 | case "mailto": |
michael@0 | 131 | ok(event.data.msg == "resource with mailto protocol loaded", "resource with mailto protocol did not load"); |
michael@0 | 132 | testsToRun["mailto"] = true; |
michael@0 | 133 | break; |
michael@0 | 134 | } |
michael@0 | 135 | checkTestsCompleted(); |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 139 | </script> |
michael@0 | 140 | </head> |
michael@0 | 141 | |
michael@0 | 142 | <body> |
michael@0 | 143 | <div id="framediv"> |
michael@0 | 144 | <iframe id="testHarness" src="https://example.com/tests/content/base/test/file_mixed_content_main_bug803225.html"></iframe> |
michael@0 | 145 | </div> |
michael@0 | 146 | <pre id="log"></pre> |
michael@0 | 147 | </body> |
michael@0 | 148 | </html> |