content/base/test/file_mixed_content_frameNavigation_secure.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

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 <!--
michael@0 4 Tests for Mixed Content Blocker related to navigating children, grandchildren, etc
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=840388
michael@0 6 -->
michael@0 7 <head>
michael@0 8 <meta charset="utf-8">
michael@0 9 <title>Tests for Mixed Content Frame Navigation</title>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <div id="testContent"></div>
michael@0 13
michael@0 14 <script>
michael@0 15 var baseUrl = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html";
michael@0 16
michael@0 17 // For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
michael@0 18 var MAX_COUNT = 50;
michael@0 19 var TIMEOUT_INTERVAL = 100;
michael@0 20
michael@0 21 var testContent = document.getElementById("testContent");
michael@0 22
michael@0 23 // Test 1: Navigate secure iframe to insecure iframe on a secure page
michael@0 24 var iframe_test1 = document.createElement("iframe");
michael@0 25 var counter_test1 = 0;
michael@0 26 iframe_test1.setAttribute("id", "test1");
michael@0 27 iframe_test1.src = baseUrl + "?securePage_navigate_child";
michael@0 28 iframe_test1.onerror = function() {
michael@0 29 parent.postMessage({"test": "securePage_navigate_child", "msg": "got an onerror event when loading or navigating testing iframe"}, "http://mochi.test:8888");
michael@0 30 };
michael@0 31 testContent.appendChild(iframe_test1);
michael@0 32
michael@0 33 function navigationStatus(iframe_test1)
michael@0 34 {
michael@0 35 // When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
michael@0 36 // Catch that specific exception and return
michael@0 37 try {
michael@0 38 var loc = document.getElementById("test1").contentDocument.location;
michael@0 39 } catch(e) {
michael@0 40 if (e.name === "SecurityError") {
michael@0 41 // We received an exception we didn't expect.
michael@0 42 throw e;
michael@0 43 }
michael@0 44 counter_test1++;
michael@0 45 return;
michael@0 46 }
michael@0 47 if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_child_response") {
michael@0 48 return;
michael@0 49 } else {
michael@0 50 if(counter_test1 < MAX_COUNT) {
michael@0 51 counter_test1++;
michael@0 52 setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
michael@0 53 }
michael@0 54 else {
michael@0 55 // After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
michael@0 56 parent.postMessage({"test": "securePage_navigate_child", "msg": "navigating to insecure iframe blocked on secure page"}, "http://mochi.test:8888");
michael@0 57 }
michael@0 58 }
michael@0 59 }
michael@0 60
michael@0 61 setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
michael@0 62
michael@0 63 // Test 2: Open an http page in a new tab from a link click with target=_blank.
michael@0 64 var iframe_test3 = document.createElement("iframe");
michael@0 65 iframe_test3.src = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_blankTarget.html";
michael@0 66 iframe_test3.onerror = function() {
michael@0 67 parent.postMessage({"test": "blankTarget", "msg": "got an onerror event when loading or navigating testing iframe"}, "http://mochi.test:8888");
michael@0 68 };
michael@0 69 testContent.appendChild(iframe_test3);
michael@0 70
michael@0 71 </script>
michael@0 72 </body>
michael@0 73 </html>

mercurial