bug 841350 - register pageshow handler earlier in browser.js r=ttaubert
[gecko.git] / browser / base / content / test / test_bug452451.html
blob633bd5fa256e2f3555f806a8dc5d0fc0968b4b3b
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=452451
5 -->
6 <head>
7 <title>Test for Bug 452451</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=452451">Mozilla Bug 452451</a>
13 <p id="display"></p>
14 <pre id="test">
15 <script type="application/javascript">
17 /** Test for Bug 452451 **/
19 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
20 const prefs = Components.classes["@mozilla.org/preferences-service;1"]
21 .getService(Components.interfaces.nsIPrefBranch);
23 ok(prefs.getBoolPref("javascript.options.relimit"),
24 "relimit should be enabled by default");
26 /**
27 * Following tests are inspired from:
28 * js/src/tests/js1_5/extensions/regress-330569.js
31 var s;
32 const expected = 'InternalError: regular expression too complex';
34 s = '<!DOCTYPE HTML PUBLIC>' +
35 '<html>\n' +
36 '<head>\n' +
37 '<meta http-equiv="content-type" content="text/html">\n' +
38 '<title></title>\n'+
39 '</head>\n' +
40 '<body>\n' +
41 '<!-- hello -->\n' +
42 '<script language="JavaScript">\n' +
43 'var s = document. body. innerHTML;\n' +
44 'var d = s. replace (/<!--(.*|\n)*-->/, "");\n' +
45 '<\/script>\n' +
46 '<\/body>\n' +
47 '<\/html>\n';
49 try {
50 /<!--(.*|\n)*-->/.exec(s);
52 catch(ex) {
53 actual = ex;
56 is(actual, expected, "reg exp too complex error should have been thrown");
58 function testre( re, n )
60 var txt = '';
61 for (var i= 0; i <= n; ++i) {
62 txt += ',';
63 re.test(txt);
67 try {
68 testre( /(?:,*)*x/, 22 );
70 catch(ex) {
71 actual = ex;
74 is(actual, expected, "reg exp too complex error should have been thrown");
76 try {
77 testre( /(?:,|,)*x/, 22 );
79 catch(ex) {
80 actual = ex;
83 is(actual, expected, "reg exp too complex error should have been thrown");
85 try {
86 testre( /(?:,|,|,|,|,)*x/, 10 );
88 catch(ex) {
89 actual = ex;
92 is(actual, expected, "reg exp too complex error should have been thrown");
93 </script>
94 </pre>
95 </body>
96 </html>