DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (205d1b4e8f69)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for inputting new text while there is unmasked range</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<input type="password" value="012345">

<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  let input = document.getElementsByTagName("input")[0];
  let editor = SpecialPowers.wrap(input).editor;

  async function doTest(aDelay) {
    await SpecialPowers.pushPrefEnv({
      set: [["editor.password.mask_delay", aDelay]],
    });
    input.focus();
    input.value = "012345";

    // Setting value
    editor.unmask(3, 4);
    input.value = "abcdef";
    is(editor.unmaskedStart, 0,
       "delay=" + aDelay + ": Setting value should mask all characters (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Setting value should mask all characters (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after setting value");
    editor.unmask(3, 4);
    input.value = "abcdef";
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Setting same value shouldn't change unmasked range (start)");
    is(editor.unmaskedEnd, 4,
       "delay=" + aDelay + ": Setting same value shouldn't change unmasked range (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after setting same value");
    input.value = "";
    is(editor.unmaskedStart, 0,
       "delay=" + aDelay + ": Setting empty value should collapse unmasked range (start)");
    is(editor.unmaskedEnd, 0,
       "delay=" + aDelay + ": Setting empty value should collapse unmasked range (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after setting empty value");
    input.value = "abcdef";
    is(editor.unmaskedStart, 0,
       "delay=" + aDelay + ": Setting empty field to new value should unmask all (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Setting empty field to new value should unmask all (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after setting empty field to new value");

    // Simply typing a character
    editor.unmask(3, 4);
    input.setSelectionRange(3, 3);
    synthesizeKey("1");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Inserting character at start of unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Inserting character at start of unmasked range should expand the range (end)");
    is(input.value, "abc1def",
       "delay=" + aDelay + ": Inserting character at start of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after inserting character at start of unmasked range");

    editor.unmask(3, 5);
    synthesizeKey("2");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Inserting character in the unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Inserting character in the unmasked range should expand the range (end)");
    is(input.value, "abc12def",
       "delay=" + aDelay + ": Inserting character in the unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after inserting character in the unmasked range");

    editor.unmask(3, 6);
    input.setSelectionRange(6, 6);
    synthesizeKey("3");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Inserting character at end of unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 7,
       "delay=" + aDelay + ": Inserting character at end of unmasked range should expand the range (end)");
    is(input.value, "abc12d3ef",
       "delay=" + aDelay + ": Inserting character at end of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after inserting character at end of unmasked range");

    editor.unmask(3, 4);
    input.setSelectionRange(2, 2);
    synthesizeKey("4");
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Inserting character before the unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Inserting character before the unmasked range should expand the range (end)");
    is(input.value, "ab4c12d3ef",
       "delay=" + aDelay + ": Inserting character before the unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after inserting character before the unmasked range");

    editor.unmask(2, 5);
    input.setSelectionRange(6, 6);
    synthesizeKey("5");
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Inserting character after the unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 7,
       "delay=" + aDelay + ": Inserting character after the unmasked range should expand the range (end)");
    is(input.value, "ab4c125d3ef",
       "delay=" + aDelay + ": Inserting character after the unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after inserting character after the unmasked range");

    // Simply removing characters
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(3, 3);
    editor.deleteSelection(editor.eNext, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing first character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing first character of unmasked range should shrink the range (end)");
    is(input.value, "abcefgh",
       "delay=" + aDelay + ": Removing first character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing first character of unmasked range");

    editor.unmask(3, 5);
    editor.deleteSelection(editor.ePrevious, editor.eStrip);
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Removing previous character of unmasked range should move the range (start)");
    is(editor.unmaskedEnd, 4,
       "delay=" + aDelay + ": Removing previous character of unmasked range should move the range (end)");
    is(input.value, "abefgh",
       "delay=" + aDelay + ": Removing previous character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing previous character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(6, 6);
    editor.deleteSelection(editor.ePrevious, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing last character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing last character of unmasked range should shrink the range (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing last character of unmasked range should shrink the range");

    editor.unmask(3, 5);
    editor.deleteSelection(editor.eNext, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing next character of unmasked range shouldn't change the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing next character of unmasked range shouldn't change the range (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing next character of unmasked range shouldn't change the range");

    input.value = "abcdef";
    editor.unmask(3, 6);
    input.setSelectionRange(4, 4);
    editor.deleteSelection(editor.eNext, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing middle character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing middle character of unmasked range should shrink the range (end)");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing middle character of unmasked range should shrink the range");

    // Removing selection
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(3, 4);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing selected first character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing selected first character of unmasked range should shrink the range (end)");
    is(input.value, "abcefgh",
       "delay=" + aDelay + ": Removing selected first character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing selected first character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(2, 3);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Removing selected previous character of unmasked range should move the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing selected previous character of unmasked range should move the range (end)");
    is(input.value, "abdefgh",
       "delay=" + aDelay + ": Removing selected previous character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing selected previous character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(5, 6);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing selected last character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing selected last character of unmasked range should shrink the range (end)");
    is(input.value, "abcdegh",
       "delay=" + aDelay + ": Removing selected last character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing selected last character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(6, 7);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing selected next character of unmasked range should keep the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Removing selected next character of unmasked range should keep the range (end)");
    is(input.value, "abcdefh",
       "delay=" + aDelay + ": Removing selected next character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing selected next character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(4, 5);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Removing selected middle character of unmasked range should shrink the range (start)");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Removing selected middle character of unmasked range should shrink the range (end)");
    is(input.value, "abcdfgh",
       "delay=" + aDelay + ": Removing selected middle character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing selected middle character of unmasked range");

    // Replacing a character
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(3, 4);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing first character of unmasked range should keep the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Replacing first character of unmasked range should keep the range (end)");
    is(input.value, "abc0efgh",
       "delay=" + aDelay + ": Replacing first character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing first character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(2, 3);
    synthesizeKey("0");
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Replacing previous character of unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Replacing previous character of unmasked range should expand the range (end)");
    is(input.value, "ab0defgh",
       "delay=" + aDelay + ": Replacing previous character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing previous character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(5, 6);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing last character of unmasked range should keep the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Replacing last character of unmasked range should keep the range (end)");
    is(input.value, "abcde0gh",
       "delay=" + aDelay + ": Replacing last character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing last character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(6, 7);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing next character of unmasked range should expand the range (start)");
    is(editor.unmaskedEnd, 7,
       "delay=" + aDelay + ": Replacing next character of unmasked range should expand the range (end)");
    is(input.value, "abcdef0h",
       "delay=" + aDelay + ": Replacing next character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing next character of unmasked range");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(4, 5);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing middle character of unmasked range should keep the range (start)");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Replacing middle character of unmasked range should keep the range (end)");
    is(input.value, "abcd0fgh",
       "delay=" + aDelay + ": Replacing middle character of unmasked range");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing middle character of unmasked range");

    // Replace part of the range
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(1, 4);
    synthesizeKey("0");
    is(editor.unmaskedStart, 1,
       "delay=" + aDelay + ": Replacing start edge of unmasked range should move and shrink the range (start) #1");
    is(editor.unmaskedEnd, 4,
       "delay=" + aDelay + ": Replacing start edge of unmasked range should move and shrink the range (end) #1");
    is(input.value, "a0efgh",
       "delay=" + aDelay + ": Replacing start edge of unmasked range #1");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing start edge of unmasked range #1");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(2, 5);
    synthesizeKey("0");
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Replacing start edge of unmasked range should move and shrink the range (start) #2");
    is(editor.unmaskedEnd, 4,
       "delay=" + aDelay + ": Replacing start edge of unmasked range should move and shrink the range (end) #2");
    is(input.value, "ab0fgh",
       "delay=" + aDelay + ": Replacing start edge of unmasked range #2");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing start edge of unmasked range #2");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(4, 7);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing end edge of unmasked range should shrink the range (start) #1");
    is(editor.unmaskedEnd, 5,
       "delay=" + aDelay + ": Replacing end edge of unmasked range should shrink the range (end) #1");
    is(input.value, "abcd0h",
       "delay=" + aDelay + ": Replacing end edge of unmasked range #1");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing end edge of unmasked range #1");

    input.value = "abcdefghi";
    editor.unmask(3, 6);
    input.setSelectionRange(5, 8);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing end edge of unmasked range should shrink the range (start) #2");
    is(editor.unmaskedEnd, 6,
       "delay=" + aDelay + ": Replacing end edge of unmasked range should shrink the range (end) #2");
    is(input.value, "abcde0i",
       "delay=" + aDelay + ": Replacing end edge of unmasked range #2");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing end edge of unmasked range #2");

    // Replaceing all of the range
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(3, 6);
    synthesizeKey("0");
    is(editor.unmaskedStart, 3,
       "delay=" + aDelay + ": Replacing all of unmasked range should shrink the range (start) #1");
    is(editor.unmaskedEnd, 4,
       "delay=" + aDelay + ": Replacing all of unmasked range should shrink the range (end) #1");
    is(input.value, "abc0gh",
       "delay=" + aDelay + ": Replacing all of unmasked range #1");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing all of unmasked range #1");

    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(2, 7);
    synthesizeKey("0");
    is(editor.unmaskedStart, 2,
       "delay=" + aDelay + ": Replacing all of unmasked range should shrink the range (start) #2");
    is(editor.unmaskedEnd, 3,
       "delay=" + aDelay + ": Replacing all of unmasked range should shrink the range (end) #2");
    is(input.value, "ab0h",
       "delay=" + aDelay + ": Replacing all of unmasked range #2");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after replacing all of unmasked range #2");

    // Removing all characters and type new character
    input.value = "abcdefgh";
    editor.unmask(3, 6);
    input.setSelectionRange(0, 8);
    editor.deleteSelection(editor.eNone, editor.eStrip);
    is(editor.unmaskedStart, 0,
       "delay=" + aDelay + ": Removing all characters should shrink the range (start)");
    is(editor.unmaskedEnd, 0,
       "delay=" + aDelay + ": Removing all characters should shrink the range (end)");
    is(input.value, "",
       "delay=" + aDelay + ": Removing all characters");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after removing all characters");
    synthesizeKey("0");
    is(editor.unmaskedStart, 0,
       "delay=" + aDelay + ": Typing first character should expand unmasked range (start)");
    is(editor.unmaskedEnd, 1,
       "delay=" + aDelay + ": Typing first character should expand unmasked range (end)");
    is(input.value, "0",
       "delay=" + aDelay + ": Typing first character");
    ok(!editor.autoMaskingEnabled,
       "delay=" + aDelay + ": auto masking shouldn't be enabled after typing first character");
  }

  await doTest(0);
  await doTest(600);

  SimpleTest.finish();
});
</script>
</pre>
</body>
</html>