Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
michael@0 | 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
michael@0 | 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
michael@0 | 4 | <head> |
michael@0 | 5 | <title>script.aculo.us Unit test file</title> |
michael@0 | 6 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
michael@0 | 7 | <script src="../../lib/prototype.js" type="text/javascript"></script> |
michael@0 | 8 | <script src="../../src/scriptaculous.js" type="text/javascript"></script> |
michael@0 | 9 | <script src="../../src/unittest.js" type="text/javascript"></script> |
michael@0 | 10 | <link rel="stylesheet" href="../test.css" type="text/css" /> |
michael@0 | 11 | <style> |
michael@0 | 12 | .selected { background-color: #888; } |
michael@0 | 13 | </style> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <h1>script.aculo.us Unit test file</h1> |
michael@0 | 17 | <p> |
michael@0 | 18 | Tests for Ajax.Autocompleter in controls.js. |
michael@0 | 19 | </p> |
michael@0 | 20 | |
michael@0 | 21 | <!-- Log output --> |
michael@0 | 22 | <div id="testlog"> </div> |
michael@0 | 23 | |
michael@0 | 24 | <input id="ac_input" type="text" autocomplete="off" /> |
michael@0 | 25 | <div id="ac_update" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> |
michael@0 | 26 | |
michael@0 | 27 | <input id="ac_input_br" type="text" autocomplete="off" /> |
michael@0 | 28 | <div id="ac_update_br" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> |
michael@0 | 29 | |
michael@0 | 30 | <input id="ac2_input" type="text" autocomplete="off" /> |
michael@0 | 31 | <div id="ac2_update" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> |
michael@0 | 32 | |
michael@0 | 33 | <input id="actoken_input" type="text" autocomplete="off" /> |
michael@0 | 34 | <div id="actoken_update" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> |
michael@0 | 35 | |
michael@0 | 36 | <input id="dummy_element" type="text" autocomplete="off" /> |
michael@0 | 37 | |
michael@0 | 38 | <!-- Tests follow --> |
michael@0 | 39 | <script type="text/javascript" language="javascript" charset="utf-8"> |
michael@0 | 40 | // <![CDATA[ |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | new Test.Unit.Runner({ |
michael@0 | 44 | |
michael@0 | 45 | // Integration test, tests the entire cycle |
michael@0 | 46 | testAjaxAutocompleter: function() { with(this) { |
michael@0 | 47 | var ac = new Ajax.Autocompleter('ac_input','ac_update','_autocomplete_result.html', |
michael@0 | 48 | { method: 'get' }); //override so we can use a static for the result |
michael@0 | 49 | assertInstanceOf(Ajax.Autocompleter, ac); |
michael@0 | 50 | |
michael@0 | 51 | // box not visible |
michael@0 | 52 | assertNotVisible('ac_update'); |
michael@0 | 53 | |
michael@0 | 54 | // focus, but box not visible |
michael@0 | 55 | Event.simulateMouse('ac_input', 'click'); |
michael@0 | 56 | assertNotVisible('ac_update'); |
michael@0 | 57 | |
michael@0 | 58 | Event.simulateKeys('ac_input','abcdefg'); |
michael@0 | 59 | assertEqual('abcdefg', $('ac_input').value); |
michael@0 | 60 | |
michael@0 | 61 | // check box popping up on input |
michael@0 | 62 | wait(1000, function() { with(this) { |
michael@0 | 63 | assertVisible('ac_update'); |
michael@0 | 64 | assertEqual('test1', $('ac_update').firstChild.firstChild.innerHTML); |
michael@0 | 65 | assertEqual('test2', $('ac_update').firstChild.firstChild.nextSibling.innerHTML); |
michael@0 | 66 | |
michael@0 | 67 | // intl. characters return (UTF-8) |
michael@0 | 68 | assertEqual('Here we have some international ©∏Á®Äç†∑rß', $('ac_update').firstChild.lastChild.innerHTML); |
michael@0 | 69 | |
michael@0 | 70 | // first entry should be selected |
michael@0 | 71 | assert(Element.hasClassName($('ac_update').firstChild.firstChild, 'selected'),'Selected item should have a className of: selected'); |
michael@0 | 72 | |
michael@0 | 73 | Event.simulateKey('ac_input','keypress',{keyCode:Event.KEY_DOWN}); |
michael@0 | 74 | |
michael@0 | 75 | // second entry should be selected |
michael@0 | 76 | assert(!Element.hasClassName($('ac_update').firstChild.firstChild),'Item shouldn\'t have a className of: selected'); |
michael@0 | 77 | assert(Element.hasClassName($('ac_update').firstChild.firstChild.nextSibling, 'selected'),'Second entry should have a className of: selected'); |
michael@0 | 78 | |
michael@0 | 79 | // check selecting with <TAB> |
michael@0 | 80 | Event.simulateKey('ac_input','keypress',{keyCode:Event.KEY_TAB}); |
michael@0 | 81 | assertEqual('test2',$('ac_input').value); |
michael@0 | 82 | |
michael@0 | 83 | // check box going away |
michael@0 | 84 | wait(500, function() { with(this) { |
michael@0 | 85 | assertNotVisible('ac_update'); |
michael@0 | 86 | |
michael@0 | 87 | // check selecting with mouse click |
michael@0 | 88 | Event.simulateKeys('ac_input','3'); |
michael@0 | 89 | assertEqual('test23', $('ac_input').value); |
michael@0 | 90 | wait(1000, function() { with(this) { |
michael@0 | 91 | assertVisible('ac_update'); |
michael@0 | 92 | Event.simulateMouse($('ac_update').firstChild.childNodes[4],'click'); |
michael@0 | 93 | |
michael@0 | 94 | wait(1000, function() { with(this) { |
michael@0 | 95 | // tests if removal of 'informal' nodes and HTML escaping works |
michael@0 | 96 | assertEqual('(GET <ME> INSTEAD)',$('ac_input').value); |
michael@0 | 97 | assertNotVisible('ac_update'); |
michael@0 | 98 | |
michael@0 | 99 | // check cancelling with <ESC> |
michael@0 | 100 | Event.simulateKeys('ac_input','abcdefg'); |
michael@0 | 101 | |
michael@0 | 102 | wait(1000, function() { with(this) { |
michael@0 | 103 | assertVisible('ac_update'); |
michael@0 | 104 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input').value); |
michael@0 | 105 | |
michael@0 | 106 | Event.simulateKey('ac_input','keypress',{keyCode:Event.KEY_DOWN}); |
michael@0 | 107 | Event.simulateKey('ac_input','keypress',{keyCode:Event.KEY_ESC}); |
michael@0 | 108 | |
michael@0 | 109 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input').value); |
michael@0 | 110 | }}); |
michael@0 | 111 | }}); |
michael@0 | 112 | }}); |
michael@0 | 113 | }}); |
michael@0 | 114 | }}); |
michael@0 | 115 | }}, |
michael@0 | 116 | |
michael@0 | 117 | testAfterUpdateElement: function() { with(this) { |
michael@0 | 118 | var ac = new Ajax.Autocompleter('ac2_input','ac2_update','_autocomplete_result.html', |
michael@0 | 119 | { method: 'get', |
michael@0 | 120 | afterUpdateElement: function(element,selectedElement) { |
michael@0 | 121 | element.value = 'afterupdate:' + selectedElement.tagName; |
michael@0 | 122 | } |
michael@0 | 123 | }); |
michael@0 | 124 | assertInstanceOf(Ajax.Autocompleter, ac); |
michael@0 | 125 | |
michael@0 | 126 | Event.simulateMouse('ac2_input', 'click'); |
michael@0 | 127 | Event.simulateKeys('ac2_input','abcdefg'); |
michael@0 | 128 | |
michael@0 | 129 | wait(1000, function() { with(this) { |
michael@0 | 130 | assertVisible('ac2_update'); |
michael@0 | 131 | Event.simulateKey('ac2_input','keypress',{keyCode:Event.KEY_TAB}); |
michael@0 | 132 | |
michael@0 | 133 | assertEqual('afterupdate:LI',$('ac2_input').value); |
michael@0 | 134 | }}); |
michael@0 | 135 | }}, |
michael@0 | 136 | |
michael@0 | 137 | testTokenizing: function() { with(this) { |
michael@0 | 138 | var actoken = new Ajax.Autocompleter('actoken_input','ac_update','_autocomplete_result.html', |
michael@0 | 139 | { tokens:',', method: 'get' }); |
michael@0 | 140 | assertInstanceOf(Ajax.Autocompleter, actoken); |
michael@0 | 141 | |
michael@0 | 142 | Event.simulateKeys('actoken_input','abc'); |
michael@0 | 143 | |
michael@0 | 144 | wait(1000, function() { with(this) { |
michael@0 | 145 | Event.simulateKey('actoken_input','keypress',{keyCode:Event.KEY_TAB}); |
michael@0 | 146 | assertEqual('test1',$('actoken_input').value); |
michael@0 | 147 | Event.simulateKeys('actoken_input',',abc'); |
michael@0 | 148 | wait(1000, function() { with(this) { |
michael@0 | 149 | Event.simulateKey('actoken_input','keypress',{keyCode:Event.KEY_DOWN}); |
michael@0 | 150 | Event.simulateKey('actoken_input','keypress',{keyCode:Event.KEY_TAB}); |
michael@0 | 151 | assertEqual('test1,test2',$('actoken_input').value); |
michael@0 | 152 | }}); |
michael@0 | 153 | }}); |
michael@0 | 154 | }}, |
michael@0 | 155 | |
michael@0 | 156 | // Same integration test, results has no linebreaks |
michael@0 | 157 | testAjaxAutocompleterNoLinebreaksInResult: function() { with(this) { |
michael@0 | 158 | var ac = new Ajax.Autocompleter('ac_input_br','ac_update_br','_autocomplete_result_nobr.html', |
michael@0 | 159 | { method: 'get' }); //override so we can use a static for the result |
michael@0 | 160 | assertInstanceOf(Ajax.Autocompleter, ac); |
michael@0 | 161 | |
michael@0 | 162 | // box not visible |
michael@0 | 163 | assertNotVisible('ac_update_br'); |
michael@0 | 164 | |
michael@0 | 165 | // focus, but box not visible |
michael@0 | 166 | Event.simulateMouse('ac_input_br', 'click'); |
michael@0 | 167 | assertNotVisible('ac_update_br'); |
michael@0 | 168 | |
michael@0 | 169 | Event.simulateKeys('ac_input_br','abcdefg'); |
michael@0 | 170 | assertEqual('abcdefg', $('ac_input_br').value); |
michael@0 | 171 | |
michael@0 | 172 | // check box popping up on input |
michael@0 | 173 | wait(1000, function() { with(this) { |
michael@0 | 174 | assertVisible('ac_update_br'); |
michael@0 | 175 | assertEqual('test1', $('ac_update_br').firstChild.firstChild.innerHTML); |
michael@0 | 176 | assertEqual('test2', $('ac_update_br').firstChild.firstChild.nextSibling.innerHTML); |
michael@0 | 177 | |
michael@0 | 178 | // intl. characters return (UTF-8) |
michael@0 | 179 | assertEqual('Here we have some international ©∏Á®Äç†∑rß', $('ac_update_br').firstChild.lastChild.innerHTML); |
michael@0 | 180 | |
michael@0 | 181 | // first entry should be selected |
michael@0 | 182 | assert(Element.hasClassName($('ac_update_br').firstChild.firstChild, 'selected'),'Selected item should have a className of: selected'); |
michael@0 | 183 | |
michael@0 | 184 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); |
michael@0 | 185 | |
michael@0 | 186 | // second entry should be selected |
michael@0 | 187 | assert(!Element.hasClassName($('ac_update_br').firstChild.firstChild),'Item shouldn\'t have a className of: selected'); |
michael@0 | 188 | assert(Element.hasClassName($('ac_update_br').firstChild.firstChild.nextSibling, 'selected'),'Second entry should have a className of: selected'); |
michael@0 | 189 | |
michael@0 | 190 | // check selecting with <TAB> |
michael@0 | 191 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_TAB}); |
michael@0 | 192 | assertEqual('test2',$('ac_input_br').value); |
michael@0 | 193 | |
michael@0 | 194 | // check box going away |
michael@0 | 195 | wait(500, function() { with(this) { |
michael@0 | 196 | assertNotVisible('ac_update_br'); |
michael@0 | 197 | |
michael@0 | 198 | // check selecting with mouse click |
michael@0 | 199 | Event.simulateKeys('ac_input_br','3'); |
michael@0 | 200 | assertEqual('test23', $('ac_input_br').value); |
michael@0 | 201 | wait(1000, function() { with(this) { |
michael@0 | 202 | assertVisible('ac_update_br'); |
michael@0 | 203 | Event.simulateMouse($('ac_update_br').firstChild.childNodes[4],'click'); |
michael@0 | 204 | |
michael@0 | 205 | wait(1000, function() { with(this) { |
michael@0 | 206 | // tests if removal of 'informal' nodes and HTML escaping works |
michael@0 | 207 | assertEqual('(GET <ME> INSTEAD)',$('ac_input_br').value); |
michael@0 | 208 | assertNotVisible('ac_update_br'); |
michael@0 | 209 | |
michael@0 | 210 | // check cancelling with <ESC> |
michael@0 | 211 | Event.simulateKeys('ac_input_br','abcdefg'); |
michael@0 | 212 | |
michael@0 | 213 | wait(1000, function() { with(this) { |
michael@0 | 214 | assertVisible('ac_update_br'); |
michael@0 | 215 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); |
michael@0 | 216 | |
michael@0 | 217 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); |
michael@0 | 218 | Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_ESC}); |
michael@0 | 219 | |
michael@0 | 220 | assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); |
michael@0 | 221 | }}); |
michael@0 | 222 | }}); |
michael@0 | 223 | }}); |
michael@0 | 224 | }}); |
michael@0 | 225 | }}); |
michael@0 | 226 | }} |
michael@0 | 227 | |
michael@0 | 228 | }); |
michael@0 | 229 | // ]]> |
michael@0 | 230 | </script> |
michael@0 | 231 | </body> |
michael@0 | 232 | </html> |