Debian Codegraph @

rhino/testsrc/tests/e4x/Regress/regress-354998.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 gTestfile = 'regress-354998.js';
8
9 var BUGNUMBER = 354998;
10 var summary = 'prototype should not be enumerated for XML objects.';
11 var actual = '';
12 var expect = '';
13
14 printBugNumber(BUGNUMBER);
15 START(summary);
16
17 function test()
18 {
19 var list = <><a/><b/></>;
20 var count = 0;
21 var now = Date.now;
22 var time = now();
23 for (var i in list) {
24 ++count;
25 }
26 time = now() - time;
27 if (count != 2) {
28 if (count < 2)
29 throw "Enumerator has not looped over all properties, count="+count;
30 throw "Enumerator has looped over prototype chain of xml, count="+count;
31 }
32 return time;
33 }
34
35 try
36 {
37 var time1 = test();
38
39 for (var i = 0; i != 1000*1000; ++i)
40 Object.prototype[i] = i;
41
42 var time2 = test();
43
44 // clean up Object prototype so it won't
45 // hang enumerations in options()...
46
47 for (var i = 0; i != 1000*1000; ++i)
48 delete Object.prototype[i];
49
50 if (time1 * 10 + 1 < time2) {
51 throw "Assigns to Object.prototype increased time of XML enumeration from "+
52 time1+"ms to "+time2+"ms";
53 }
54 }
55 catch(ex)
56 {
57 actual = ex = '';
58 }
59
60 TEST(1, expect, actual);
61
62 END();