editor/composer/test/test_bug519928.html

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 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=519928
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 519928</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=519928">Mozilla Bug 519928</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content">
michael@0 15 <iframe id="load-frame"></iframe>
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script class="testbody" type="text/javascript">
michael@0 19
michael@0 20 var iframe = document.getElementById("load-frame");
michael@0 21
michael@0 22 function enableJS() allowJS(true, iframe);
michael@0 23 function disableJS() allowJS(false, iframe);
michael@0 24 function allowJS(allow, frame) {
michael@0 25 SpecialPowers.wrap(frame.contentWindow)
michael@0 26 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
michael@0 27 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
michael@0 28 .QueryInterface(SpecialPowers.Ci.nsIDocShell)
michael@0 29 .allowJavascript = allow;
michael@0 30 }
michael@0 31 function expectJSAllowed(allowed, testCondition, callback) {
michael@0 32 window.ICanRunMyJS = false;
michael@0 33 var self_ = window;
michael@0 34 testCondition();
michael@0 35
michael@0 36 var doc = iframe.contentDocument;
michael@0 37 doc.body.innerHTML = "<iframe></iframe>";
michael@0 38 var innerFrame = doc.querySelector("iframe");
michael@0 39 innerFrame.addEventListener("load", function() {
michael@0 40 innerFrame.removeEventListener("load", arguments.callee, false);
michael@0 41
michael@0 42 var msg = "The inner iframe should" + (allowed ? "" : " not") + " be able to run Javascript";
michael@0 43 is(self_.ICanRunMyJS, allowed, msg);
michael@0 44 callback();
michael@0 45 }, false);
michael@0 46 var iframeSrc = "data:text/html,<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
michael@0 47 innerFrame.src = iframeSrc;
michael@0 48 }
michael@0 49
michael@0 50 SimpleTest.waitForExplicitFinish();
michael@0 51 addLoadEvent(function() {
michael@0 52 var enterDesignMode = function() document.designMode = "on";
michael@0 53 var leaveDesignMode = function() document.designMode = "off";
michael@0 54 expectJSAllowed(false, disableJS, function() {
michael@0 55 expectJSAllowed(true, enableJS, function() {
michael@0 56 expectJSAllowed(true, enterDesignMode, function() {
michael@0 57 expectJSAllowed(true, leaveDesignMode, function() {
michael@0 58 expectJSAllowed(false, disableJS, function() {
michael@0 59 expectJSAllowed(false, enterDesignMode, function() {
michael@0 60 expectJSAllowed(false, leaveDesignMode, function() {
michael@0 61 expectJSAllowed(true, enableJS, function() {
michael@0 62 enterDesignMode = function() iframe.contentDocument.designMode = "on";
michael@0 63 leaveDesignMode = function() iframe.contentDocument.designMode = "off";
michael@0 64 expectJSAllowed(false, disableJS, function() {
michael@0 65 expectJSAllowed(true, enableJS, function() {
michael@0 66 expectJSAllowed(true, enterDesignMode, function() {
michael@0 67 expectJSAllowed(true, leaveDesignMode, function() {
michael@0 68 expectJSAllowed(false, disableJS, function() {
michael@0 69 expectJSAllowed(false, enterDesignMode, function() {
michael@0 70 expectJSAllowed(false, leaveDesignMode, function() {
michael@0 71 expectJSAllowed(true, enableJS, function() {
michael@0 72 testDocumentDisabledJS();
michael@0 73 });
michael@0 74 });
michael@0 75 });
michael@0 76 });
michael@0 77 });
michael@0 78 });
michael@0 79 });
michael@0 80 });
michael@0 81 });
michael@0 82 });
michael@0 83 });
michael@0 84 });
michael@0 85 });
michael@0 86 });
michael@0 87 });
michael@0 88 });
michael@0 89 });
michael@0 90
michael@0 91 function testDocumentDisabledJS() {
michael@0 92 window.ICanRunMyJS = false;
michael@0 93 var self_ = window;
michael@0 94 // Ensure design modes are disabled
michael@0 95 document.designMode = "off";
michael@0 96 iframe.contentDocument.designMode = "off";
michael@0 97
michael@0 98 // Javascript enabled on the main iframe
michael@0 99 enableJS();
michael@0 100
michael@0 101 var doc = iframe.contentDocument;
michael@0 102 doc.body.innerHTML = "<iframe></iframe>";
michael@0 103 var innerFrame = doc.querySelector("iframe");
michael@0 104
michael@0 105 // Javascript disabled on the innerFrame.
michael@0 106 allowJS(false, innerFrame);
michael@0 107
michael@0 108 innerFrame.addEventListener("load", function() {
michael@0 109 innerFrame.removeEventListener("load", arguments.callee, false);
michael@0 110
michael@0 111 var msg = "The inner iframe should not be able to run Javascript";
michael@0 112 is(self_.ICanRunMyJS, false, msg);
michael@0 113 SimpleTest.finish();
michael@0 114 }, false);
michael@0 115 var iframeSrc = "data:text/html,<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
michael@0 116 innerFrame.src = iframeSrc;
michael@0 117 }
michael@0 118
michael@0 119 </script>
michael@0 120 </pre>
michael@0 121 </body>
michael@0 122 </html>
michael@0 123

mercurial