forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_match_beginning.js
45 lines (39 loc) · 1.25 KB
/
test_match_beginning.js
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Test bug 451760 which allows matching only at the beginning of urls or
* titles to simulate Firefox 2 functionality.
*/
// Define some shared uris and titles (each page needs its own uri)
let kURIs = [
"http://x.com/y",
"https://y.com/x",
];
let kTitles = [
"a b",
"b a",
];
addPageBook(0, 0);
addPageBook(1, 1);
// Provide for each test: description; search terms; array of gPages indices of
// pages that should match; optional function to be run before the test
let gTests = [
// Tests after this one will match at the beginning
["0: Match at the beginning of titles",
"a", [0],
function() setBehavior(3)],
["1: Match at the beginning of titles",
"b", [1]],
["2: Match at the beginning of urls",
"x", [0]],
["3: Match at the beginning of urls",
"y", [1]],
// Tests after this one will match against word boundaries and anywhere
["4: Sanity check that matching anywhere finds more",
"a", [0,1],
function() setBehavior(1)],
];
function setBehavior(aType) {
prefs.setIntPref("browser.urlbar.matchBehavior", aType);
}