summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/mochitest/test_nac.xhtml
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/xpconnect/tests/mochitest/test_nac.xhtml
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
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>