Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / js / tests / e4x / XML / regress-376773.js
blob11a1556838313a067399370c819ae330153e5864
1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is JavaScript Engine testing utilities.
18 * The Initial Developer of the Original Code is
19 * Mozilla Foundation.
20 * Portions created by the Initial Developer are Copyright (C) 2007
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s): Igor Bukanov
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 gTestfile = 'regress-376773.js';
41 var BUGNUMBER = 376773;
42 var summary = 'xmlsimple.stringmethod === xmlsimple.function::stringmethod';
43 var actual = '';
44 var expect = '';
45 var actualcall = '';
46 var expectcall = '';
48 printBugNumber(BUGNUMBER);
49 START(summary);
51 var nTest = 0;
52 var xml = <a>TEXT</a>;
54 // --------------------------------------------------------------
56 String.prototype.orig_toString = String.prototype.toString;
57 String.prototype.toString = function() {
58 actualcall = 'String.prototype.toString called';
59 return this.orig_toString();
62 expect = 'TEXT';
63 expectcall = 'String.prototype.toString not called';
65 actualcall = expectcall;
66 actual = xml.toString();
67 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
69 actualcall = expectcall;
70 actual = xml.function::toString();
71 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
73 actualcall = expectcall;
74 actual = xml.function::toString.call(xml);
75 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
77 String.prototype.toString = String.prototype.orig_toString;
78 delete String.prototype.orig_toString;
80 // --------------------------------------------------------------
82 String.prototype.orig_toSource = String.prototype.toSource;
83 String.prototype.toSource = function() {
84 actualcall = 'String.prototype.toSource called';
85 return this.orig_toSource();
88 expect = '<a>TEXT</a>';
89 expectcall = 'String.prototype.toSource not called';
91 actualcall = expectcall;
92 actual = xml.toSource();
93 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
95 actualcall = expectcall;
96 actual = xml.function::toSource();
97 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
99 actualcall = expectcall;
100 actual = xml.function::toSource.call(xml);
101 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
103 String.prototype.toSource = String.prototype.orig_toSource;
104 delete String.prototype.orig_toSource;
106 // --------------------------------------------------------------
108 String.prototype.orig_valueOf = String.prototype.valueOf;
109 String.prototype.valueOf = function() {
110 actualcall = 'String.prototype.valueOf called';
111 return this.orig_valueOf();
114 expect = 'TEXT';
115 expectcall = 'String.prototype.valueOf not called';
117 actualcall = expectcall;
118 actual = xml.valueOf();
119 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
121 actualcall = expectcall;
122 actual = xml.function::valueOf();
123 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
125 actualcall = expectcall;
126 actual = xml.function::valueOf.call(xml);
127 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
129 String.prototype.valueOf = String.prototype.orig_valueOf;
130 delete String.prototype.orig_valueOf;
132 // --------------------------------------------------------------
134 String.prototype.orig_charAt = String.prototype.charAt;
135 String.prototype.charAt = function(pos) {
136 actualcall = 'String.prototype.charAt called';
137 return this.orig_charAt(pos);
140 expect = 'T';
141 expectcall = 'String.prototype.charAt called';
143 actualcall = expectcall.replace(/called/, 'not called');
144 actual = xml.charAt(0);
145 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
147 actualcall = expectcall.replace(/called/, 'not called');
148 actual = xml.function::charAt(0);
149 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
151 actualcall = expectcall.replace(/called/, 'not called');
152 actual = xml.function::charAt.call(xml, 0);
153 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
155 String.prototype.charAt = String.prototype.orig_charAt;
156 delete String.prototype.orig_charAt;
158 // --------------------------------------------------------------
160 String.prototype.orig_charCodeAt = String.prototype.charCodeAt;
161 String.prototype.charCodeAt = function(pos) {
162 actualcall = 'String.prototype.charCodeAt called';
163 return this.orig_charCodeAt(pos);
166 expect = 84;
167 expectcall = 'String.prototype.charCodeAt called';
169 actualcall = expectcall.replace(/called/, 'not called');
170 actual = xml.charCodeAt(0);
171 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
173 actualcall = expectcall.replace(/called/, 'not called');
174 actual = xml.function::charCodeAt(0);
175 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
177 actualcall = expectcall.replace(/called/, 'not called');
178 actual = xml.function::charCodeAt.call(xml, 0);
179 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
181 String.prototype.charCodeAt = String.prototype.orig_charCodeAt;
182 delete String.prototype.orig_charCodeAt;
184 // --------------------------------------------------------------
186 String.prototype.orig_concat = String.prototype.concat;
187 String.prototype.concat = function(string1) {
188 actualcall = 'String.prototype.concat called';
189 return this.orig_concat(string1);
192 expect = 'TEXTtext';
193 expectcall = 'String.prototype.concat called';
195 actualcall = expectcall.replace(/called/, 'not called');
196 actual = xml.concat(<b>text</b>);
197 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
199 actualcall = expectcall.replace(/called/, 'not called');
200 actual = xml.function::concat(<b>text</b>);
201 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
203 actualcall = expectcall.replace(/called/, 'not called');
204 actual = xml.function::concat.call(xml, <b>text</b>);
205 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
207 String.prototype.concat = String.prototype.orig_concat;
208 delete String.prototype.orig_concat;
210 // --------------------------------------------------------------
212 String.prototype.orig_indexOf = String.prototype.indexOf;
213 String.prototype.indexOf = function(searchString, position) {
214 actualcall = 'String.prototype.indexOf called';
215 return this.orig_indexOf(searchString, position);
218 expect = 0;
219 expectcall = 'String.prototype.indexOf called';
221 actualcall = expectcall.replace(/called/, 'not called');
222 actual = xml.indexOf('T');
223 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
225 actualcall = expectcall.replace(/called/, 'not called');
226 actual = xml.function::indexOf('T');
227 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
229 actualcall = expectcall.replace(/called/, 'not called');
230 actual = xml.function::indexOf.call(xml, 'T');
231 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
233 String.prototype.indexOf = String.prototype.orig_indexOf;
234 delete String.prototype.orig_indexOf;
236 // --------------------------------------------------------------
238 String.prototype.orig_lastIndexOf = String.prototype.lastIndexOf;
239 String.prototype.lastIndexOf = function(searchString, position) {
240 actualcall = 'String.prototype.lastIndexOf called';
241 return this.orig_lastIndexOf(searchString, position);
244 expect = 3;
245 expectcall = 'String.prototype.lastIndexOf called';
247 actualcall = expectcall.replace(/called/, 'not called');
248 actual = xml.lastIndexOf('T');
249 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
251 actualcall = expectcall.replace(/called/, 'not called');
252 actual = xml.function::lastIndexOf('T');
253 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
255 actualcall = expectcall.replace(/called/, 'not called');
256 actual = xml.function::lastIndexOf.call(xml, 'T');
257 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
259 String.prototype.lastIndexOf = String.prototype.orig_lastIndexOf;
260 delete String.prototype.orig_lastIndexOf;
262 // --------------------------------------------------------------
264 String.prototype.orig_localeCompare = String.prototype.localeCompare;
265 String.prototype.localeCompare = function(that) {
266 actualcall = 'String.prototype.localeCompare called';
267 return this.orig_localeCompare(that);
270 expect = 0;
271 expectcall = 'String.prototype.localeCompare called';
273 actualcall = expectcall.replace(/called/, 'not called');
274 actual = xml.localeCompare(xml);
275 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
277 actualcall = expectcall.replace(/called/, 'not called');
278 actual = xml.function::localeCompare(xml);
279 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
281 actualcall = expectcall.replace(/called/, 'not called');
282 actual = xml.function::localeCompare.call(xml, xml);
283 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
285 String.prototype.localeCompare = String.prototype.orig_localeCompare;
286 delete String.prototype.orig_localeCompare;
288 // --------------------------------------------------------------
290 String.prototype.orig_match = String.prototype.match;
291 String.prototype.match = function(regexp) {
292 actualcall = 'String.prototype.match called';
293 return this.orig_match(regexp);
296 expect = ['TEXT'];
297 expectcall = 'String.prototype.match called';
299 actualcall = expectcall.replace(/called/, 'not called');
300 actual = xml.match(/TEXT/);
301 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
303 actualcall = expectcall.replace(/called/, 'not called');
304 actual = xml.function::match(/TEXT/);
305 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
307 actualcall = expectcall.replace(/called/, 'not called');
308 actual = xml.function::match.call(xml, /TEXT/);
309 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
311 String.prototype.match = String.prototype.orig_match;
312 delete String.prototype.orig_match;
314 // --------------------------------------------------------------
316 String.prototype.orig_replace = String.prototype.replace;
317 String.prototype.replace = function(searchValue, replaceValue) {
318 actualcall = 'String.prototype.replace called';
319 return this.orig_replace(searchValue, replaceValue);
322 expect = 'TEXT';
323 expectcall = 'String.prototype.replace not called';
325 actualcall = expectcall;
326 actual = xml.replace(/EXT/, 'ext');
327 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
329 actualcall = expectcall;
330 actual = xml.function::replace(/EXT/, 'ext');
331 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
333 actualcall = expectcall;
334 actual = xml.function::replace.call(xml, /EXT/, 'ext');
335 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
337 String.prototype.replace = String.prototype.orig_replace;
338 delete String.prototype.orig_replace;
340 // --------------------------------------------------------------
342 String.prototype.orig_search = String.prototype.search;
343 String.prototype.search = function(regexp) {
344 actualcall = 'String.prototype.search called';
345 return this.orig_search(regexp);
348 expect = 0;
349 expectcall = 'String.prototype.search called';
351 actualcall = expectcall.replace(/called/, 'not called');
352 actual = xml.search(/TEXT/);
353 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
355 actualcall = expectcall.search(/called/, 'not called');
356 actual = xml.function::search(/TEXT/);
357 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
359 actualcall = expectcall.search(/called/, 'not called');
360 actual = xml.function::search.call(xml, /TEXT/);
361 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
363 String.prototype.search = String.prototype.orig_search;
364 delete String.prototype.orig_search;
366 // --------------------------------------------------------------
368 String.prototype.orig_slice = String.prototype.slice;
369 String.prototype.slice = function(start, end) {
370 actualcall = 'String.prototype.slice called';
371 return this.orig_slice(start, end);
374 expect = '';
375 expectcall = 'String.prototype.slice called';
377 actualcall = expectcall.replace(/called/, 'not called');
378 actual = xml.slice(1,1);
379 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
381 actualcall = expectcall.slice(/called/, 'not called');
382 actual = xml.function::slice(1,1);
383 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
385 actualcall = expectcall.slice(/called/, 'not called');
386 actual = xml.function::slice.call(xml, 1,1);
387 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
389 String.prototype.slice = String.prototype.orig_slice;
390 delete String.prototype.orig_slice;
392 // --------------------------------------------------------------
394 String.prototype.orig_split = String.prototype.split;
395 String.prototype.split = function(separator, limit) {
396 actualcall = 'String.prototype.split called';
397 return this.orig_split(separator, limit);
400 expect = ['T', 'E', 'X', 'T'];
401 expectcall = 'String.prototype.split called';
403 actualcall = expectcall.replace(/called/, 'not called');
404 actual = xml.split('');
405 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
407 actualcall = expectcall.split(/called/, 'not called');
408 actual = xml.function::split('');
409 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
411 actualcall = expectcall.split(/called/, 'not called');
412 actual = xml.function::split.call(xml, '');
413 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
415 String.prototype.split = String.prototype.orig_split;
416 delete String.prototype.orig_split;
418 // --------------------------------------------------------------
420 String.prototype.orig_substr = String.prototype.substr;
421 String.prototype.substr = function(start, length) {
422 actualcall = 'String.prototype.substr called';
423 return this.orig_substr(start, length);
426 expect = 'E';
427 expectcall = 'String.prototype.substr called';
429 actualcall = expectcall.replace(/called/, 'not called');
430 actual = xml.substr(1,1);
431 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
433 actualcall = expectcall.substr(/called/, 'not called');
434 actual = xml.function::substr(1,1);
435 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
437 actualcall = expectcall.substr(/called/, 'not called');
438 actual = xml.function::substr.call(xml, 1,1);
439 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
441 String.prototype.substr = String.prototype.orig_substr;
442 delete String.prototype.orig_substr;
444 // --------------------------------------------------------------
446 String.prototype.orig_substring = String.prototype.substring;
447 String.prototype.substring = function(start, end) {
448 actualcall = 'String.prototype.substring called';
449 return this.orig_substring(start, end);
452 expect = '';
453 expectcall = 'String.prototype.substring called';
455 actualcall = expectcall.replace(/called/, 'not called');
456 actual = xml.substring(1,1);
457 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
459 actualcall = expectcall.substring(/called/, 'not called');
460 actual = xml.function::substring(1,1);
461 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
463 actualcall = expectcall.substring(/called/, 'not called');
464 actual = xml.function::substring.call(xml, 1,1);
465 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
467 String.prototype.substring = String.prototype.orig_substring;
468 delete String.prototype.orig_substring;
470 // --------------------------------------------------------------
472 String.prototype.orig_toLowerCase = String.prototype.toLowerCase;
473 String.prototype.toLowerCase = function() {
474 actualcall = 'String.prototype.toLowerCase called';
475 return this.orig_toLowerCase();
478 expect = 'text';
479 expectcall = 'String.prototype.toLowerCase called';
481 actualcall = expectcall.replace(/called/, 'not called');
482 actual = xml.toLowerCase();
483 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
485 actualcall = expectcall.toLowerCase(/called/, 'not called');
486 actual = xml.function::toLowerCase();
487 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
489 actualcall = expectcall.toLowerCase(/called/, 'not called');
490 actual = xml.function::toLowerCase.call(xml);
491 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
493 String.prototype.toLowerCase = String.prototype.orig_toLowerCase;
494 delete String.prototype.orig_toLowerCase;
496 // --------------------------------------------------------------
498 String.prototype.orig_toLocaleLowerCase = String.prototype.toLocaleLowerCase;
499 String.prototype.toLocaleLowerCase = function() {
500 actualcall = 'String.prototype.toLocaleLowerCase called';
501 return this.orig_toLocaleLowerCase();
504 expect = 'text';
505 expectcall = 'String.prototype.toLocaleLowerCase called';
507 actualcall = expectcall.replace(/called/, 'not called');
508 actual = xml.toLocaleLowerCase();
509 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
511 actualcall = expectcall.toLocaleLowerCase(/called/, 'not called');
512 actual = xml.function::toLocaleLowerCase();
513 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
515 actualcall = expectcall.toLocaleLowerCase(/called/, 'not called');
516 actual = xml.function::toLocaleLowerCase.call(xml);
517 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
519 String.prototype.toLocaleLowerCase = String.prototype.orig_toLocaleLowerCase;
520 delete String.prototype.orig_toLocaleLowerCase;
522 // --------------------------------------------------------------
524 String.prototype.orig_toUpperCase = String.prototype.toUpperCase;
525 String.prototype.toUpperCase = function() {
526 actualcall = 'String.prototype.toUpperCase called';
527 return this.orig_toUpperCase();
530 expect = 'TEXT';
531 expectcall = 'String.prototype.toUpperCase called';
533 actualcall = expectcall.replace(/called/, 'not called');
534 actual = xml.toUpperCase();
535 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
537 actualcall = expectcall.toUpperCase(/called/, 'not called');
538 actual = xml.function::toUpperCase();
539 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
541 actualcall = expectcall.toUpperCase(/called/, 'not called');
542 actual = xml.function::toUpperCase.call(xml);
543 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
545 String.prototype.toUpperCase = String.prototype.orig_toUpperCase;
546 delete String.prototype.orig_toUpperCase;
548 // --------------------------------------------------------------
550 String.prototype.orig_toLocaleUpperCase = String.prototype.toLocaleUpperCase;
551 String.prototype.toLocaleUpperCase = function() {
552 actualcall = 'String.prototype.toLocaleUpperCase called';
553 return this.orig_toLocaleUpperCase();
556 expect = 'TEXT';
557 expectcall = 'String.prototype.toLocaleUpperCase called';
559 actualcall = expectcall.replace(/called/, 'not called');
560 actual = xml.toLocaleUpperCase();
561 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
563 actualcall = expectcall.toLocaleUpperCase(/called/, 'not called');
564 actual = xml.function::toLocaleUpperCase();
565 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
567 actualcall = expectcall.toLocaleUpperCase(/called/, 'not called');
568 actual = xml.function::toLocaleUpperCase.call(xml);
569 TEST(++nTest, expectcall + ':' + expect, actualcall + ':' + actual);
571 String.prototype.toLocaleUpperCase = String.prototype.orig_toLocaleUpperCase;
572 delete String.prototype.orig_toLocaleUpperCase;
574 var l = <><a>text</a></>;
575 expect = 't';
576 actual = l.function::charAt.call(l, 0);
577 TEST(++nTest, expect, actual);
579 expect = 't';
580 with (l) actual = function::charAt(0);
581 TEST(++nTest, expect, actual);
584 END();