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 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Testing of isFromUserInput in text events</title> |
michael@0 | 5 | |
michael@0 | 6 | <link rel="stylesheet" type="text/css" |
michael@0 | 7 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="../common.js"></script> |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="../events.js"></script> |
michael@0 | 18 | |
michael@0 | 19 | <script type="application/javascript"> |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * Remove text data from HTML input. |
michael@0 | 23 | */ |
michael@0 | 24 | function removeTextFromInput(aID, aStart, aEnd, aText, aFromUser) |
michael@0 | 25 | { |
michael@0 | 26 | this.DOMNode = getNode(aID); |
michael@0 | 27 | |
michael@0 | 28 | this.eventSeq = [ |
michael@0 | 29 | new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser) |
michael@0 | 30 | ]; |
michael@0 | 31 | |
michael@0 | 32 | this.invoke = function removeTextFromInput_invoke() |
michael@0 | 33 | { |
michael@0 | 34 | const nsIDOMNSEditableElement = |
michael@0 | 35 | Components.interfaces.nsIDOMNSEditableElement; |
michael@0 | 36 | |
michael@0 | 37 | this.DOMNode.focus(); |
michael@0 | 38 | this.DOMNode.setSelectionRange(aStart, aEnd); |
michael@0 | 39 | |
michael@0 | 40 | synthesizeKey("VK_DELETE", {}); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | this.getID = function removeTextFromInput_getID() |
michael@0 | 44 | { |
michael@0 | 45 | return "Remove text from " + aStart + " to " + aEnd + " for " + |
michael@0 | 46 | prettyName(aID); |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Remove text data from text node. |
michael@0 | 52 | */ |
michael@0 | 53 | function removeTextFromContentEditable(aID, aStart, aEnd, aText, aFromUser) |
michael@0 | 54 | { |
michael@0 | 55 | this.DOMNode = getNode(aID); |
michael@0 | 56 | |
michael@0 | 57 | this.eventSeq = [ |
michael@0 | 58 | new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser) |
michael@0 | 59 | ]; |
michael@0 | 60 | |
michael@0 | 61 | this.invoke = function removeTextFromContentEditable_invoke() |
michael@0 | 62 | { |
michael@0 | 63 | const nsIDOMNSEditableElement = |
michael@0 | 64 | Components.interfaces.nsIDOMNSEditableElement; |
michael@0 | 65 | |
michael@0 | 66 | this.DOMNode.focus(); |
michael@0 | 67 | this.textNode = getNode(aID).firstChild; |
michael@0 | 68 | var selection = window.getSelection(); |
michael@0 | 69 | var range = document.createRange(); |
michael@0 | 70 | range.setStart(this.textNode, aStart); |
michael@0 | 71 | range.setEnd(this.textNode, aEnd); |
michael@0 | 72 | selection.addRange(range); |
michael@0 | 73 | |
michael@0 | 74 | synthesizeKey("VK_DELETE", {}); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | this.getID = function removeTextFromContentEditable_getID() |
michael@0 | 78 | { |
michael@0 | 79 | return "Remove text from " + aStart + " to " + aEnd + " for " + |
michael@0 | 80 | prettyName(aID); |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 85 | // Do tests |
michael@0 | 86 | // gA11yEventDumpID = "eventdump"; // debug stuff |
michael@0 | 87 | |
michael@0 | 88 | var gQueue = null; |
michael@0 | 89 | |
michael@0 | 90 | function doTests() |
michael@0 | 91 | { |
michael@0 | 92 | gQueue = new eventQueue(); |
michael@0 | 93 | |
michael@0 | 94 | // Focused editable text node |
michael@0 | 95 | gQueue.push(new removeTextFromContentEditable("div", 0, 3, "hel", true)); |
michael@0 | 96 | |
michael@0 | 97 | // Focused editable HTML input |
michael@0 | 98 | gQueue.push(new removeTextFromInput("input", 1, 2, "n", true)); |
michael@0 | 99 | |
michael@0 | 100 | gQueue.invoke(); // Will call SimpleTest.finish() |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 104 | addA11yLoadEvent(doTests); |
michael@0 | 105 | |
michael@0 | 106 | </script> |
michael@0 | 107 | </head> |
michael@0 | 108 | |
michael@0 | 109 | |
michael@0 | 110 | <body> |
michael@0 | 111 | <a target="_blank" |
michael@0 | 112 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=686909" |
michael@0 | 113 | title="isFromUserInput flag on accessible text change events not correct"> |
michael@0 | 114 | Mozilla Bug 686909 |
michael@0 | 115 | </a> |
michael@0 | 116 | |
michael@0 | 117 | <p id="display"></p> |
michael@0 | 118 | <div id="content" style="display: none"></div> |
michael@0 | 119 | <pre id="test"></pre> |
michael@0 | 120 | <div id="eventdump"></div> |
michael@0 | 121 | |
michael@0 | 122 | <div id="div" contentEditable="true">hello</div> |
michael@0 | 123 | <input id="input" value="input"> |
michael@0 | 124 | |
michael@0 | 125 | </body> |
michael@0 | 126 | |
michael@0 | 127 | </html> |