js/xpconnect/tests/mochitest/test_getWebIDLCaller.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/mochitest/test_getWebIDLCaller.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=968335
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 968335</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 Cu.getCallerPrincipal (within JS-implemented WebIDL). **/
    1.17 +
    1.18 +  SimpleTest.waitForExplicitFinish();
    1.19 +  SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
    1.20 +
    1.21 +
    1.22 +  function go() {
    1.23 +    var t = new TestInterfaceJS();
    1.24 +    is(t.getCallerPrincipal(), location.origin,
    1.25 +       "Cu.getCallerPrincipal works right within JS-implemented WebIDL");
    1.26 +
    1.27 +    try {
    1.28 +      SpecialPowers.Cu.getWebIDLCallerPrincipal();
    1.29 +      ok(false, "Should have thrown");
    1.30 +    } catch (e) {
    1.31 +      ok(/NOT_AVAILABLE/.test(SpecialPowers.wrap(e)),
    1.32 +         "API should throw when invoked outside of JS-implemented WebIDL");
    1.33 +    }
    1.34 +
    1.35 +    SimpleTest.finish();
    1.36 +  }
    1.37 +
    1.38 +
    1.39 +
    1.40 +
    1.41 +  </script>
    1.42 +</head>
    1.43 +<body>
    1.44 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968335">Mozilla Bug 968335</a>
    1.45 +<p id="display"></p>
    1.46 +<div id="content" style="display: none">
    1.47 +
    1.48 +</div>
    1.49 +<pre id="test">
    1.50 +</pre>
    1.51 +</body>
    1.52 +</html>

mercurial