Sat, 03 Jan 2015 20:18:00 +0100
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=622245 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for untrusted keypress events</title> |
michael@0 | 8 | <script type="application/javascript" src="/MochiKit/packed.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=622245">Mozilla Bug 622245</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | <input id="i"><br> |
michael@0 | 17 | <textarea id="t"></textarea><br> |
michael@0 | 18 | <div id="d" contenteditable style="min-height: 1em;"></div> |
michael@0 | 19 | </div> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <script type="application/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | /** Test for Bug 674770 **/ |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | |
michael@0 | 26 | var input = document.getElementById("i"); |
michael@0 | 27 | var textarea = document.getElementById("t"); |
michael@0 | 28 | var div = document.getElementById("d"); |
michael@0 | 29 | |
michael@0 | 30 | addLoadEvent(function() { |
michael@0 | 31 | input.focus(); |
michael@0 | 32 | |
michael@0 | 33 | SimpleTest.executeSoon(function() { |
michael@0 | 34 | input.addEventListener("keypress", |
michael@0 | 35 | function(aEvent) { |
michael@0 | 36 | input.removeEventListener("keypress", arguments.callee, false); |
michael@0 | 37 | is(aEvent.target, input, |
michael@0 | 38 | "The keypress event target isn't the input element"); |
michael@0 | 39 | |
michael@0 | 40 | SimpleTest.executeSoon(function() { |
michael@0 | 41 | is(input.value, "", |
michael@0 | 42 | "Did keypress event cause modifying the input element?"); |
michael@0 | 43 | textarea.focus(); |
michael@0 | 44 | SimpleTest.executeSoon(runTextareaTest); |
michael@0 | 45 | }); |
michael@0 | 46 | }, false); |
michael@0 | 47 | var keypress = document.createEvent("KeyboardEvent"); |
michael@0 | 48 | keypress.initKeyEvent("keypress", true, true, document.defaultView, |
michael@0 | 49 | false, false, false, false, 0, "a".charCodeAt(0)); |
michael@0 | 50 | input.dispatchEvent(keypress); |
michael@0 | 51 | }); |
michael@0 | 52 | }); |
michael@0 | 53 | |
michael@0 | 54 | function runTextareaTest() |
michael@0 | 55 | { |
michael@0 | 56 | textarea.addEventListener("keypress", |
michael@0 | 57 | function(aEvent) { |
michael@0 | 58 | textarea.removeEventListener("keypress", arguments.callee, false); |
michael@0 | 59 | is(aEvent.target, textarea, |
michael@0 | 60 | "The keypress event target isn't the textarea element"); |
michael@0 | 61 | |
michael@0 | 62 | SimpleTest.executeSoon(function() { |
michael@0 | 63 | is(textarea.value, "", |
michael@0 | 64 | "Did keypress event cause modifying the textarea element?"); |
michael@0 | 65 | div.focus(); |
michael@0 | 66 | SimpleTest.executeSoon(runContentediableTest); |
michael@0 | 67 | }); |
michael@0 | 68 | }, false); |
michael@0 | 69 | var keypress = document.createEvent("KeyboardEvent"); |
michael@0 | 70 | keypress.initKeyEvent("keypress", true, true, document.defaultView, |
michael@0 | 71 | false, false, false, false, 0, "b".charCodeAt(0)); |
michael@0 | 72 | textarea.dispatchEvent(keypress); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function runContentediableTest() |
michael@0 | 76 | { |
michael@0 | 77 | div.addEventListener("keypress", |
michael@0 | 78 | function(aEvent) { |
michael@0 | 79 | div.removeEventListener("keypress", arguments.callee, false); |
michael@0 | 80 | is(aEvent.target, div, |
michael@0 | 81 | "The keypress event target isn't the div element"); |
michael@0 | 82 | |
michael@0 | 83 | SimpleTest.executeSoon(function() { |
michael@0 | 84 | is(div.innerHTML, "", |
michael@0 | 85 | "Did keypress event cause modifying the div element?"); |
michael@0 | 86 | |
michael@0 | 87 | SimpleTest.finish(); |
michael@0 | 88 | }); |
michael@0 | 89 | }, false); |
michael@0 | 90 | var keypress = document.createEvent("KeyboardEvent"); |
michael@0 | 91 | keypress.initKeyEvent("keypress", true, true, document.defaultView, |
michael@0 | 92 | false, false, false, false, 0, "c".charCodeAt(0)); |
michael@0 | 93 | div.dispatchEvent(keypress); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | </script> |
michael@0 | 97 | </pre> |
michael@0 | 98 | </body> |
michael@0 | 99 | </html> |