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=408231 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 408231</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408231">Mozilla Bug 408231</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script class="testbody" type="text/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 408231 **/ |
michael@0 | 21 | |
michael@0 | 22 | var commandEnabledResults = [ |
michael@0 | 23 | ["contentReadOnly", "true"], |
michael@0 | 24 | ["copy", "false"], |
michael@0 | 25 | ["createlink", "true"], |
michael@0 | 26 | ["cut", "false"], |
michael@0 | 27 | ["decreasefontsize", "true"], |
michael@0 | 28 | ["delete", "true"], |
michael@0 | 29 | ["fontname", "true"], |
michael@0 | 30 | ["fontsize", "true"], |
michael@0 | 31 | ["formatblock", "true"], |
michael@0 | 32 | ["heading", "true"], |
michael@0 | 33 | ["hilitecolor", "true"], |
michael@0 | 34 | ["increasefontsize", "true"], |
michael@0 | 35 | ["indent", "true"], |
michael@0 | 36 | ["inserthorizontalrule", "true"], |
michael@0 | 37 | ["inserthtml", "true"], |
michael@0 | 38 | ["insertimage", "true"], |
michael@0 | 39 | ["insertorderedlist", "true"], |
michael@0 | 40 | ["insertunorderedlist", "true"], |
michael@0 | 41 | ["insertparagraph", "true"], |
michael@0 | 42 | ["italic", "true"], |
michael@0 | 43 | ["justifycenter", "true"], |
michael@0 | 44 | ["justifyfull", "true"], |
michael@0 | 45 | ["justifyleft", "true"], |
michael@0 | 46 | ["justifyright", "true"], |
michael@0 | 47 | ["outdent", "true"], |
michael@0 | 48 | //["paste", "true"], |
michael@0 | 49 | ["redo", "false"], |
michael@0 | 50 | ["removeformat", "true"], |
michael@0 | 51 | ["selectall", "true"], |
michael@0 | 52 | ["strikethrough", "true"], |
michael@0 | 53 | ["styleWithCSS", "true"], |
michael@0 | 54 | ["subscript", "true"], |
michael@0 | 55 | ["superscript", "true"], |
michael@0 | 56 | ["underline", "true"], |
michael@0 | 57 | ["undo", "false"], |
michael@0 | 58 | ["unlink", "true"], |
michael@0 | 59 | ["not-a-command", "false"] |
michael@0 | 60 | ]; |
michael@0 | 61 | |
michael@0 | 62 | var commandIndetermResults = [ |
michael@0 | 63 | ["contentReadOnly", "false"], |
michael@0 | 64 | ["copy", "false"], |
michael@0 | 65 | ["createlink", "false"], |
michael@0 | 66 | ["cut", "false"], |
michael@0 | 67 | ["decreasefontsize", "false"], |
michael@0 | 68 | ["delete", "false"], |
michael@0 | 69 | ["fontname", "false"], |
michael@0 | 70 | ["fontsize", "false"], |
michael@0 | 71 | ["formatblock", "false"], |
michael@0 | 72 | ["heading", "false"], |
michael@0 | 73 | ["hilitecolor", "false"], |
michael@0 | 74 | ["increasefontsize", "false"], |
michael@0 | 75 | ["indent", "false"], |
michael@0 | 76 | ["inserthorizontalrule", "false"], |
michael@0 | 77 | ["inserthtml", "false"], |
michael@0 | 78 | ["insertimage", "false"], |
michael@0 | 79 | ["insertorderedlist", "false"], |
michael@0 | 80 | ["insertunorderedlist", "false"], |
michael@0 | 81 | ["insertparagraph", "false"], |
michael@0 | 82 | ["italic", "false"], |
michael@0 | 83 | ["justifycenter", "false"], |
michael@0 | 84 | ["justifyfull", "false"], |
michael@0 | 85 | ["justifyleft", "false"], |
michael@0 | 86 | ["justifyright", "false"], |
michael@0 | 87 | ["outdent", "false"], |
michael@0 | 88 | //["paste", "false"], |
michael@0 | 89 | ["redo", "false"], |
michael@0 | 90 | ["removeformat", "false"], |
michael@0 | 91 | ["selectall", "false"], |
michael@0 | 92 | ["strikethrough", "false"], |
michael@0 | 93 | ["styleWithCSS", "false"], |
michael@0 | 94 | ["subscript", "false"], |
michael@0 | 95 | ["superscript", "false"], |
michael@0 | 96 | ["underline", "false"], |
michael@0 | 97 | ["undo", "false"], |
michael@0 | 98 | ["unlink", "false"], |
michael@0 | 99 | ["not-a-command", "false"] |
michael@0 | 100 | ]; |
michael@0 | 101 | |
michael@0 | 102 | var commandStateResults = [ |
michael@0 | 103 | ["contentReadOnly", "false"], |
michael@0 | 104 | ["copy", "false"], |
michael@0 | 105 | ["createlink", "false"], |
michael@0 | 106 | ["cut", "false"], |
michael@0 | 107 | ["decreasefontsize", "false"], |
michael@0 | 108 | ["delete", "false"], |
michael@0 | 109 | ["fontname", "false"], |
michael@0 | 110 | ["fontsize", "false"], |
michael@0 | 111 | ["formatblock", "false"], |
michael@0 | 112 | ["heading", "false"], |
michael@0 | 113 | ["hilitecolor", "false"], |
michael@0 | 114 | ["increasefontsize", "false"], |
michael@0 | 115 | ["indent", "false"], |
michael@0 | 116 | ["inserthorizontalrule", "false"], |
michael@0 | 117 | ["inserthtml", "false"], |
michael@0 | 118 | ["insertimage", "false"], |
michael@0 | 119 | ["insertorderedlist", "false"], |
michael@0 | 120 | ["insertunorderedlist", "false"], |
michael@0 | 121 | ["insertparagraph", "false"], |
michael@0 | 122 | ["italic", "false"], |
michael@0 | 123 | ["justifycenter", "false"], |
michael@0 | 124 | ["justifyfull", "false"], |
michael@0 | 125 | ["justifyleft", "true"], |
michael@0 | 126 | ["justifyright", "false"], |
michael@0 | 127 | ["outdent", "false"], |
michael@0 | 128 | //["paste", "false"], |
michael@0 | 129 | ["redo", "false"], |
michael@0 | 130 | ["removeformat", "false"], |
michael@0 | 131 | ["selectall", "false"], |
michael@0 | 132 | ["strikethrough", "false"], |
michael@0 | 133 | ["styleWithCSS", "false"], |
michael@0 | 134 | ["subscript", "false"], |
michael@0 | 135 | ["superscript", "false"], |
michael@0 | 136 | ["underline", "false"], |
michael@0 | 137 | ["undo", "false"], |
michael@0 | 138 | ["unlink", "false"], |
michael@0 | 139 | ["not-a-command", "false"] |
michael@0 | 140 | ]; |
michael@0 | 141 | |
michael@0 | 142 | var commandValueResults = [ |
michael@0 | 143 | ["contentReadOnly", ""], |
michael@0 | 144 | ["copy", ""], |
michael@0 | 145 | ["createlink", ""], |
michael@0 | 146 | ["cut", ""], |
michael@0 | 147 | ["decreasefontsize", ""], |
michael@0 | 148 | ["delete", ""], |
michael@0 | 149 | ["fontname", ""], |
michael@0 | 150 | ["fontsize", ""], |
michael@0 | 151 | ["formatblock", ""], |
michael@0 | 152 | ["heading", ""], |
michael@0 | 153 | ["hilitecolor", "transparent"], |
michael@0 | 154 | ["increasefontsize", ""], |
michael@0 | 155 | ["indent", ""], |
michael@0 | 156 | ["inserthorizontalrule", ""], |
michael@0 | 157 | ["inserthtml", ""], |
michael@0 | 158 | ["insertimage", ""], |
michael@0 | 159 | ["insertorderedlist", ""], |
michael@0 | 160 | ["insertunorderedlist", ""], |
michael@0 | 161 | ["insertparagraph", ""], |
michael@0 | 162 | ["italic", ""], |
michael@0 | 163 | ["justifycenter", "left"], |
michael@0 | 164 | ["justifyfull", "left"], |
michael@0 | 165 | ["justifyleft", "left"], |
michael@0 | 166 | ["justifyright", "left"], |
michael@0 | 167 | ["outdent", ""], |
michael@0 | 168 | //["paste", ""], |
michael@0 | 169 | ["redo", ""], |
michael@0 | 170 | ["removeformat", ""], |
michael@0 | 171 | ["selectall", ""], |
michael@0 | 172 | ["strikethrough", ""], |
michael@0 | 173 | ["styleWithCSS", ""], |
michael@0 | 174 | ["subscript", ""], |
michael@0 | 175 | ["superscript", ""], |
michael@0 | 176 | ["underline", ""], |
michael@0 | 177 | ["undo", ""], |
michael@0 | 178 | ["unlink", ""], |
michael@0 | 179 | ["not-a-command", ""], |
michael@0 | 180 | ]; |
michael@0 | 181 | |
michael@0 | 182 | |
michael@0 | 183 | function callQueryCommandEnabled(cmdName) { |
michael@0 | 184 | var result; |
michael@0 | 185 | try { |
michael@0 | 186 | result = '' + document.queryCommandEnabled( cmdName ); |
michael@0 | 187 | } catch( error ) { |
michael@0 | 188 | result = 'name' in error ? error.name : 'exception'; |
michael@0 | 189 | } |
michael@0 | 190 | return result; |
michael@0 | 191 | } |
michael@0 | 192 | |
michael@0 | 193 | function callQueryCommandIndeterm(cmdName) { |
michael@0 | 194 | var result; |
michael@0 | 195 | try { |
michael@0 | 196 | result = '' + document.queryCommandIndeterm( cmdName ); |
michael@0 | 197 | } catch( error ) { |
michael@0 | 198 | result = 'name' in error ? error.name : 'exception'; |
michael@0 | 199 | } |
michael@0 | 200 | return result; |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | function callQueryCommandState(cmdName) { |
michael@0 | 204 | var result; |
michael@0 | 205 | try { |
michael@0 | 206 | result = '' + document.queryCommandState( cmdName ); |
michael@0 | 207 | } catch( error ) { |
michael@0 | 208 | result = 'name' in error ? error.name : 'exception'; |
michael@0 | 209 | } |
michael@0 | 210 | return result; |
michael@0 | 211 | } |
michael@0 | 212 | |
michael@0 | 213 | function callQueryCommandValue(cmdName) { |
michael@0 | 214 | var result; |
michael@0 | 215 | try { |
michael@0 | 216 | result = '' + document.queryCommandValue( cmdName ); |
michael@0 | 217 | } catch( error ) { |
michael@0 | 218 | result = 'name' in error ? error.name : 'exception'; |
michael@0 | 219 | } |
michael@0 | 220 | return result; |
michael@0 | 221 | } |
michael@0 | 222 | |
michael@0 | 223 | function testQueryCommand(expectedResults, fun, funName) { |
michael@0 | 224 | for (i=0; i<expectedResults.length; i++) { |
michael@0 | 225 | var commandName = expectedResults[i][0]; |
michael@0 | 226 | var expectedResult = expectedResults[i][1]; |
michael@0 | 227 | var result = fun(commandName); |
michael@0 | 228 | ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult); |
michael@0 | 229 | } |
michael@0 | 230 | } |
michael@0 | 231 | |
michael@0 | 232 | function runTests() { |
michael@0 | 233 | document.designMode='on'; |
michael@0 | 234 | window.getSelection().collapse(document.body, 0); |
michael@0 | 235 | testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled"); |
michael@0 | 236 | testQueryCommand(commandIndetermResults, callQueryCommandIndeterm, "queryCommandIndeterm"); |
michael@0 | 237 | testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState"); |
michael@0 | 238 | testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue"); |
michael@0 | 239 | document.designMode='off'; |
michael@0 | 240 | SimpleTest.finish(); |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | window.onload = runTests; |
michael@0 | 244 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 245 | |
michael@0 | 246 | </script> |
michael@0 | 247 | </pre> |
michael@0 | 248 | </body> |
michael@0 | 249 | </html> |
michael@0 | 250 |