Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=605124 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 605124</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.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=605124">Mozilla Bug 605124</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | <input required> |
michael@0 | 17 | <textarea required></textarea> |
michael@0 | 18 | <select required> |
michael@0 | 19 | <option value="">foo</option> |
michael@0 | 20 | <option>bar</option> |
michael@0 | 21 | </select> |
michael@0 | 22 | <select multiple required> |
michael@0 | 23 | <option value="">foo</option> |
michael@0 | 24 | <option>bar</option> |
michael@0 | 25 | </select> |
michael@0 | 26 | </div> |
michael@0 | 27 | <pre id="test"> |
michael@0 | 28 | <script type="application/javascript"> |
michael@0 | 29 | |
michael@0 | 30 | /** Test for Bug 605124 **/ |
michael@0 | 31 | |
michael@0 | 32 | function checkPseudoClass(aElement, aExpected) |
michael@0 | 33 | { |
michael@0 | 34 | is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aExpected, |
michael@0 | 35 | "mozMatchesSelector(':-moz-ui-invalid') should return " + aExpected + " for " + aElement); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function checkElement(aElement) |
michael@0 | 39 | { |
michael@0 | 40 | checkPseudoClass(aElement, false); |
michael@0 | 41 | |
michael@0 | 42 | // Focusing while :-moz-ui-invalid doesn't apply, |
michael@0 | 43 | // the pseudo-class should not apply while typing. |
michael@0 | 44 | aElement.focus(); |
michael@0 | 45 | checkPseudoClass(aElement, false); |
michael@0 | 46 | // with keys |
michael@0 | 47 | synthesizeKey('f', {}); |
michael@0 | 48 | checkPseudoClass(aElement, false); |
michael@0 | 49 | synthesizeKey('VK_BACK_SPACE', {}); |
michael@0 | 50 | checkPseudoClass(aElement, false); |
michael@0 | 51 | // with .value |
michael@0 | 52 | aElement.value = 'f'; |
michael@0 | 53 | checkPseudoClass(aElement, false); |
michael@0 | 54 | aElement.value = ''; |
michael@0 | 55 | checkPseudoClass(aElement, false); |
michael@0 | 56 | |
michael@0 | 57 | aElement.blur(); |
michael@0 | 58 | checkPseudoClass(aElement, true); |
michael@0 | 59 | |
michael@0 | 60 | // Focusing while :-moz-ui-invalid applies, |
michael@0 | 61 | // the pseudo-class should apply while typing if appropriate. |
michael@0 | 62 | aElement.focus(); |
michael@0 | 63 | checkPseudoClass(aElement, true); |
michael@0 | 64 | // with keys |
michael@0 | 65 | synthesizeKey('f', {}); |
michael@0 | 66 | checkPseudoClass(aElement, false); |
michael@0 | 67 | synthesizeKey('VK_BACK_SPACE', {}); |
michael@0 | 68 | checkPseudoClass(aElement, true); |
michael@0 | 69 | // with .value |
michael@0 | 70 | aElement.value = 'f'; |
michael@0 | 71 | checkPseudoClass(aElement, false); |
michael@0 | 72 | aElement.value = ''; |
michael@0 | 73 | checkPseudoClass(aElement, true); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | function checkSelectElement(aElement) |
michael@0 | 77 | { |
michael@0 | 78 | checkPseudoClass(aElement, false); |
michael@0 | 79 | |
michael@0 | 80 | // Focusing while :-moz-ui-invalid doesn't apply, |
michael@0 | 81 | // the pseudo-class should not apply while changing selection. |
michael@0 | 82 | aElement.focus(); |
michael@0 | 83 | checkPseudoClass(aElement, false); |
michael@0 | 84 | |
michael@0 | 85 | aElement.selectedIndex = 1; |
michael@0 | 86 | checkPseudoClass(aElement, false); |
michael@0 | 87 | aElement.selectedIndex = 0; |
michael@0 | 88 | checkPseudoClass(aElement, false); |
michael@0 | 89 | |
michael@0 | 90 | aElement.blur(); |
michael@0 | 91 | checkPseudoClass(aElement, true); |
michael@0 | 92 | |
michael@0 | 93 | // Focusing while :-moz-ui-invalid applies, |
michael@0 | 94 | // the pseudo-class should apply while changing selection if appropriate. |
michael@0 | 95 | aElement.focus(); |
michael@0 | 96 | checkPseudoClass(aElement, true); |
michael@0 | 97 | |
michael@0 | 98 | aElement.selectedIndex = 1; |
michael@0 | 99 | checkPseudoClass(aElement, false); |
michael@0 | 100 | aElement.selectedIndex = 0; |
michael@0 | 101 | checkPseudoClass(aElement, true); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | checkElement(document.getElementsByTagName('input')[0]); |
michael@0 | 105 | checkElement(document.getElementsByTagName('textarea')[0]); |
michael@0 | 106 | checkSelectElement(document.getElementsByTagName('select')[0]); |
michael@0 | 107 | checkSelectElement(document.getElementsByTagName('select')[1]); |
michael@0 | 108 | |
michael@0 | 109 | </script> |
michael@0 | 110 | </pre> |
michael@0 | 111 | </body> |
michael@0 | 112 | </html> |