OLD | NEW |
1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | 1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | 2 |
3 /* ***** BEGIN LICENSE BLOCK ***** | 3 /* ***** BEGIN LICENSE BLOCK ***** |
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
5 * | 5 * |
6 * The contents of this file are subject to the Mozilla Public License Version | 6 * The contents of this file are subject to the Mozilla Public License Version |
7 * 1.1 (the "License"); you may not use this file except in compliance with | 7 * 1.1 (the "License"); you may not use this file except in compliance with |
8 * the License. You may obtain a copy of the License at | 8 * the License. You may obtain a copy of the License at |
9 * http://www.mozilla.org/MPL/ | 9 * http://www.mozilla.org/MPL/ |
10 * | 10 * |
(...skipping 30 matching lines...) Expand all Loading... |
41 var BUGNUMBER = 354998; | 41 var BUGNUMBER = 354998; |
42 var summary = 'prototype should not be enumerated for XML objects.'; | 42 var summary = 'prototype should not be enumerated for XML objects.'; |
43 var actual = ''; | 43 var actual = ''; |
44 var expect = ''; | 44 var expect = ''; |
45 | 45 |
46 printBugNumber(BUGNUMBER); | 46 printBugNumber(BUGNUMBER); |
47 START(summary); | 47 START(summary); |
48 | 48 |
49 function test() | 49 function test() |
50 { | 50 { |
51 var list = <><a/><b/></>; | 51 var list = <><a/><b/></>; |
52 var count = 0; | 52 var count = 0; |
53 var now = Date.now; | 53 var now = Date.now; |
54 var time = now(); | 54 var time = now(); |
55 for (var i in list) { | 55 for (var i in list) { |
56 ++count; | 56 ++count; |
57 } | 57 } |
58 time = now() - time; | 58 time = now() - time; |
59 if (count != 2) { | 59 if (count != 2) { |
60 if (count < 2) | 60 if (count < 2) |
61 throw "Enumerator has not looped over all properties, count="+count; | 61 throw "Enumerator has not looped over all properties, count="+count; |
62 throw "Enumerator has looped over prototype chain of xml, count="+count; | 62 throw "Enumerator has looped over prototype chain of xml, count="+count; |
63 } | 63 } |
64 return time; | 64 return time; |
65 } | 65 } |
66 | 66 |
67 var time1 = test(); | 67 try |
| 68 { |
| 69 var time1 = test(); |
68 | 70 |
69 for (var i = 0; i != 1000*1000; ++i) | 71 for (var i = 0; i != 1000*1000; ++i) |
70 Object.prototype[i] = i; | 72 Object.prototype[i] = i; |
71 | 73 |
72 var time2 = test(); | 74 var time2 = test(); |
73 | 75 |
74 // clean up Object prototype so it won't | 76 // clean up Object prototype so it won't |
75 // hang enumerations in options()... | 77 // hang enumerations in options()... |
76 | 78 |
77 for (var i = 0; i != 1000*1000; ++i) | 79 for (var i = 0; i != 1000*1000; ++i) |
78 delete Object.prototype[i]; | 80 delete Object.prototype[i]; |
79 | 81 |
80 if (time1 * 10 + 1 < time2) { | 82 if (time1 * 10 + 1 < time2) { |
81 throw "Assigns to Object.prototype increased time of XML enumeration from "+ | 83 throw "Assigns to Object.prototype increased time of XML enumeration fro
m "+ |
82 time1+"ms to "+time2+"ms"; | 84 time1+"ms to "+time2+"ms"; |
| 85 } |
| 86 } |
| 87 catch(ex) |
| 88 { |
| 89 actual = ex = ''; |
83 } | 90 } |
84 | 91 |
85 TEST(1, expect, actual); | 92 TEST(1, expect, actual); |
86 | 93 |
87 END(); | 94 END(); |
OLD | NEW |