js/xpconnect/tests/mochitest/test_bug916945.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/mochitest/test_bug916945.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=916945
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 916945</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <script type="application/javascript">
    1.15 +
    1.16 +  /** Test for Bug 916945 **/
    1.17 +  SimpleTest.waitForExplicitFinish();
    1.18 +
    1.19 +  var gLoadCount = 0;
    1.20 +  function loaded() {
    1.21 +    if (++gLoadCount == 2)
    1.22 +      go();
    1.23 +  }
    1.24 +  function go() {
    1.25 +    // Both same-origin and cross-origin names should be visible if they're set
    1.26 +    // on the iframe element.
    1.27 +    ok('winA' in window, "same-origin named access works");
    1.28 +    ok(winA instanceof Window, "same-origin named access works");
    1.29 +    ok('winB' in window, "cross-origin named access works when iframe name matches");
    1.30 +    // XXXbholley - flip me when Window moves to new bindings.
    1.31 +    todo_is(winB instanceof Window, "cross-origin named access works when iframe name matches");
    1.32 +
    1.33 +    // Setting the 'name' attribute should propagate to the docshell.
    1.34 +    var ifrB = document.getElementById('ifrB');
    1.35 +    ifrB.setAttribute('name', 'foo');
    1.36 +    is(SpecialPowers.wrap(ifrB).contentWindow.name, 'foo', 'attribute sets propagate to the docshell');
    1.37 +    ok('foo' in window, "names are dynamic if updated via setAttribute");
    1.38 +    // XXXbholley - flip me when Window moves to new bindings.
    1.39 +    todo('foo' instanceof Window, "names are dynamic if updated via setAttribute");
    1.40 +
    1.41 +    // Setting window.name on the subframe should not propagate to the attribute.
    1.42 +    SpecialPowers.wrap(ifrB).contentWindow.name = 'bar';
    1.43 +    is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute');
    1.44 +
    1.45 +    // When the frame element attribute and docshell name don't match, nothing is returned.
    1.46 +    ok(!('foo' in window), "frame element name not resolved if it doesn't match the docshell");
    1.47 +    ok(!('bar' in window), "docshell name not resolved if it doesn't match the frame element");
    1.48 +
    1.49 +    SimpleTest.finish();
    1.50 +  }
    1.51 +
    1.52 +  </script>
    1.53 +</head>
    1.54 +<body>
    1.55 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=916945">Mozilla Bug 916945</a>
    1.56 +<p id="display"></p>
    1.57 +<div id="content" style="display: none">
    1.58 +
    1.59 +</div>
    1.60 +<iframe id="ifrA" name="winA" onload="loaded();" src="file_empty.html"></iframe>
    1.61 +<iframe id="ifrB" name="winB" onload="loaded();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
    1.62 +<pre id="test">
    1.63 +</pre>
    1.64 +</body>
    1.65 +</html>

mercurial