js/jsd/test/test_bug507448.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=507448
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 507448</title>
michael@0 8 <script type="application/javascript" src="/MochiKit/Base.js"></script>
michael@0 9 <script type="application/javascript" src="/MochiKit/Async.js"></script>
michael@0 10 <script type="application/javascript" src="/MochiKit/DOM.js"></script>
michael@0 11 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 13 </head>
michael@0 14 <body>
michael@0 15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=507448">Mozilla Bug 507448</a>
michael@0 16 <p id="display"></p>
michael@0 17 <div id="content" style="display: none">
michael@0 18
michael@0 19 </div>
michael@0 20 <pre id="test">
michael@0 21 <script type="application/javascript">
michael@0 22 function f() {}
michael@0 23 function g(a,b) {}
michael@0 24 function h(me, too, here) { var x = 1; }
michael@0 25 function annoying(a, b, a, b, b, a) {}
michael@0 26 function manyLocals(a, b, c, d, e, f, g, h, i, j, k, l, m) {
michael@0 27 var n, o, p, q, r, s, t, u, v, w, x, y, z;
michael@0 28 }
michael@0 29 </script>
michael@0 30 <script type="application/javascript">
michael@0 31
michael@0 32 SimpleTest.waitForExplicitFinish();
michael@0 33
michael@0 34 function loadScript(url) {
michael@0 35 var d = new MochiKit.Async.Deferred();
michael@0 36 var head = document.getElementsByTagName("head")[0];
michael@0 37 var script = MochiKit.DOM.createDOM("script", { type: "text/javascript", src: url });
michael@0 38 script.onload = function() {
michael@0 39 script.onload = null;
michael@0 40 script.onerror = null;
michael@0 41 script.onreadystatechange = null;
michael@0 42 d.callback();
michael@0 43 };
michael@0 44 script.onerror = function(msg) {
michael@0 45 script.onload = null;
michael@0 46 script.onerror = null;
michael@0 47 script.onreadystatechange = null;
michael@0 48 msg = "Failed to load script at " + url + ": " + msg;
michael@0 49 d.errback(new URIError(msg, url));
michael@0 50 }
michael@0 51 script.onreadystatechange = function() {
michael@0 52 if (script.readyState == "loaded" || script.readyState == "complete") {
michael@0 53 script.onload();
michael@0 54 } else {
michael@0 55 // IE doesn't bother to report errors...
michael@0 56 MochiKit.Async.callLater(10, script.onerror, "Script loading timed out")
michael@0 57 }
michael@0 58 };
michael@0 59 head.appendChild(script);
michael@0 60 return d;
michael@0 61 }
michael@0 62
michael@0 63 /** Test for Bug 507448 **/
michael@0 64 function assertArraysEqual(arr1, arr2) {
michael@0 65 is(arr1.length, arr2.length, "Lengths not equal");
michael@0 66 for (var i = 0 ; i < arr1.length; ++i) {
michael@0 67 is(arr1[i], arr2[i], "Element " + i + " not equal");
michael@0 68 }
michael@0 69 }
michael@0 70
michael@0 71 var jsdIDebuggerService = SpecialPowers.Ci.jsdIDebuggerService;
michael@0 72 var jsd = SpecialPowers.Cc['@mozilla.org/js/jsd/debugger-service;1']
michael@0 73 .getService(jsdIDebuggerService);
michael@0 74 var jsdOnAtStart = false;
michael@0 75
michael@0 76 function setupJSD() {
michael@0 77 // This is somewhat unfortunate: jsd only deals with scripts that have a
michael@0 78 // nonzero line number, so we can't just createElement a script here.
michael@0 79 // So break the test up into three <script>s, of which the middle one has our test functions.
michael@0 80
michael@0 81 jsdOnAtStart = jsd.isOn;
michael@0 82 if (jsdOnAtStart) {
michael@0 83 testJSD();
michael@0 84 } else {
michael@0 85 jsd.asyncOn(
michael@0 86 {
michael@0 87 onDebuggerActivated: function() {
michael@0 88 testJSD();
michael@0 89 }
michael@0 90 }
michael@0 91 );
michael@0 92 }
michael@0 93 }
michael@0 94
michael@0 95 addLoadEvent(setupJSD);
michael@0 96
michael@0 97 </script>
michael@0 98 <script>
michael@0 99 function testJSD() {
michael@0 100 ok(jsd.isOn, "JSD needs to be running for this test.");
michael@0 101
michael@0 102 var deferred = loadScript("bug507448.js");
michael@0 103 }
michael@0 104 </script>
michael@0 105 </pre>
michael@0 106 </body>
michael@0 107 </html>

mercurial