docshell/test/navigation/test_reserved.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/navigation/test_reserved.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     1.8 +    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     1.9 +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +    <script type="text/javascript" src="NavigationUtils.js"></script>        
    1.11 +    <style type="text/css">
    1.12 +      iframe { width: 90%; height: 200px; }
    1.13 +    </style>
    1.14 +<script>
    1.15 +if (navigator.platform.startsWith("Mac")) {
    1.16 +  SimpleTest.expectAssertions(0, 2);
    1.17 +}
    1.18 +
    1.19 +function testTop() {
    1.20 +  window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10");
    1.21 +
    1.22 +  xpcWaitForFinishedFrames(function() {
    1.23 +    isInaccessible(window0, "Should be able to navigate off-domain top by setting location.");
    1.24 +    window0.close();
    1.25 +    xpcCleanupWindows();
    1.26 +
    1.27 +    window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10");
    1.28 +    
    1.29 +    xpcWaitForFinishedFrames(function() {
    1.30 +      isInaccessible(window1, "Should be able to navigate off-domain top by calling window.open.");
    1.31 +      window1.close();
    1.32 +      xpcCleanupWindows();
    1.33 +
    1.34 +      window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10");
    1.35 +
    1.36 +      xpcWaitForFinishedFrames(function() {
    1.37 +        isInaccessible(window2, "Should be able to navigate off-domain top by submitting form.");
    1.38 +        window2.close();
    1.39 +        xpcCleanupWindows();
    1.40 +
    1.41 +        window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10");
    1.42 +
    1.43 +        xpcWaitForFinishedFrames(function() {
    1.44 +          isInaccessible(window3, "Should be able to navigate off-domain top by targeted hyperlink.");
    1.45 +          window3.close();
    1.46 +          xpcCleanupWindows();
    1.47 +
    1.48 +          testParent();
    1.49 +        }, 1);
    1.50 +      }, 1);
    1.51 +    }, 1);
    1.52 +  }, 1);
    1.53 +}
    1.54 +
    1.55 +function testParent() {
    1.56 +  document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#parent,location"></iframe>';
    1.57 +
    1.58 +  xpcWaitForFinishedFrames(function() {
    1.59 +    isAccessible(frames[0], "Should not be able to navigate off-domain parent by setting location.");
    1.60 +    xpcCleanupWindows();
    1.61 +
    1.62 +    document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,open"></iframe>';
    1.63 +
    1.64 +    xpcWaitForFinishedFrames(function() {
    1.65 +      isAccessible(frames[0], "Should not be able to navigate off-domain parent by calling window.open.");
    1.66 +      xpcCleanupWindows();
    1.67 +
    1.68 +      document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,form"></iframe>';
    1.69 +
    1.70 +      xpcWaitForFinishedFrames(function() {
    1.71 +        isAccessible(frames[0], "Should not be able to navigate off-domain parent by submitting form.");
    1.72 +        xpcCleanupWindows();
    1.73 +
    1.74 +        document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,hyperlink"></iframe>';
    1.75 +
    1.76 +        xpcWaitForFinishedFrames(function() {
    1.77 +          isAccessible(frames[0], "Should not be able to navigate off-domain parent by targeted hyperlink.");
    1.78 +          xpcCleanupWindows();
    1.79 +
    1.80 +          document.getElementById("frames").innerHTML = "";
    1.81 +          SimpleTest.finish();
    1.82 +        }, 1);
    1.83 +      }, 1);
    1.84 +    }, 1);
    1.85 +  }, 1);
    1.86 +}
    1.87 +
    1.88 +window.onload = function() {
    1.89 +  testTop();
    1.90 +}
    1.91 +</script>
    1.92 +</head>
    1.93 +<body>
    1.94 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408052">Mozilla Bug 408052</a>
    1.95 +<div id="frames">
    1.96 +</div>
    1.97 +<pre id="test">
    1.98 +<script type="text/javascript">
    1.99 +SimpleTest.waitForExplicitFinish();
   1.100 +</script>
   1.101 +</pre>
   1.102 +</body>
   1.103 +</html>

mercurial