File: key_sequence_test.js

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (535 lines) | stat: -rw-r--r-- 19,858 bytes parent folder | download | duplicates (5)
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

GEN_INCLUDE(['../testing/chromevox_e2e_test_base.js']);

/**
 * Test fixture.
 */
ChromeVoxMV2KeySequenceUnitTest = class extends ChromeVoxE2ETest {
  /**
   * Create mock event object.
   * @param {number} keyCode The event key code (i.e. 13 for Enter).
   * @param {{altGraphKey: boolean=,
   *         altKey: boolean=,
   *         ctrlKey: boolean=,
   *         metaKey: boolean=,
   *         searchKeyHeld: boolean=,
   *         shiftKey: boolean=,
   *         stickyMode: boolean=,
   *         prefixKey: boolean=}} eventParams The parameters on the event.
   *  altGraphKey: Whether or not the altGraph key was held down.
   *  altKey: Whether or not the alt key was held down.
   *  ctrlKey: Whether or not the ctrl key was held down.
   *  metaKey: Whether or not the meta key was held down.
   *  searchKeyHeld: Whether or not the search key was held down.
   *  shiftKey: Whether or not the shift key was held down.
   *  stickyMode: Whether or not sticky mode is enabled.
   *  prefixKey: Whether or not the prefix key was entered.
   * @return {Object} The mock event.
   */
  createMockEvent(keyCode, eventParams) {
    const mockEvent = {};
    mockEvent.keyCode = keyCode;

    if (eventParams == null) {
      return mockEvent;
    }
    if (eventParams.hasOwnProperty('altGraphKey')) {
      mockEvent.altGraphKey = eventParams.altGraphKey;
    }
    if (eventParams.hasOwnProperty('altKey')) {
      mockEvent.altKey = eventParams.altKey;
    }
    if (eventParams.hasOwnProperty('ctrlKey')) {
      mockEvent.ctrlKey = eventParams.ctrlKey;
    }
    if (eventParams.hasOwnProperty('metaKey')) {
      mockEvent.metaKey = eventParams.metaKey;
    }
    if (eventParams.hasOwnProperty('shiftKey')) {
      mockEvent.shiftKey = eventParams.shiftKey;
    }

    if (eventParams.hasOwnProperty('searchKeyHeld')) {
      mockEvent.searchKeyHeld = eventParams.searchKeyHeld;
    }
    if (eventParams.hasOwnProperty('stickyMode')) {
      mockEvent.stickyMode = eventParams.stickyMode;
    }
    if (eventParams.hasOwnProperty('prefixKey')) {
      mockEvent.keyPrefix = eventParams.prefixKey;
    }

    return mockEvent;
  }

  /** @override */
  async setUpDeferred() {
    await super.setUpDeferred();

    // Set up mock ChromeVox modifier
    KeySequence.modKeyStr = 'Alt';

    // Use these mock events in the tests:

    // Down arrow, no modifiers
    this.downArrowEvent = this.createMockEvent(KeyCode.DOWN);

    // Down arrow key with alt held down. We specified 'Alt' as the
    // mock ChromeVox modifier string, so this means that KeySequence
    // should interpret this as the ChromeVox modifier being active.
    this.altDownArrowEvent = this.createMockEvent(KeyCode.DOWN, {altKey: true});

    // Right arrow, no modifiers
    this.rightArrowEvent = this.createMockEvent(KeyCode.RIGHT);

    // Ctrl key, no modifiers
    this.ctrlEvent = this.createMockEvent(KeyCode.CONTROL);

    // Ctrl key with sticky mode
    this.ctrlStickyEvent =
        this.createMockEvent(KeyCode.CONTROL, {stickyMode: true});

    // Ctrl key with prefix mode
    this.ctrlPrefixEvent =
        this.createMockEvent(KeyCode.CONTROL, {prefixKey: true});

    // 'a' key, no modifiers
    this.aEvent = this.createMockEvent(KeyCode.A);

    // 'a' key with ctrl held down
    this.ctrlAEvent = this.createMockEvent(KeyCode.A, {ctrlKey: true});

    // 'a' key with meta held down
    this.metaAEvent = this.createMockEvent(KeyCode.A, {metaKey: true});

    // 'a' key with shift held down
    this.shiftAEvent = this.createMockEvent(KeyCode.A, {shiftKey: true});

    // 'a' key with alt (which is the mock ChromeVox modifier) and shift held
    // down.
    this.altShiftAEvent =
        this.createMockEvent(KeyCode.A, {altKey: true, shiftKey: true});

    // 'a' key with shift and prefix held down
    this.shiftAPrefixEvent =
        this.createMockEvent(KeyCode.A, {shiftKey: true, prefixKey: true});

    // 'a' key with shift and sticky mode
    this.shiftAStickyEvent =
        this.createMockEvent(KeyCode.A, {shiftKey: true, stickyMode: true});

    // 'a' key with sticky mode
    this.aEventSticky = this.createMockEvent(KeyCode.A, {stickyMode: true});

    // 'a' key with prefix key
    this.aEventPrefix = this.createMockEvent(KeyCode.A, {prefixKey: true});

    // 'a' key with alt (which is the mock ChromeVox modifier) held down
    this.altAEvent = this.createMockEvent(KeyCode.A, {altKey: true});

    // 'b' key, no modifiers
    this.bEvent = this.createMockEvent(KeyCode.B);

    // 'b' key, with ctrl held down
    this.ctrlBEvent = this.createMockEvent(KeyCode.B, {ctrlKey: true});

    // 'c' key, no modifiers
    this.cEvent = this.createMockEvent(KeyCode.C);

    // Shift key with ctrl held down
    this.ctrlShiftEvent = this.createMockEvent(60, {ctrlKey: true});

    // Ctrl key with shift held down
    this.shiftCtrlEvent =
        this.createMockEvent(KeyCode.CONTROL, {shiftKey: true});
  }
};

AX_TEST_F(
    'ChromeVoxMV2KeySequenceUnitTest', 'SimpleSequenceNoModifier', function() {
      const downKey = new KeySequence(this.downArrowEvent, false);

      assertEqualsJSON([KeyCode.DOWN], downKey.keys.keyCode);
      assertFalse(downKey.stickyMode);
      assertFalse(downKey.prefixKey);
      assertFalse(downKey.cvoxModifier);

      assertEqualsJSON([false], downKey.keys.altGraphKey);
      assertEqualsJSON([false], downKey.keys.altKey);
      assertEqualsJSON([false], downKey.keys.ctrlKey);
      assertEqualsJSON([false], downKey.keys.metaKey);
      assertEqualsJSON([false], downKey.keys.searchKeyHeld);
      assertEqualsJSON([false], downKey.keys.shiftKey);

      assertEquals(1, downKey.length());
    });


/** Test another key sequence, this time with the modifier */
AX_TEST_F(
    'ChromeVoxMV2KeySequenceUnitTest', 'SimpleSequenceWithModifier',
    function() {
      const downKey = new KeySequence(this.downArrowEvent, true);

      assertEqualsJSON([KeyCode.DOWN], downKey.keys.keyCode);
      assertFalse(downKey.stickyMode);
      assertFalse(downKey.prefixKey);
      assertTrue(downKey.cvoxModifier);

      assertEqualsJSON([false], downKey.keys.altGraphKey);
      assertEqualsJSON([false], downKey.keys.altKey);
      assertEqualsJSON([false], downKey.keys.ctrlKey);
      assertEqualsJSON([false], downKey.keys.metaKey);
      assertEqualsJSON([false], downKey.keys.searchKeyHeld);
      assertEqualsJSON([false], downKey.keys.shiftKey);

      assertEquals(1, downKey.length());
    });


/** Test a key sequence that includes the modifier */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'ModifiedSequence', function() {
  const cvoxDownKey = new KeySequence(this.altDownArrowEvent, true);

  assertEqualsJSON([KeyCode.DOWN], cvoxDownKey.keys.keyCode);
  assertFalse(cvoxDownKey.stickyMode);
  assertFalse(cvoxDownKey.prefixKey);
  assertTrue(cvoxDownKey.cvoxModifier);

  assertEqualsJSON([false], cvoxDownKey.keys.altGraphKey);
  assertEqualsJSON([false], cvoxDownKey.keys.altKey);
  assertEqualsJSON([false], cvoxDownKey.keys.ctrlKey);
  assertEqualsJSON([false], cvoxDownKey.keys.metaKey);
  assertEqualsJSON([false], cvoxDownKey.keys.searchKeyHeld);
  assertEqualsJSON([false], cvoxDownKey.keys.shiftKey);

  assertEquals(1, cvoxDownKey.length());
});


/**
 * Test equality - Ctrl key vs. Ctrl key with sticky mode on
 * These should be equal because Ctrl should still function even with
 * sticky mode on.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'StickyEquality', function() {
  const ctrlKey = new KeySequence(this.ctrlEvent, false);
  const ctrlSticky = new KeySequence(this.ctrlStickyEvent, false);

  assertTrue(ctrlKey.equals(ctrlSticky));
});


/**
 * Test equality - 'a' key with Shift modifier vs. 'a' key without Shift
 * modifier.
 * These should not be equal because they do not have the same modifiers.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'ShiftEquality', function() {
  const aKey = new KeySequence(this.aEvent, false);
  const shiftA = new KeySequence(this.shiftAEvent, false);

  assertFalse(aKey.equals(shiftA));
});


/**
 * Test equality - 'a' with ChromeVox modifier specified, 'a' with sticky mode
 * on, 'a' with prefix key, and 'a' with ChromeVox modifier held down. These
 * should all be equal to each other.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'FourWayEquality', function() {
  const commandSequence = new KeySequence(this.aEvent, true);
  const stickySequence = new KeySequence(this.aEventSticky, false);
  const prefixSequence = new KeySequence(this.aEventPrefix, false);
  const cvoxModifierSequence = new KeySequence(this.altAEvent);

  assertTrue(commandSequence.equals(stickySequence));
  assertTrue(commandSequence.equals(prefixSequence));
  assertTrue(commandSequence.equals(cvoxModifierSequence));

  assertTrue(stickySequence.equals(commandSequence));
  assertTrue(stickySequence.equals(prefixSequence));
  assertTrue(stickySequence.equals(cvoxModifierSequence));

  assertTrue(prefixSequence.equals(commandSequence));
  assertTrue(prefixSequence.equals(stickySequence));
  assertTrue(prefixSequence.equals(cvoxModifierSequence));

  assertTrue(cvoxModifierSequence.equals(commandSequence));
  assertTrue(cvoxModifierSequence.equals(stickySequence));
  assertTrue(cvoxModifierSequence.equals(prefixSequence));
});


/**
 * Test equality - 'a' key with Shift modifier and prefix vs. 'a' key with Shift
 * modifier and sticky mode vs. 'a' key with Shift modifier and ChromeVox
 * modifier specified vs. 'a' key with ChromeVox modifier held down.
 * These should all be equal to each other..
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'ShiftPrefixEquality', function() {
  const shiftAWithModifier = new KeySequence(this.shiftAEvent, true);
  const shiftAWithPrefix = new KeySequence(this.shiftAPrefixEvent, false);
  const shiftASticky = new KeySequence(this.shiftAStickyEvent, false);
  const cvoxShiftA = new KeySequence(this.altShiftAEvent);

  assertTrue(shiftAWithModifier.equals(shiftAWithPrefix));
  assertTrue(shiftAWithModifier.equals(shiftASticky));
  assertTrue(shiftAWithModifier.equals(cvoxShiftA));

  assertTrue(shiftAWithPrefix.equals(shiftAWithModifier));
  assertTrue(shiftAWithPrefix.equals(shiftASticky));
  assertTrue(shiftAWithPrefix.equals(cvoxShiftA));

  assertTrue(shiftASticky.equals(shiftAWithPrefix));
  assertTrue(shiftASticky.equals(shiftAWithModifier));
  assertTrue(shiftASticky.equals(cvoxShiftA));

  assertTrue(cvoxShiftA.equals(shiftAWithModifier));
  assertTrue(cvoxShiftA.equals(shiftAWithPrefix));
  assertTrue(cvoxShiftA.equals(shiftASticky));
});


/**
 * Test inequality - 'a' with modifier key vs. 'a' without modifier key.
 * These should not be equal.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'Inequality', function() {
  const aNoModifier = new KeySequence(this.aEvent, false);
  const aWithModifier = new KeySequence(this.aEvent, true);

  assertFalse(aNoModifier.equals(aWithModifier));
  assertFalse(aWithModifier.equals(aNoModifier));
});


/**
 * Test equality - adding an additional key onto a sequence.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'CvoxCtrl', function() {
  const cvoxCtrlSequence = new KeySequence(this.ctrlEvent, true);
  assertTrue(cvoxCtrlSequence.addKeyEvent(this.rightArrowEvent));

  assertEquals(2, cvoxCtrlSequence.length());

  // Can't add more than two key events.
  assertFalse(cvoxCtrlSequence.addKeyEvent(this.rightArrowEvent));

  const cvoxCtrlStickySequence = new KeySequence(this.ctrlStickyEvent, false);
  assertTrue(cvoxCtrlStickySequence.addKeyEvent(this.rightArrowEvent));

  const mockCtrlPrefixSequence = new KeySequence(this.ctrlPrefixEvent, false);
  assertTrue(mockCtrlPrefixSequence.addKeyEvent(this.rightArrowEvent));

  assertTrue(cvoxCtrlSequence.equals(cvoxCtrlStickySequence));
  assertTrue(cvoxCtrlStickySequence.equals(cvoxCtrlSequence));

  assertTrue(cvoxCtrlSequence.equals(mockCtrlPrefixSequence));
  assertTrue(mockCtrlPrefixSequence.equals(cvoxCtrlSequence));

  assertTrue(cvoxCtrlStickySequence.equals(mockCtrlPrefixSequence));
  assertTrue(mockCtrlPrefixSequence.equals(cvoxCtrlStickySequence));
});


/**
 * Test for inequality - key sequences in different orders.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'DifferentSequences', function() {
  const cvoxBSequence = new KeySequence(this.bEvent, true);
  assertTrue(cvoxBSequence.addKeyEvent(this.cEvent));

  const cvoxCSequence = new KeySequence(this.cEvent, false);
  assertTrue(cvoxCSequence.addKeyEvent(this.bEvent));

  assertFalse(cvoxBSequence.equals(cvoxCSequence));
  assertFalse(cvoxCSequence.equals(cvoxBSequence));
});


/**
 * Tests modifiers (ctrl, alt, etc) - if two sequences have different modifiers
 * held down then they aren't equal.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'MoreModifiers', function() {
  const ctrlASequence = new KeySequence(this.ctrlAEvent, false);
  const ctrlModifierKeyASequence = new KeySequence(this.ctrlAEvent, true);

  const ctrlBSequence = new KeySequence(this.ctrlBEvent, false);

  const metaASequence = new KeySequence(this.metaAEvent, false);

  assertFalse(ctrlASequence.equals(metaASequence));
  assertFalse(ctrlASequence.equals(ctrlModifierKeyASequence));
  assertFalse(ctrlASequence.equals(ctrlBSequence));
});


/**
 * Tests modifier (ctrl, alt, etc) order - if two sequences have the same
 * modifiers but held down in a different order then they aren't equal.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'ModifierOrder', function() {
  const ctrlShiftSequence = new KeySequence(this.ctrlShiftEvent, false);
  const shiftCtrlSequence = new KeySequence(this.shiftCtrlEvent, true);

  assertFalse(ctrlShiftSequence.equals(shiftCtrlSequence));
});


/**
 * Tests converting from a string to a KeySequence object.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'FromStr', function() {
  const ctrlString = KeySequence.fromStr('Ctrl');
  assertEqualsJSON(ctrlString.keys.ctrlKey, [true]);
  assertEqualsJSON(ctrlString.keys.keyCode, [KeyCode.CONTROL]);

  const modifiedLetterString = KeySequence.fromStr('Ctrl+Z');
  assertEqualsJSON(modifiedLetterString.keys.ctrlKey, [true]);
  assertEqualsJSON(modifiedLetterString.keys.keyCode, [KeyCode.Z]);

  const keyCodeString = KeySequence.fromStr('#9');
  assertEqualsJSON(keyCodeString.keys.keyCode, [KeyCode.TAB]);

  const modifiedKeyCodeString = KeySequence.fromStr('Shift+#9');
  assertEqualsJSON(modifiedKeyCodeString.keys.shiftKey, [true]);
  assertEqualsJSON(modifiedKeyCodeString.keys.keyCode, [KeyCode.TAB]);

  const cvoxLetterString = KeySequence.fromStr('Cvox+U');
  assertTrue(cvoxLetterString.cvoxModifier);
  assertEqualsJSON(cvoxLetterString.keys.keyCode, [KeyCode.U]);

  const cvoxSequenceString = KeySequence.fromStr('Cvox+C>T');
  assertTrue(cvoxSequenceString.cvoxModifier);
  assertEqualsJSON(cvoxSequenceString.keys.keyCode, [KeyCode.C, KeyCode.T]);

  const cvoxSequenceKeyCodeString = KeySequence.fromStr('Cvox+L>#186');
  assertTrue(cvoxSequenceKeyCodeString.cvoxModifier);
  assertEqualsJSON(
      cvoxSequenceKeyCodeString.keys.keyCode, [KeyCode.L, KeyCode.OEM_1]);

  const stickyString = KeySequence.fromStr('Insert>Insert+');
  assertEqualsJSON(stickyString.keys.keyCode, [KeyCode.INSERT, KeyCode.INSERT]);
});


/**
 * Tests converting from a JSON string to a KeySequence object.
 */
AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'Deserialize', function() {
  const forwardSequence = KeySequence.deserialize({
    'cvoxModifier': true,
    'stickyMode': false,
    'prefixKey': false,
    'keys': {
      'ctrlKey': [false],
      'searchKeyHeld': [false],
      'altKey': [false],
      'altGraphKey': [false],
      'shiftKey': [false],
      'metaKey': [false],
      'keyCode': [KeyCode.DOWN],
    },
  });
  assertTrue(forwardSequence.cvoxModifier);
  assertEqualsJSON(forwardSequence.keys.keyCode, [KeyCode.DOWN]);

  const ctrlSequence = KeySequence.deserialize({
    'cvoxModifier': false,
    'stickyMode': true,
    'prefixKey': false,
    'keys': {
      'ctrlKey': [true],
      'searchKeyHeld': [false],
      'altKey': [false],
      'altGraphKey': [false],
      'shiftKey': [false],
      'metaKey': [false],
      'keyCode': [KeyCode.CONTROL],
    },
  });
  assertEqualsJSON(ctrlSequence.keys.ctrlKey, [true]);
  assertEqualsJSON(ctrlSequence.keys.keyCode, [KeyCode.CONTROL]);
});

AX_TEST_F(
    'ChromeVoxMV2KeySequenceUnitTest', 'DeserializeAltShiftCvoxMod',
    function() {
      KeySequence.modKeyStr = 'Alt+Shift';

      // Build a key sequence that does not strip modifiers when deserializing.
      // This feature is important for sequences that contain part or all of the
      // modifiers in the cvox modifier as specified in the key map. This
      // happens by default when deserializing.
      //
      // For example, at runtime, a user presses Shift+H with sticky mode on.
      // This should match against a key sequence that has cvoxModifier set
      // along with shift key set.
      const prevHeadingUnstripped = {'shiftKey': [true], keyCode: [KeyCode.H]};
      const prevHeadingSeq = KeySequence.deserialize(
          {'cvoxModifier': true, keys: prevHeadingUnstripped});

      assertTrue(prevHeadingSeq.cvoxModifier);
      assertTrue(prevHeadingSeq.keys.shiftKey[0]);
    });

AX_TEST_F(
    'ChromeVoxMV2KeySequenceUnitTest', 'DeserializeSearchCvoxMod', function() {
      // Test the case when we do want to strip modifiers when deserializing.
      // This is important when the key sequence in the key map and the key
      // sequence at runtime both contain the bare cvox modifier as a key code
      // such as in the case of the Search sticky key and Search cvox modifier.
      // Stripping happens by default for key events at runtime.
      KeySequence.modKeyStr = 'Search';

      // First, assert that unstripped seqs imply various modifier fields get
      // set.
      let stickySeq =
          KeySequence.deserialize({keys: {keyCode: [KeyCode.SEARCH]}});
      assertTrue(stickySeq.cvoxModifier);
      assertTrue(stickySeq.keys.metaKey[0]);
      assertTrue(stickySeq.keys.searchKeyHeld[0]);

      // Next, assert that stripping causes those modifiers to get unset. This
      // is desirable at runtime so that we can match against the stripped
      // runtime key seqs.
      stickySeq = KeySequence.deserialize(
          {'skipStripping': false, keys: {keyCode: [KeyCode.SEARCH]}});
      assertTrue(stickySeq.cvoxModifier);
      assertFalse(stickySeq.keys.metaKey[0]);
      assertFalse(stickySeq.keys.searchKeyHeld[0]);
    });

AX_TEST_F('ChromeVoxMV2KeySequenceUnitTest', 'RequireStickyMode', function() {
  const oneFromMap = KeySequence.deserialize(
      {requireStickyMode: true, keys: {keyCode: [KeyCode.ONE]}});

  assertFalse(oneFromMap.cvoxModifier);
  assertTrue(oneFromMap.requireStickyMode);
  assertFalse(oneFromMap.stickyMode);

  // Pressing one doesn't trigger the key because it requires sticky mode.
  const oneFromEvt = KeySequence.deserialize({keys: {keyCode: [KeyCode.ONE]}});
  assertFalse(oneFromMap.equals(oneFromEvt));

  // Even modified, it should not match.
  const modOneFromEvt = KeySequence.deserialize(
      {cvoxModifier: true, keys: {keyCode: [KeyCode.ONE]}});
  assertFalse(oneFromMap.equals(modOneFromEvt));

  // But, with sticky mode on in the event, it should match.
  const stickyOneFromEvt = KeySequence.deserialize(
      {stickyMode: true, keys: {keyCode: [KeyCode.ONE]}});
  assertTrue(stickyOneFromEvt.equals(oneFromMap));

  // Finally, with both modifier and sticky on, it doesn't match.
  const stickyModOneFromEvt = KeySequence.deserialize(
      {stickyMode: true, cvoxModifier: true, keys: {keyCode: [KeyCode.ONE]}});
  assertFalse(stickyModOneFromEvt.equals(oneFromMap));
});