Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 *
8 * Date: 21 January 2003
9 * SUMMARY: Regression test for bug 189898
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=189898
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var UBound = 0;
15 var BUGNUMBER = 189898;
16 var summary = 'Regression test for bug 189898';
17 var status = '';
18 var statusitems = [];
19 var actual = '';
20 var actualvalues = [];
21 var expect= '';
22 var expectedvalues = [];
25 status = inSection(1);
26 actual = 'XaXY'.replace('XY', '--')
27 expect = 'Xa--';
28 addThis();
30 status = inSection(2);
31 actual = '$a$^'.replace('$^', '--')
32 expect = '$a--';
33 addThis();
35 status = inSection(3);
36 actual = 'ababc'.replace('abc', '--')
37 expect = 'ab--';
38 addThis();
40 status = inSection(4);
41 actual = 'ababc'.replace('abc', '^$')
42 expect = 'ab^$';
43 addThis();
47 /*
48 * Same as above, but providing a regexp in the first parameter
49 * to String.prototype.replace() instead of a string.
50 *
51 * See http://bugzilla.mozilla.org/show_bug.cgi?id=83293
52 * for subtleties on this issue -
53 */
54 status = inSection(5);
55 actual = 'XaXY'.replace(/XY/, '--')
56 expect = 'Xa--';
57 addThis();
59 status = inSection(6);
60 actual = 'XaXY'.replace(/XY/g, '--')
61 expect = 'Xa--';
62 addThis();
64 status = inSection(7);
65 actual = '$a$^'.replace(/\$\^/, '--')
66 expect = '$a--';
67 addThis();
69 status = inSection(8);
70 actual = '$a$^'.replace(/\$\^/g, '--')
71 expect = '$a--';
72 addThis();
74 status = inSection(9);
75 actual = 'ababc'.replace(/abc/, '--')
76 expect = 'ab--';
77 addThis();
79 status = inSection(10);
80 actual = 'ababc'.replace(/abc/g, '--')
81 expect = 'ab--';
82 addThis();
84 status = inSection(11);
85 actual = 'ababc'.replace(/abc/, '^$')
86 expect = 'ab^$';
87 addThis();
89 status = inSection(12);
90 actual = 'ababc'.replace(/abc/g, '^$')
91 expect = 'ab^$';
92 addThis();
96 //-----------------------------------------------------------------------------
97 test();
98 //-----------------------------------------------------------------------------
102 function addThis()
103 {
104 statusitems[UBound] = status;
105 actualvalues[UBound] = actual;
106 expectedvalues[UBound] = expect;
107 UBound++;
108 }
111 function test()
112 {
113 enterFunc('test');
114 printBugNumber(BUGNUMBER);
115 printStatus(summary);
117 for (var i=0; i<UBound; i++)
118 {
119 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
120 }
122 exitFunc ('test');
123 }