js/xpconnect/tests/mochitest/test_bug505915.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/mochitest/test_bug505915.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=505915
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 505915</title>
    1.11 +  <script type="application/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=505915">Mozilla Bug 505915</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script type="application/javascript;version=1.7">
    1.22 +
    1.23 +/** Test for Bug 505915 **/
    1.24 +window.addEventListener("message", function () { gen.next() }, false);
    1.25 +
    1.26 +function go() {
    1.27 +    var ifr = $('ifr');
    1.28 +    try {
    1.29 +        // NB: the contentDocument getter now returns null for cross-origin
    1.30 +        // frames, so use SpecialPowers to get a security wrapper to the document.
    1.31 +        var xdoc = SpecialPowers.unwrap(SpecialPowers.wrap(ifr).contentDocument)
    1.32 +        document.createTreeWalker(xdoc, 0, null);
    1.33 +        ok(false, "should have thrown a security exception");
    1.34 +    } catch (e) {
    1.35 +        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
    1.36 +           /TypeError: Argument 1 of Document.createTreeWalker does not implement interface Node/.test(e),
    1.37 +           "threw a security exception or binding exception instead of an " +
    1.38 +           "invalid child exception");
    1.39 +    }
    1.40 +
    1.41 +    SimpleTest.finish();
    1.42 +    yield;
    1.43 +}
    1.44 +
    1.45 +SimpleTest.waitForExplicitFinish();
    1.46 +
    1.47 +</script>
    1.48 +</pre>
    1.49 +
    1.50 +<iframe id="ifr" onload="gen = go(); gen.next();" src="http://example.org/"></iframe>
    1.51 +
    1.52 +</body>
    1.53 +</html>

mercurial