content/base/test/file_mixed_content_frameNavigation.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 baseUrlHttps = "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 an insecure page
    24   var iframe_test1 = document.createElement("iframe");
    25   var counter_test1 = 0;
    26   iframe_test1.src = baseUrlHttps + "?insecurePage_navigate_child";
    27   iframe_test1.setAttribute("id", "test1");
    28   iframe_test1.onerror = function() {
    29     parent.postMessage({"test": "insecurePage_navigate_child", "msg": "got an onerror alert 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     }
    50     else {
    51       if(counter_test1 < MAX_COUNT) {
    52         counter_test1++;
    53         setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
    54       }
    55       else {
    56         // After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
    57         parent.postMessage({"test": "insecurePage_navigate_child", "msg": "navigating to insecure iframe blocked on insecure page"}, "http://mochi.test:8888");
    58       }
    59     }
    60   }
    62   setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
    64   // Test 2: Navigate secure grandchild iframe to insecure grandchild iframe on a page that has no secure parents
    65   var iframe_test2 = document.createElement("iframe");
    66   iframe_test2.src = "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_grandchild.html"
    67   iframe_test2.onerror = function() {
    68     parent.postMessage({"test": "insecurePage_navigate_grandchild", "msg": "got an on error alert when loading or navigating testing iframe"}, "http://mochi.test:8888");
    69   };
    70   testContent.appendChild(iframe_test2);
    72 </script>
    73 </body>
    74 </html>

mercurial