blob: 154f3ec11c75da0d60bf18cdf4afd58fac4ebaa6 (
plain)
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from head.js */
async function doNCharsTest({ trigger, assert }) {
for (const input of ["x", "xx", "xx x", "xx x "]) {
await doTest(async () => {
await openPopup(input);
await trigger();
await assert(input.length);
});
}
}
async function doNCharsWithOverMaxTextLengthCharsTest({ trigger, assert }) {
await doTest(async () => {
let input = "";
for (let i = 0; i < UrlbarUtils.MAX_TEXT_LENGTH * 2; i++) {
input += "x";
}
await openPopup(input);
await trigger();
await assert(UrlbarUtils.MAX_TEXT_LENGTH * 2);
});
}
async function doNWordsTest({ trigger, assert }) {
for (const input of ["x", "xx", "xx x", "xx x "]) {
await doTest(async () => {
await openPopup(input);
await trigger();
const splits = input.trim().split(" ");
await assert(splits.length);
});
}
}
async function doNWordsWithOverMaxTextLengthCharsTest({ trigger, assert }) {
await doTest(async () => {
const word = "1234 ";
let input = "";
while (input.length < UrlbarUtils.MAX_TEXT_LENGTH * 2) {
input += word;
}
await openPopup(input);
await trigger();
await assert(UrlbarUtils.MAX_TEXT_LENGTH / word.length);
});
}
|