js/xpconnect/tests/mochitest/test_nac.xhtml

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4529126904ed
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=914618
4 -->
5 <head>
6 <title>Test for Bug 914618</title>
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
9 <bindings xmlns="http://www.mozilla.org/xbl"
10 xmlns:html="http://www.w3.org/1999/xhtml">
11 <binding id="testBinding" chromeOnlyContent="true">
12 <!-- The root of the anonymous subtree is special, and is not allowed to
13 be adopted, among other things. Work with a child of the root. -->
14 <content><html:div><html:span id="nac">hidden text</html:span></html:div></content>
15 <implementation>
16 <constructor>
17 var win = XPCNativeWrapper.unwrap(window);
18 var nac = document.getAnonymousNodes(this)[0].firstChild;
19 win.is(nac.textContent, "hidden text", "XBL can see NAC");
20 win.playWithNAC(nac);
21 </constructor>
22 </implementation>
23 </binding>
24 </bindings>
25 <script type="application/javascript">
26 <![CDATA[
27
28 /** Test for Bug 914618 **/
29 SimpleTest.waitForExplicitFinish();
30
31 function checkThrows(fn) {
32 try {
33 fn();
34 ok(false, "Should have thrown");
35 } catch (e) {
36 ok(/denied|insecure|/.test(e), "Should have thrown security error");
37 }
38 }
39
40 function playWithNAC(nac) {
41 checkThrows(function() { nac.toString(); });
42 checkThrows(function() { nac.textContent; });
43 var iwin = document.getElementById('ifr').contentWindow;
44 iwin.nac = window.nac = nac;
45 checkThrows(new iwin.Function('nac.toString();'));
46 checkThrows(new iwin.Function('nac.textContent;'));
47
48 SimpleTest.finish();
49 }
50
51 ]]>
52 </script>
53 </head>
54 <body>
55 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=914618">Mozilla Bug 914618</a>
56 <p id="display"></p>
57 <div id="content" style="display: none">
58 </div>
59 <div id="bindingSink" style="-moz-binding: url(#testBinding);"></div>
60 <iframe id="ifr"></iframe>
61 <pre id="test">
62 </pre>
63 </body>
64 </html>

mercurial