content/html/document/test/test_bug172261.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/test/test_bug172261.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=172261
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 172261</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=172261">Mozilla Bug 172261</a>
    1.16 +<p id="display">
    1.17 +  <iframe id="test"></iframe>
    1.18 +</p>
    1.19 +<div id="content" style="display: none">
    1.20 +  
    1.21 +</div>
    1.22 +<pre id="test">
    1.23 +<script class="testbody" type="text/javascript">
    1.24 +  /** Test for Bug 172261 **/
    1.25 +  SimpleTest.waitForExplicitFinish();
    1.26 +
    1.27 +  var callable = false;
    1.28 +  function toggleCallable() { callable = true; }
    1.29 +
    1.30 +  var doTestInIframe = false;
    1.31 +
    1.32 +  // Shouldn't do history stuff from inside onload
    1.33 +  addLoadEvent(function() { setTimeout(startTest, 10) });
    1.34 +
    1.35 +  function startTest() {
    1.36 +    // First, create a dummy document.  Use onunload handlers to make sure
    1.37 +    // bfcache doesn't screw us up.
    1.38 +    var doc = $("test").contentDocument;
    1.39 +    
    1.40 +    doc.write("<html><body onunload=''>First</body></html>");
    1.41 +    doc.close();
    1.42 +
    1.43 +    // Now write our test document
    1.44 +    doc.write("<html><script>window.onerror = parent.onerror; if (parent.doTestInIframe) { parent.is(document.domain, parent.document.domain, 'Domains should match');  parent.toggleCallable(); } <"  + "/script><body>Second</body></html>");
    1.45 +    doc.close();
    1.46 +
    1.47 +    $("test").onload = goForward;
    1.48 +    history.back();
    1.49 +  }
    1.50 +
    1.51 +  function goForward() {
    1.52 +      $("test").onload = doTest;
    1.53 +      doTestInIframe = true;
    1.54 +      history.forward();
    1.55 +  }
    1.56 +
    1.57 +  function doTest() {
    1.58 +    is($("test").contentDocument.domain, document.domain,
    1.59 +       "Domains should match 2");
    1.60 +    is($("test").contentDocument.location.href, location.href,
    1.61 +         "Locations should match");
    1.62 +    is(callable, true, "Subframe should be able to call us");
    1.63 +    SimpleTest.finish();
    1.64 +  }
    1.65 +</script>
    1.66 +</pre>
    1.67 +</body>
    1.68 +</html>
    1.69 +

mercurial