summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/mochitest/test_nac.xhtml
diff options
context:
space:
mode:
Diffstat (limited to 'js/xpconnect/tests/mochitest/test_nac.xhtml')
-rw-r--r--js/xpconnect/tests/mochitest/test_nac.xhtml64
1 files changed, 64 insertions, 0 deletions
diff --git a/js/xpconnect/tests/mochitest/test_nac.xhtml b/js/xpconnect/tests/mochitest/test_nac.xhtml
new file mode 100644
index 000000000..0f18fe489
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_nac.xhtml
@@ -0,0 +1,64 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=914618
+-->
+<head>
+ <title>Test for Bug 914618</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="testBinding" chromeOnlyContent="true">
+ <!-- The root of the anonymous subtree is special, and is not allowed to
+ be adopted, among other things. Work with a child of the root. -->
+ <content><html:div><html:span id="nac">hidden text</html:span></html:div></content>
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ var nac = document.getAnonymousNodes(this)[0].firstChild;
+ win.is(nac.textContent, "hidden text", "XBL can see NAC");
+ win.playWithNAC(nac);
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 914618 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function checkThrows(fn) {
+ try {
+ fn();
+ ok(false, "Should have thrown");
+ } catch (e) {
+ ok(/denied|insecure|/.test(e), "Should have thrown security error");
+ }
+ }
+
+ function playWithNAC(nac) {
+ checkThrows(function() { nac.toString(); });
+ checkThrows(function() { nac.textContent; });
+ var iwin = document.getElementById('ifr').contentWindow;
+ iwin.nac = window.nac = nac;
+ checkThrows(new iwin.Function('nac.toString();'));
+ checkThrows(new iwin.Function('nac.textContent;'));
+
+ SimpleTest.finish();
+ }
+
+ ]]>
+</script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=914618">Mozilla Bug 914618</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<div id="bindingSink" style="-moz-binding: url(#testBinding);"></div>
+<iframe id="ifr"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>