js/xpconnect/tests/mochitest/test_nac.xhtml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial