content/base/test/file_mixed_content_frameNavigation_secure.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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

mercurial