content/base/test/file_mixed_content_frameNavigation.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/file_mixed_content_frameNavigation.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +Tests for Mixed Content Blocker related to navigating children, grandchildren, etc
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=840388
     1.9 +-->
    1.10 +<head>
    1.11 +  <meta charset="utf-8">
    1.12 +  <title>Tests for Mixed Content Frame Navigation</title>
    1.13 +</head>
    1.14 +<body>
    1.15 +<div id="testContent"></div>
    1.16 +
    1.17 +<script>
    1.18 +  var baseUrlHttps = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html";
    1.19 +
    1.20 +  // For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
    1.21 +  var MAX_COUNT = 50;
    1.22 +  var TIMEOUT_INTERVAL = 100;
    1.23 +
    1.24 +  var testContent = document.getElementById("testContent");
    1.25 +
    1.26 +  // Test 1: Navigate secure iframe to insecure iframe on an insecure page
    1.27 +  var iframe_test1 = document.createElement("iframe");
    1.28 +  var counter_test1 = 0;
    1.29 +  iframe_test1.src = baseUrlHttps + "?insecurePage_navigate_child";
    1.30 +  iframe_test1.setAttribute("id", "test1");
    1.31 +  iframe_test1.onerror = function() {
    1.32 +    parent.postMessage({"test": "insecurePage_navigate_child", "msg": "got an onerror alert when loading or navigating testing iframe"}, "http://mochi.test:8888");
    1.33 +  };
    1.34 +  testContent.appendChild(iframe_test1);
    1.35 +
    1.36 +  function navigationStatus(iframe_test1)
    1.37 +  {
    1.38 +    // When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
    1.39 +    // Catch that specific exception and return
    1.40 +    try {
    1.41 +      var loc = document.getElementById("test1").contentDocument.location;
    1.42 +    } catch(e) {
    1.43 +      if (e.name === "SecurityError") {
    1.44 +        // We received an exception we didn't expect.
    1.45 +        throw e;
    1.46 +      }
    1.47 +      counter_test1++;
    1.48 +      return;
    1.49 +    }
    1.50 +    if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_child_response") {
    1.51 +      return;
    1.52 +    }
    1.53 +    else {
    1.54 +      if(counter_test1 < MAX_COUNT) {
    1.55 +        counter_test1++;
    1.56 +        setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
    1.57 +      }
    1.58 +      else {
    1.59 +        // After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
    1.60 +        parent.postMessage({"test": "insecurePage_navigate_child", "msg": "navigating to insecure iframe blocked on insecure page"}, "http://mochi.test:8888");
    1.61 +      }
    1.62 +    }
    1.63 +  }
    1.64 +
    1.65 +  setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
    1.66 +
    1.67 +  // Test 2: Navigate secure grandchild iframe to insecure grandchild iframe on a page that has no secure parents
    1.68 +  var iframe_test2 = document.createElement("iframe");
    1.69 +  iframe_test2.src = "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_grandchild.html"
    1.70 +  iframe_test2.onerror = function() {
    1.71 +    parent.postMessage({"test": "insecurePage_navigate_grandchild", "msg": "got an on error alert when loading or navigating testing iframe"}, "http://mochi.test:8888");
    1.72 +  };
    1.73 +  testContent.appendChild(iframe_test2);
    1.74 +
    1.75 +</script>
    1.76 +</body>
    1.77 +</html>

mercurial