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 15.10.4.1 new RegExp(pattern, flags)
9 If F contains any character other than "g", "i", or" m", or if it
10 contains the same one more than once, then throw a SyntaxError
11 exception.
12 */
14 //-----------------------------------------------------------------------------
15 var BUGNUMBER = 476940;
16 var summary = 'Section 15.10.4.1 - RegExp with invalid flags';
17 var actual = '';
18 var expect = '';
21 //-----------------------------------------------------------------------------
22 test();
23 //-----------------------------------------------------------------------------
25 function test()
26 {
27 enterFunc ('test');
28 printBugNumber(BUGNUMBER);
29 printStatus (summary);
31 var invalidflags = ['ii', 'gg', 'mm', 'a'];
33 for (var i = 0; i < invalidflags.length; i++)
34 {
35 var flag = invalidflags[i];
36 expect = 'SyntaxError: invalid regular expression flag ' + flag.charAt(0);
37 actual = '';
38 try
39 {
40 new RegExp('bar', flag);
41 }
42 catch(ex)
43 {
44 actual = ex + '';
45 }
46 reportCompare(expect, actual, summary +
47 ': new RegExp("bar", "' + flag + '")');
49 actual = '';
50 try
51 {
52 eval("/bar/" + flag);
53 }
54 catch(ex)
55 {
56 actual = ex + '';
57 }
58 reportCompare(expect, actual, summary + ': /bar/' + flag + ')');
59 }
61 exitFunc ('test');
62 }