Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / actionscript.all / TextField.as
blob48dc6f5339d22224ac42dfd4a64a4beb96f7fb59
1 //
2 // Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 // Test case for TextField ActionScript class
19 // compile this test case with Ming makeswf, and then
20 // execute it like this gnash -1 -r 0 -v out.swf
23 rcsid="TextField.as";
24 #include "check.as"
26 printBounds = function(b)
28 var s = '';
29 s += "xmin:"+b.xMin;
30 s += " ymin:"+b.yMin;
31 s += " xmax:"+b.xMax;
32 s += " ymax:"+b.yMax;
33 return s;
36 TextField.prototype.getBounds = MovieClip.prototype.getBounds;
39 // check that the dejagnu clip is *not* a TextField, which is why the
40 // following prototype properties are not yet initialized.
41 #if OUTPUT_VERSION > 6
42 check_equals(_root.getInstanceAtDepth(-16383), _level0.__shared_assets);
43 xcheck(!_level0.__shared_assets.instance1._xtrace_win instanceof TextField);
44 xcheck_equals(typeof(_level0.__shared_assets.instance1._xtrace_win),
45 "movieclip");
46 note(_level0.__shared_assets.instance1._xtrace_win.toString());
47 #endif
49 #if OUTPUT_VERSION < 6
51 check_equals(typeof(TextField), 'function');
52 check_equals(TextField.prototype, undefined);
53 createTextField("tf", 50, 10, 10, 10, 10);
54 xcheck_equals(typeof(tf), "movieclip");
55 xcheck_equals(tf.__proto__.toString(), "[object Object]");
56 check(!tf instanceOf TextField);
58 tf = new TextField();
59 xcheck(tf instanceOf TextField);
60 totals();
62 #else
64 check_equals(typeof(TextField), 'function');
65 check_equals(typeof(TextField.prototype), 'object');
66 check_equals(typeof(TextField.prototype.__proto__), 'object');
67 check_equals(TextField.prototype.__proto__, Object.prototype);
68 check_equals(typeof(TextField.prototype.setTextFormat), 'function');
69 check_equals(typeof(TextField.prototype.getTextFormat), 'function');
70 check_equals(typeof(TextField.prototype.setNewTextFormat), 'function');
71 check_equals(typeof(TextField.prototype.getNewTextFormat), 'function');
72 check_equals(typeof(TextField.prototype.getDepth), 'function');
73 check_equals(typeof(TextField.prototype.removeTextField), 'function');
74 check_equals(typeof(TextField.prototype.replaceSel), 'function');
76 // TextField.prototype was implicitly initialized by ASBroadcaster.initialize !
77 // See http://www.senocular.com/flash/tutorials/listenersasbroadcaster/?page=2
78 check_equals(typeof(TextField.prototype.addListener), 'function');
79 check_equals(typeof(TextField.prototype.removeListener), 'function');
80 check_equals(typeof(TextField.prototype.broadcastMessage), 'function');
81 check(TextField.prototype.hasOwnProperty("_listeners"));
82 check_equals(typeof(TextField.prototype._listeners), 'object');
83 check(TextField.prototype._listeners instanceof Array);
84 check_equals(TextField.prototype._listeners.length, 0);
86 // NOTE: the following will be true after a call to createTextField ! Seek forward to see..
87 xcheck( !TextField.prototype.hasOwnProperty('background'));
88 xcheck( !TextField.prototype.hasOwnProperty('backgroundColor'));
89 xcheck( !TextField.prototype.hasOwnProperty('autoSize') );
90 xcheck( !TextField.prototype.hasOwnProperty('border') );
91 xcheck( !TextField.prototype.hasOwnProperty('borderColor') );
92 xcheck( !TextField.prototype.hasOwnProperty('bottomScroll') );
93 xcheck( !TextField.prototype.hasOwnProperty('embedFonts') );
94 xcheck( !TextField.prototype.hasOwnProperty('hscroll') );
95 xcheck( !TextField.prototype.hasOwnProperty('html') );
96 xcheck( !TextField.prototype.hasOwnProperty('htmlText') );
97 xcheck( !TextField.prototype.hasOwnProperty('length') );
98 xcheck( !TextField.prototype.hasOwnProperty('maxChars') );
99 xcheck( !TextField.prototype.hasOwnProperty('maxhscroll') );
100 xcheck( !TextField.prototype.hasOwnProperty('maxscroll') );
101 xcheck( !TextField.prototype.hasOwnProperty('multiline') );
102 xcheck( !TextField.prototype.hasOwnProperty('password') );
103 xcheck( !TextField.prototype.hasOwnProperty('restrict') );
104 xcheck( !TextField.prototype.hasOwnProperty('scroll') );
105 xcheck( !TextField.prototype.hasOwnProperty('selectable') );
106 xcheck( !TextField.prototype.hasOwnProperty('text') );
107 xcheck( !TextField.prototype.hasOwnProperty('textColor') );
108 xcheck( !TextField.prototype.hasOwnProperty('textHeight') ); // should be available on first instantiation
109 xcheck( !TextField.prototype.hasOwnProperty('textWidth') ); // should be available on first instantiation
110 xcheck( !TextField.prototype.hasOwnProperty('type') ); // should be available on first instantiation
111 xcheck( !TextField.prototype.hasOwnProperty('variable') );
112 xcheck( !TextField.prototype.hasOwnProperty('wordWrap') );
114 // this is a static method
115 check_equals(typeof(TextField.getFontList), 'function');
116 check_equals(typeof(TextField.prototype.getFontList), 'undefined');
118 tfGetFontList = TextField.getFontList;
119 tfGetFontListObj = new Object();
120 tfGetFontListObj.f = tfGetFontList;
121 check_equals(TextField.getFontList() instanceof Array, true);
122 check_equals(tfGetFontList() instanceof Array, true);
123 check_equals(tfGetFontListObj.f() instanceof Array, true);
124 check_equals(tfGetFontList.call(null) instanceof Array, true);
125 check_equals(tfGetFontList.call(undefined) instanceof Array, true);
127 check(TextField.prototype.hasOwnProperty('replaceText'));
128 #if OUTPUT_VERSION > 6
129 check_equals(typeof(TextField.prototype.replaceText), 'function');
130 #else
131 check_equals(typeof(TextField.prototype.replaceText), 'undefined');
132 // but exists!
133 #endif
135 tfObj = new TextField();
136 check_equals(typeof(tfObj), 'object');
137 check(tfObj instanceof TextField);
139 check_equals(typeof(tfObj.setTextFormat), 'function');
140 check_equals(typeof(tfObj.getTextFormat), 'function');
141 check_equals(typeof(tfObj.setNewTextFormat), 'function');
142 check_equals(typeof(tfObj.getNewTextFormat), 'function');
143 check_equals(typeof(tfObj.addListener), 'function');
144 check_equals(typeof(tfObj.removeListener), 'function');
145 check_equals(typeof(tfObj.getDepth), 'function');
146 check_equals(typeof(tfObj.removeTextField), 'function');
147 check_equals(typeof(tfObj.replaceSel), 'function');
148 // this is a static method, it's available as TextField.getFontList
149 check_equals(typeof(tfObj.getFontList), 'undefined');
150 check_equals(typeof(tfObj._parent), 'undefined'); // no parent
152 //--------------------------------------------------
153 // Check textfield creation trough createTextField
154 //--------------------------------------------------
156 ret = createTextField("tf", 99, 10, 10, 500, 500);
157 #if OUTPUT_VERSION < 8
158 check_equals(typeof(ret), 'undefined');
159 #else
160 check_equals(typeof(ret), 'object');
161 check_equals(ret, _root.tf);
162 #endif
164 check(tf instanceof TextField);
165 check_equals(typeof(tf), 'object');
166 check(tf.hasOwnProperty('_listeners'));
167 check_equals(tf._listeners.length, 1); // adds self to the listeners
168 check_equals(tf._listeners[0], tf); // adds self to the listeners set
169 check(!tf.hasOwnProperty('broadcastMessage'));
170 check(!tf.hasOwnProperty('addListener'));
171 check(!tf.hasOwnProperty('removeListener'));
173 // NOTE: the following were false before the call to createTextField ! Seek backward to see..
174 check( TextField.prototype.hasOwnProperty('background'));
175 check( TextField.prototype.hasOwnProperty('backgroundColor'));
176 check( TextField.prototype.hasOwnProperty('autoSize') );
177 check( TextField.prototype.hasOwnProperty('border') );
178 check( TextField.prototype.hasOwnProperty('borderColor') );
179 check( TextField.prototype.hasOwnProperty('bottomScroll') );
180 check( TextField.prototype.hasOwnProperty('embedFonts') );
181 check( TextField.prototype.hasOwnProperty('hscroll') );
182 check( TextField.prototype.hasOwnProperty('html') );
183 check( TextField.prototype.hasOwnProperty('htmlText') );
184 check( TextField.prototype.hasOwnProperty('length') );
185 check( TextField.prototype.hasOwnProperty('maxChars') );
186 check( TextField.prototype.hasOwnProperty('maxhscroll') );
187 check( TextField.prototype.hasOwnProperty('maxscroll') );
188 check( TextField.prototype.hasOwnProperty('multiline') );
189 check( TextField.prototype.hasOwnProperty('password') );
190 check( TextField.prototype.hasOwnProperty('restrict') );
191 check( TextField.prototype.hasOwnProperty('scroll') );
192 check( TextField.prototype.hasOwnProperty('selectable') );
193 check( TextField.prototype.hasOwnProperty('text') );
194 check( TextField.prototype.hasOwnProperty('textColor') );
195 check( TextField.prototype.hasOwnProperty('textHeight') );
196 check( TextField.prototype.hasOwnProperty('textWidth') );
197 check( TextField.prototype.hasOwnProperty('type') );
198 check( TextField.prototype.hasOwnProperty('variable') );
199 check( TextField.prototype.hasOwnProperty('wordWrap') );
200 check( TextField.prototype.hasOwnProperty('length') );
202 check( ! TextField.prototype.hasOwnProperty('valueOf') );
203 check( ! TextField.prototype.hasOwnProperty('toString') );
204 check( TextField.prototype.__proto__.hasOwnProperty('valueOf') );
205 check( TextField.prototype.__proto__.hasOwnProperty('toString') );
207 // Check TextField._alpha
209 check_equals(typeof(tf._alpha), 'number');
210 check( ! tf.hasOwnProperty('_alpha') );
211 check( ! tf.__proto__.hasOwnProperty('_alpha') );
213 // Check TextField.autoSize
215 check_equals(typeof(tf.autoSize), 'string');
216 check_equals(tf.autoSize, 'none'); // TODO: research which valid values we have
217 check(! tf.hasOwnProperty('autoSize'));
218 tf.autoSize = false;
219 check_equals(tf.autoSize, 'none'); // false is a synonim for 'none'
220 tf.autoSize = true;
221 check_equals(tf.autoSize, 'left'); // true is a synonim for 'left'
222 tf.autoSize = 'true';
223 check_equals(tf.autoSize, 'none'); // 'true' (as a string) is invalid, thus equivalent to 'none'
224 tf.autoSize = 'center';
225 check_equals(tf.autoSize, 'center'); // 'center' is a valid value
226 tf.autoSize = 'right';
227 check_equals(tf.autoSize, 'right'); // 'right' is a valid value
228 o = new Object(); o.toString = function() { return 'center'; };
229 tf.autoSize = o;
230 check_equals(tf.autoSize, 'center'); // toString is called for object args
231 tf.autoSize = 'lEft';
232 check_equals(tf.autoSize, 'left'); // arg is not case sensitive
233 tf.autoSize = new Boolean(true);
234 check_equals(tf.autoSize, 'none'); // a Boolean is the same as any other object
236 tf.autoSize = 'none';
238 // Check TextField.background
240 check_equals(typeof(tf.background), 'boolean');
241 check(!tf.hasOwnProperty('background'));
242 check_equals(tf.background, false);
243 tf.background = true;
244 check_equals(tf.background, true);
245 tf.background = 0;
246 check_equals(tf.background, false);
247 check_equals(typeof(tf.background), 'boolean');
248 tf.background = 54.3;
249 check_equals(typeof(tf.background), 'boolean');
250 check_equals(tf.background, true);
251 o = new Object; o.valueOf = function() { return 0x0000FF; };
252 tf.background = o;
253 check_equals(tf.background, true);
254 o = new Object; o.valueOf = function() { return 'string'; };
255 tf.background = o;
256 check_equals(typeof(tf.background), 'boolean');
257 check_equals(tf.background, true); // 'string' evaluates to true
258 tf.background = new Boolean(false);
259 check_equals(typeof(tf.background), 'boolean');
260 check_equals(tf.background, true); // dunno why, but Boolean evaluates to false
261 tf.background = false;
263 // Check TextField.backgroundColor
265 check_equals(typeof(tf.backgroundColor), 'number');
266 check(!tf.hasOwnProperty('backgroundColor'));
267 tf.backgroundColor = 0x00FF00;
268 check_equals(tf.backgroundColor, 0x00FF00);
269 tf.backgroundColor = 'red';
270 check_equals(tf.backgroundColor, 0x000000); // string value evaluates to NaN thus 0
271 o = new Object; o.valueOf = function() { return 0x0000FF; };
272 tf.backgroundColor = o;
273 check_equals(tf.backgroundColor, 0x0000FF); // valueOf is invoked
275 // Check TextField.border
277 check_equals(typeof(tf.border), 'boolean');
278 check(!tf.hasOwnProperty('border'));
280 // Check TextField.borderColor
282 check_equals(typeof(tf.borderColor), 'number');
283 check(!tf.hasOwnProperty('borderColor'));
285 // Check TextField.bottomScroll
287 check_equals(typeof(tf.bottomScroll), 'number');
288 check(!tf.hasOwnProperty('bottomScroll'));
289 check_equals(tf.bottomScroll, 1);
290 tf.bottomScroll = 100; // bottomScroll is read-only
291 check_equals(tf.bottomScroll, 1);
293 // Check TextField.embedFonts
295 check_equals(typeof(tf.embedFonts), 'boolean');
296 check(!tf.hasOwnProperty('embedFonts'));
297 check_equals(tf.embedFonts, false);
298 tf.embedFonts = true;
299 check_equals(tf.embedFonts, true);
300 tf.embedFonts = new Number(0); // will be converted to bool (true)
301 check_equals(typeof(tf.embedFonts), 'boolean');
302 check_equals(tf.embedFonts, true);
303 tf.embedFonts = ""; // will be converted to bool (false);
304 check_equals(typeof(tf.embedFonts), 'boolean');
305 check_equals(tf.embedFonts, false);
306 // TODO: do this test with really embedded fonts, in misc-ming.all/DefineEditTextTest.c
308 // Check TextField._highquality
310 check_equals(typeof(tf._highquality), 'number');
311 check(!tf.hasOwnProperty('_highquality'));
312 check(!tf.__proto__.hasOwnProperty('_highquality'));
313 check_equals(tf._highquality, 1);
314 tf._highquality = 0;
315 check_equals(tf._highquality, 0);
316 tf._highquality = 1;
318 // Check TextField._height (how is this different from textHeight?)
320 check_equals(typeof(tf._height), 'number');
321 check(!tf.hasOwnProperty('_height'));
322 check(!tf.__proto__.hasOwnProperty('_height'));
323 check_equals(tf._height, 500); // as we created it, see createTextField call
324 tf._height = 99999;
325 check_equals(tf._height, 99999);
326 tf._height = 500;
328 // Check TextField.hscroll
330 check_equals(typeof(tf.hscroll), 'number');
331 check(!tf.hasOwnProperty('hscroll'));
332 check_equals(tf.hscroll, 0);
333 tf.hscroll = 1;
334 xcheck_equals(tf.hscroll, 0);
335 tf.hscroll = 0;
337 // Check TextField.html
339 check_equals(typeof(tf.html), 'boolean');
340 check(!tf.hasOwnProperty('html'));
341 check_equals(tf.html, false);
342 tf.html = true;
343 check_equals(tf.html, true);
344 tf.html = false;
346 // Check TextField.htmlText (the displayed text in explicit HTML)
348 check_equals(typeof(tf.htmlText), 'string');
349 check(!tf.hasOwnProperty('htmlText'));
350 check_equals(tf.htmlText, '');
351 tf.htmlText = new Array;
352 check_equals(typeof(tf.htmlText), 'string'); // forced cast to string
353 check_equals(tf.htmlText, '');
354 check_equals(tf.html, false);
355 tf.htmlText = "Hello <b>html</b> world";
356 check_equals(tf.html, false); // assigning to htmlText doesn't change the 'html' flag
357 check_equals(tf.htmlText, 'Hello <b>html</b> world');
358 // Changing htmlText also changes text
359 check_equals(tf.text, 'Hello <b>html</b> world');
360 tf.text = "Hello world";
361 check_equals(tf.htmlText, 'Hello world');
363 //-------------------------------------------------------------------------
364 // Check TextField.length (number of characters in text)
365 //-------------------------------------------------------------------------
367 check_equals(typeof(tf.length), 'number');
368 check(!tf.hasOwnProperty('length'));
369 tf.text = "";
370 check_equals(tf.length, 0);
371 tf.length = 10; // you don't change lenght like this, you assign to text instead
372 check_equals(tf.length, 0);
373 tf.text = "Hello world";
374 check_equals(tf.length, 11);
375 tf.htmlText = "Hello <b>world</b>";
376 check_equals(tf.length, 18); // the tags are also counted
378 // Check TextField.maxChars
380 check_equals(typeof(tf.maxChars), 'null');
381 check(!tf.hasOwnProperty('maxChars'));
382 tf.maxChars = 5;
383 check_equals(tf.maxChars, 5);
384 tf.text = "0123456789";
385 // no effect (maybe only limits user input)
386 check_equals(tf.text, "0123456789");
387 tf.maxChars = "string";
388 check_equals(typeof(tf.maxChars), "null");
389 tf.maxChars = -6;
390 check_equals(typeof(tf.maxChars), "number");
391 check_equals(tf.maxChars, -6);
392 tf.maxChars = 0;
393 check_equals(typeof(tf.maxChars), "null");
395 tf.maxChars = null;
397 // Check TextField.maxhscroll
399 check_equals(typeof(tf.maxhscroll), 'number');
400 check(!tf.hasOwnProperty('maxhscroll'));
401 check_equals(tf.maxhscroll, 0);
402 tf.maxhscroll = 10;
403 check_equals(tf.maxhscroll, 0); // read-only
405 // Check TextField.maxscroll
407 check_equals(typeof(tf.maxscroll), 'number');
408 check(!tf.hasOwnProperty('maxscroll'));
409 check_equals(tf.maxscroll, 1);
410 tf.maxscroll = 10;
411 check_equals(tf.maxscroll, 1); // read-only
413 // Check TextField.multiline
415 check_equals(typeof(tf.multiline), 'boolean');
416 check_equals(tf.multiline, false);
417 check(!tf.hasOwnProperty('multiline'));
418 check_equals(tf.multiline, false);
419 tf.multiline = true;
420 check_equals(tf.multiline, true);
421 tf.multiline = 54;
422 check_equals(typeof(tf.multiline), 'boolean'); // always converted
423 tf.multiline = false;
425 //-------------------------------------------------------------------------
426 // Check TextField._name
427 //-------------------------------------------------------------------------
429 check_equals(typeof(tf._name), 'string');
430 check(!tf.hasOwnProperty('_name'));
431 check(!tf.__proto__.hasOwnProperty('_name'));
432 check_equals(tf._name, 'tf');
433 tfref = tf;
434 tf._name = 'changed';
435 check_equals(typeof(tf), 'undefined');
436 check_equals(typeof(tfref), 'object');
437 check_equals(tfref._name, 'changed');
438 check_equals(tfref._target, '/changed');
439 tfref._name = 'tf';
440 check_equals(typeof(tf), 'object');
441 check_equals(typeof(tfref), 'object');
442 // TODO: see effects of unloading the textfield ?
444 //-------------------------------------------------------------------------
445 // Check TextField._root and _global
446 //-------------------------------------------------------------------------
448 check(tf._root);
449 check_equals(_root, _root.tf._root);
451 check(tf._global);
452 check_equals(_global, _root.tf._global);
454 check(tf._level0);
456 // They would exist if they had been loaded...
457 check(!tf._level1);
458 check(!tf._level2);
460 #if OUTPUT_VERSION > 6
461 check(tf._root != tf._ROOT);
462 check(tf._root != tf._GLOBAL);
463 check(tf._level0 != tf._LEVEL0);
464 #endif
466 //-------------------------------------------------------------------------
467 // Check TextField._parent
468 //-------------------------------------------------------------------------
470 check_equals(typeof(tf._parent), 'movieclip');
471 check(!tf.hasOwnProperty('_parent'));
472 check(!tf.__proto__.hasOwnProperty('_parent'));
473 check_equals(tf._parent, _root);
474 bk = tf._parent;
475 tf._parent = 23;
476 xcheck_equals(tf._parent, 23); // can be overridden !
477 check_equals(tf._target, "/tf"); // but won't change _target
478 r = delete tf._parent;
479 xcheck(r);
480 r = delete tf._parent;
481 check(!r);
482 TextField.prototype._parent = "from proto";
483 check_equals(tf._parent, _root); // still unchanged
484 delete TextField.prototype._parent;
485 tf._parent = bk;
487 //-------------------------------------------------------------------------
488 // Check TextField.password
489 //-------------------------------------------------------------------------
491 // This verifies it really uses to_bool.
493 check_equals(typeof(tf.password), 'boolean');
494 check_equals(tf.password, false);
495 check(!tf.hasOwnProperty('password'));
496 check_equals(tf.password, false);
497 tf.password = true;
498 check_equals(tf.password, true);
499 tf.password = 7;
500 check_equals(tf.password, true);
501 tf.password = "string";
502 #if OUTPUT_VERSION > 6
503 check_equals(tf.password, true);
504 #else
505 check_equals(tf.password, false);
506 #endif
507 tf.password = 0;
508 check_equals(tf.password, false);
509 tf.password = "a string";
510 #if OUTPUT_VERSION > 6
511 check_equals(tf.password, true);
512 #else
513 check_equals(tf.password, false);
514 #endif
515 tf.password = undefined;
516 check_equals(tf.password, false);
517 // TODO: check effects of setting to 'password' (should hide characters)
518 tf.password = false;
520 // Check TextField.quality
522 // TODO: check this, might be a string
523 check_equals(typeof(tf._quality), 'string');
524 check(!tf.hasOwnProperty('_quality'));
525 check(!tf.__proto__.hasOwnProperty('_quality'));
526 check(!tf.__proto__.__proto__.hasOwnProperty('_quality'));
527 check(!tf.__proto__.__proto__.__proto__.hasOwnProperty('_quality'));
528 check_equals(tf._quality, "HIGH");
529 tf._quality = "FAKE VALUE";
530 check_equals(tf._quality, "HIGH");
531 tf._quality = "LOW";
532 check_equals(tf._quality, "LOW");
533 tf._quality = "HIGH";
535 // Check TextField.restrict (the set of characters a user can input)
537 check_equals(typeof(tf.restrict), 'null');
538 check(!tf.hasOwnProperty('restrict'));
539 check_equals(typeof(tf.restrict), 'null');
540 tf.text = "Hello World";
541 tf.restrict = "olH";
542 check_equals(typeof(tf.restrict), 'string');
543 check_equals(tf.text, "Hello World");
544 tf.text = "Hello World"; // override
545 // doesn't influence explicit setting, only GUI modification
546 // of the textfield (TODO: test with a MovieTester)
547 check_equals(tf.text, "Hello World");
549 tf.restrict = "";
550 check_equals(tf.restrict, "");
551 check_equals(typeof(tf.restrict), 'string');
552 tf.restrict = "ä";
553 check_equals(tf.restrict, "ä");
554 check_equals(typeof(tf.restrict), 'string');
556 tf.restrict = 9;
557 check_equals(tf.restrict, "9");
558 check_equals(typeof(tf.restrict), 'string');
560 o = {};
561 o.toString = function() { return "üöä"; };
562 o.valueOf = function() { return 8; };
564 tf.restrict = o;
565 check_equals(tf.restrict, "üöä");
566 check_equals(typeof(tf.restrict), 'string');
568 tf.restrict = null;
569 xcheck_equals(tf.restrict, null);
570 xcheck_equals(typeof(tf.restrict), "null");
572 // Check TextField._rotation
574 check_equals(typeof(tf._rotation), 'number');
575 check(!tf.hasOwnProperty('_rotation'));
576 check(!tf.__proto__.hasOwnProperty('_rotation'));
577 check_equals(tf._rotation, 0);
578 check_equals(tf._width, 500);
579 tf._rotation = 10;
580 check_equals(tf._rotation, 10);
581 check_equals(tf._width, 579.2);
582 check_equals(tf._xscale, 100.0);
583 tf._rotation = 0;
584 check_equals(tf._width, 500.0);
585 check_equals(tf._xscale, 100.0);
587 // Check TextField.scroll
589 // TODO: better test for this, might do nothing if there's no scrollin
590 check_equals(typeof(tf.scroll), 'number');
591 check( ! tf.hasOwnProperty('scroll') );
592 check_equals(tf.scroll, 1);
593 tf.scroll = 10;
594 xcheck_equals(tf.scroll, 1); // read-only // is it?
596 // Check TextField.selectable
598 check_equals(typeof(tf.selectable), 'boolean');
599 check( ! tf.hasOwnProperty('selectable') );
600 check_equals(tf.selectable, true);
601 tf.selectable = false;
602 check_equals(tf.selectable, false);
603 tf.selectable = "Hello";
604 check_equals(typeof(tf.selectable), 'boolean');
605 tf.selectable = true;
607 // Check TextField._soundbuftime
609 check_equals(typeof(tf._soundbuftime), 'number');
610 check( ! tf.hasOwnProperty('_soundbuftime') );
611 check( ! tf.__proto__.hasOwnProperty('_soundbuftime') );
612 xcheck_equals(tf._soundbuftime, 5); // the default is 5, it seems
614 // These seem to be only valid for MovieClips, but they are still read-only
615 check_equals(typeof(tf._currentframe), 'undefined');
616 tf._currentframe = "6";
617 check_equals(tf._currentframe, undefined);
619 check_equals(typeof(tf._totalframes), 'undefined');
620 tf._totalframes = 67;
621 check_equals(tf._totalframes, undefined);
623 check_equals(typeof(tf._framesloaded), 'undefined');
624 tf._framesloaded = "hi";
625 check_equals(tf._framesloaded, undefined);
627 // Check TextField._focusrect
628 check(tf._focusrect !== 'null');
629 check(tf._focusRect !== 'null');
630 check_equals(typeof(tf._focusrect), 'null');
631 check_equals(typeof(tf._focusRect), 'null');
632 check(! tf.hasOwnProperty('_focusrect') );
633 check(! tf.__proto__.hasOwnProperty('_focusrect') );
636 // Check TextField.tabEnabled
638 check_equals(typeof(tf.tabEnabled), 'undefined');
639 check( ! tf.hasOwnProperty('tabEnabled') );
640 check( ! tf.__proto__.hasOwnProperty('tabEnabled') );
641 tf.tabEnabled = false;
642 check_equals(tf.tabEnabled, false);
643 delete(tf.tabEnabled);
645 // Check TextField.tabIndex
647 check_equals(typeof(tf.tabIndex), 'undefined');
648 check( ! tf.hasOwnProperty('tabIndex') );
649 check( ! tf.__proto__hasOwnProperty('tabIndex') );
650 tf.tabIndex = 9;
651 check_equals(tf.tabIndex, 9);
652 delete(tf.tabIndex);
654 //-------------------------------------------------------------------------
655 // Check TextField._target
656 //-------------------------------------------------------------------------
658 check_equals(typeof(tf._target), 'string');
659 check( ! tf.hasOwnProperty('_target') );
660 check( ! tf.__proto__.hasOwnProperty('_target') );
661 check_equals(tf._target, '/tf');
662 // TODO: check the effect of changing _name on the _target value
663 tf._target = "fake_target"; // read-only
664 check_equals(tf._target, '/tf');
666 // Check TextField.text
668 check_equals(typeof(tf.text), 'string');
669 check( ! tf.hasOwnProperty('text') );
670 check_equals(tf.text, 'Hello World');
671 tf.text = "hello world";
672 check_equals(tf.text, 'hello world');
673 check_equals(tf.length, 11); // number of characters in "hello world"
676 // Check TextField.textColor
678 check_equals(typeof(tf.textColor), 'number');
679 check( ! tf.hasOwnProperty('textColor') );
680 check_equals(tf.textColor, 0);
681 tf.textColor = 0xFF0000;
682 check_equals(tf.textColor, 0xFF0000);
683 // TODO: check color (use misc-ming.all/DefineEditTextTest.swf and a test runner with check_pixel)
685 // Check TextField.textHeight (height of the bounding box)
687 check_equals(typeof(tf.textHeight), 'number');
688 check( ! tf.hasOwnProperty('textHeight') );
689 currentHeight = tf.textHeight; // WARNING: this might depend on the default font height
690 tf.textHeight = 1000;
691 check_equals(tf.textHeight, currentHeight); // was read-only (I think)
693 // Check TextField.textWidth (width of the bounding box)
695 check_equals(typeof(tf.textWidth), 'number');
696 check( ! tf.hasOwnProperty('textWidth') );
697 currentWidth = tf.textWidth; // WARNING: this might depend on the default font height
698 tf.textWidth = 1000;
699 check_equals(tf.textWidth, currentWidth); // was read-only (I think)
701 // Check TextField.type (input or dynamic)
703 check_equals(typeof(tf.type), 'string');
704 check( ! tf.hasOwnProperty('type') );
705 check_equals(tf.type, 'dynamic');
706 tf.type = "input";
707 check_equals(tf.type, 'input');
708 tf.type = new Array();
709 check_equals(typeof(tf.type), 'string'); // invalid assignment
710 check_equals(tf.type, 'input'); // keeps previous value
711 tf.type = "dynamic";
712 check_equals(tf.type, 'dynamic');
713 tf.type = new Array();
714 check_equals(tf.type, 'dynamic'); // keeps previous value
715 o = {}; o.toString = function() { return 'Input'; };
716 tf.type = o;
717 check_equals(tf.type, 'input');
719 // Check TextField._url (url of the SWF that created the textfield)
721 check_equals(typeof(tf._url), 'string');
722 check( ! tf.hasOwnProperty('_url') );
723 check( ! tf.__proto__.hasOwnProperty('_url') );
724 check_equals(tf._url, _root._url);
725 tf._url = "fake url";
726 check_equals(tf._url, _root._url); // read-only
728 //-------------------------------------------------------------------------
729 // Check TextField.variable (variable name associated with the textfield)
730 //-------------------------------------------------------------------------
732 // SUMMARY: write summary here
734 //-------------------------------------------------------------------------
736 check_equals(typeof(tf.variable), 'null');
737 check( ! tf.hasOwnProperty('variable') );
738 tf.variable = _level0.inputVar;
739 check_equals(typeof(tf.variable), 'null'); // _level0.inputVar doesn't exist !
740 tf.variable = 2;
741 check_equals(typeof(tf.variable), 'string');
742 check_equals(tf.variable, '2');
743 tf.variable = undefined;
744 check_equals(typeof(tf.variable), 'null');
745 tf.variable = 2;
746 tf.variable = null;
747 check_equals(typeof(tf.variable), 'null');
748 tf.variable = "_level0.inputVar";
749 check_equals(tf.variable, '_level0.inputVar');
750 xcheck_equals(typeof(_level0.inputVar), 'undefined');
751 check_equals(tf.text, "hello world"); // as _level0.inputVar is unexistent
752 xcheck(!_level0.hasOwnProperty('inputVar'));
753 _level0.inputVar = "dynamic variable";
754 check_equals(tf.text, "dynamic variable");
755 tf.text = "back-propagated";
756 check_equals(_level0.inputVar, "back-propagated");
757 o = new Object();
758 tf.variable = "_level0.o.t"; // non-existent member (yet)
759 check_equals(tf.text, "back-propagated"); // _level0.o.t doesn't exist yet
760 o.t = "from object"; // here we create _level0.o.t
761 check_equals(tf.text, "back-propagated"); // but creating _level0.o.t doesn't trigger textfield text update
762 tf.text = "back-to-object"; // instead, assigning to TextField.text updates the object
763 check_equals(o.t, "back-to-object");
764 o.t = "from object again"; // but updates to the object still don't update the TextField
765 check_equals(tf.text, "back-to-object"); // assigning to the object doesn't trigger update of text ?
766 tf.variable = "_level0.o.t"; // We re-assign TextField.variable, now the variable exists
767 xcheck_equals(tf.text, "from object again"); // this time the TextField.text is updated
768 check_equals(o.t, "from object again");
769 o.t = "and forever";
770 xcheck_equals(tf.text, "from object again"); // but updating o.t still doesn't trigger update of the text ?
771 tf.text = "and forever back";
772 check_equals(o.t, "and forever back"); // while updating textfield's text updates o.t
774 // Test value of variable if the property is present but undefined.
776 mc45 = _root.createEmptyMovieClip("mc45", getNextHighestDepth());
777 mc45.createTextField("tf45", 0, 0, 100, 100, getNextHighestDepth());
778 mc45.tf45.variable = "_root.mc45.vari";
779 _root.mc45.vari = undefined;
780 #if OUTPUT_VERSION < 7
781 check_equals(mc45.tf45.text, "");
782 #else
783 check_equals(mc45.tf45.text, "undefined");
784 #endif
786 //-------------------------------------------------------------------------
787 // TODO: check TextField.getDepth()
788 //-------------------------------------------------------------------------
790 //-------------------------------------------------------------------------
791 // Check TextField.removeTextField and soft references
792 //-------------------------------------------------------------------------
794 // TextField as_value references are soft references like MovieClip ones.
795 // Till the ref is not danglign, typeof(ref) will return 'object', once
796 // the ref is dangling it will return 'movieclip' and will successfully
797 // rebind to a real MovieClip ! When rebound, typeof(ref) will return 'object'
798 // or 'movieclip' depending on the bound thing.
800 //-------------------------------------------------------------------------
802 createTextField("hardref", 23, 10, 10, 160, 200);
803 hardref.prop = 5;
804 softref = hardref;
805 check_equals(typeof(hardref), 'object');
806 check_equals(typeof(softref), 'object');
807 check_equals(softref.prop, 5);
808 check_equals(softref.getDepth(), 23);
809 hardref.removeTextField();
810 check_equals(typeof(hardref), 'undefined');
811 check_equals(typeof(softref), 'movieclip'); // a dangling character ref is always reported to be a 'movieclip' (historical reasons probably)
812 check_equals(typeof(softref.prop), 'undefined');
813 createEmptyMovieClip("hardref", 24);
814 check_equals(typeof(hardref), 'movieclip');
815 hardref.prop = 7;
816 check_equals(typeof(softref), 'movieclip');
817 check_equals(softref.prop, 7); // and it's actually also rebound to one if available
818 hardref.removeMovieClip();
819 createTextField("hardref", 25, 10, 10, 160, 200);
820 hardref.prop = 9;
821 check_equals(typeof(softref), 'object'); // changes type on rebind
822 check_equals(softref.prop, 9);
825 //-------------------------------------------------------------------------
826 // Check TextField._visible
827 //-------------------------------------------------------------------------
829 check_equals(typeof(tf._visible), 'boolean');
830 check( ! tf.hasOwnProperty('_visible') );
831 check( ! tf.__proto__.hasOwnProperty('_visible') );
832 check_equals(tf._visible, true);
833 tf._visible = false;
834 check_equals(tf._visible, false);
835 tf._visible = true;
837 //-------------------------------------------------------------------------
838 // Check TextField._width (how is this different from textWidth ?)
839 //-------------------------------------------------------------------------
841 check_equals(typeof(tf._width), 'number');
842 check( ! tf.hasOwnProperty('_width') );
843 check( ! tf.__proto__.hasOwnProperty('_width') );
844 check_equals(tf._width, 500); // as it was set by createTextField, see above
845 tf._width = 99999;
846 check_equals(tf._width, 99999);
847 b = tf.getBounds(_root); bs = printBounds(b);
848 check_equals(bs, 'xmin:10 ymin:10 xmax:100009 ymax:510');
849 tf.autoSize = false;
850 tf.text = 'small'; // doesn't reset bounds (being autoSize false);
851 check_equals(tf._width, 99999);
852 b = tf.getBounds(_root); bs = printBounds(b);
853 check_equals(bs, 'xmin:10 ymin:10 xmax:100009 ymax:510');
855 tf.autoSize = true; // changes width !!
856 check(tf._width < 99999);
857 ow = tf._width;
859 tf.autoSize = false; // doesn't reset to last manually set one
860 check_equals(tf._width, ow);
862 tf._width = 500;
864 //-------------------------------------------------------------------------
865 // Check TextField.wordWrap (should text wrap when bbox limit is hit?)
866 //-------------------------------------------------------------------------
868 check_equals(typeof(tf.wordWrap), 'boolean');
869 check( ! tf.hasOwnProperty('wordWrap') );
870 check_equals(tf.wordWrap, false);
871 // TODO: check what can be assigned to wordWrap and what not...
873 //-------------------------------------------------------------------------
874 // Check TextField._x
875 //-------------------------------------------------------------------------
877 check_equals(typeof(tf._x), 'number');
878 check_equals(typeof(tf._X), 'number');
879 check( ! tf.hasOwnProperty('_x') );
880 check( ! tf.__proto__.hasOwnProperty('_x') );
881 check_equals(tf._x, 10); // as set by createTextField
882 tf._x = 20;
883 check_equals(tf._x, 20);
885 //-------------------------------------------------------------------------
886 // Check TextField._xmouse
887 //-------------------------------------------------------------------------
889 check_equals(typeof(tf._xmouse), 'number');
890 check( ! tf.hasOwnProperty('_xmouse') );
891 check( ! tf.__proto__.hasOwnProperty('_xmouse') );
892 currXmouse = tf._xmouse; // unsafe, if user moves the mouse while running the test
893 tf._xmouse = "a string";
894 check_equals(typeof(tf._xmouse), 'number');
895 check_equals(tf._xmouse, currXmouse); // possibly unsafe, if user moves the mouse while running the test
897 //-------------------------------------------------------------------------
898 // Check TextField._xscale
899 //-------------------------------------------------------------------------
901 check_equals(typeof(tf._xscale), 'number');
902 check( ! tf.hasOwnProperty('_xscale') );
903 check( ! tf.__proto__.hasOwnProperty('_xscale') );
904 check_equals(tf._xscale, 100);
905 // check how .textWidth and ._width change when changing _xscale
906 currTextWidth = tf.textWidth;
907 currWidth = tf._width;
908 tf._xscale = 200;
909 note("textWidth: _xscale=100: "+currTextWidth+"; _xscale=200: "+tf.textWidth);
910 // check_equals(tf.textWidth, currTextWidth*2); // not clear what does textWidth depend on
911 check_equals(tf._width, currWidth*2);
912 tf._xscale = 100;
914 //-------------------------------------------------------------------------
915 // Check TextField._y
916 //-------------------------------------------------------------------------
918 check_equals(typeof(tf._y), 'number');
919 check( ! tf.hasOwnProperty('_y') );
920 check( ! tf.__proto__.hasOwnProperty('_y') );
921 check_equals(tf._y, 10); // as set by createTextField
922 tf._y = 5;
923 check_equals(tf._y, 5);
925 //-------------------------------------------------------------------------
926 // Check TextField._ymouse
927 //-------------------------------------------------------------------------
929 check_equals(typeof(tf._ymouse), 'number');
930 check( ! tf.hasOwnProperty('_ymouse') );
931 check( ! tf.__proto__.hasOwnProperty('_ymouse') );
932 currYmouse = tf._ymouse;
933 tf._ymouse = "a string";
934 check_equals(typeof(tf._ymouse), 'number');
935 check_equals(tf._ymouse, currYmouse); // possibly unsafe, if user moves the mouse while running the test
937 //-------------------------------------------------------------------------
938 // Check TextField._yscale
939 //-------------------------------------------------------------------------
941 check_equals(typeof(tf._yscale), 'number');
942 check( ! tf.hasOwnProperty('_yscale') );
943 check( ! tf.__proto__.hasOwnProperty('_yscale') );
944 check_equals(tf._yscale, 100);
945 // check how .textHeight and ._height change based on _yscale
946 currTextHeight = tf.textHeight;
947 currHeight = tf._height;
948 tf._yscale = 200;
949 note("textHeight: _yscale=100: "+currTextHeight+"; _yscale=200: "+tf.textHeight);
950 // check_equals(tf.textHeight, currTextHeight*2); // not clear what does textHeight depend on
951 check_equals(tf._height, currHeight*2);
952 tf._yscale = 100;
954 //-------------------------------------------------------------------------
955 // Check interaction between autoSize and _width and wordWrap
956 //-------------------------------------------------------------------------
958 tf._width = 10; // "hello world" text should overflow this
959 tf.text = "Hello world";
960 tf.autoSize = 'none';
961 tf.wordWrap = false;
962 check_equals(tf._width, 10);
963 origTextWidth = tf.textWidth;
964 tf.autoSize = 'center';
965 check(tf._width > 10);
966 check_equals(tf.textWidth, origTextWidth); // textWidth isn't influenced by autoSize
967 tf.autoSize = 'none';
968 tf.wordWrap = true;
969 note("After setting wordWrap flat: textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
970 check_equals(tf.textWidth, origTextWidth);
971 tf._width = 10;
972 note("After reducing _width: textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
973 check_equals(tf._width, 10);
975 #if OUTPUT_VERSION < 8
976 check_equals(origTextWidth, tf.textWidth);
977 #else
978 xcheck(origTextWidth > tf.textWidth);
979 #endif
981 // test that adding a newline doesn't change the bounds width
982 // see bug #22216
983 tf.autoSize = 'center';
985 // Word wrap is still true, so nothing should happen!
986 check_equals(tf._width, 10);
987 tf.text = "single line";
989 // Changing text should also not change width.
990 check_equals(tf._width, 10);
992 linewidth = tf._width;
993 tf.text = "single line\n";
995 check_equals(tf._width, 10);
996 check_equals(tf._width, linewidth);
998 // Test that setting autoSize = none
999 // doesn't reset the bounding box.
1000 // See bug #24266
1002 oldwidth = tf._width;
1003 note("width: "+oldwidth);
1004 check(oldwidth>0); // or the test is invalid
1005 tf.autoSize = 'none'; // tf was created with bounds 0,0
1006 check_equals(tf._width, oldwidth); // but _width didn't change to that
1008 // Test that when autoSize != none,
1009 // and wordWrap is true, text box isn't
1010 // reset. See #24348
1012 tf.wordWrap = false;
1013 check_equals(tf._width, oldwidth); // text takes more width with wordWrap false
1014 note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
1015 tf.autoSize = 'center';
1016 note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
1017 check(tf._width > oldwidth);
1018 oldwidth = tf._width;
1019 tf.wordWrap = true;
1020 note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
1021 check_equals(tf._width, oldwidth); // wordWrap change didn't reset the bbox
1024 //------------------------------------------------------------
1025 // Test insane calls
1026 //------------------------------------------------------------
1028 ret = createTextField("tf2", 99, 5, 6, -1, -2);
1029 check_equals(typeof(tf2), 'object');
1030 check_equals(tf2._width, 1);
1031 check_equals(tf2._height, 2);
1032 check_equals(tf2._x, 5);
1033 check_equals(tf2._y, 6);
1035 createTextField("tf3", 99, 10.87, 10.12, NAN, 50.74);
1036 check_equals(tf3._x, 10);
1037 check_equals(tf3._y, 10);
1038 check_equals(tf3._width, 0);
1039 check_equals(tf3._height, 50);
1041 createTextField("tf4", 99, 10, 50, NAN, "20");
1042 check_equals(tf4._width, 0);
1043 check_equals(tf4._height, 20);
1045 createTextField(3, "101", "10", '100', '32', '15');
1046 check_equals(_root[3].getDepth(), 101);
1047 check_equals(_root[3]._x, 10);
1048 check_equals(_root[3]._y, 100);
1049 check_equals(_root[3]._width, 32);
1050 check_equals(_root[3]._height, 15);
1052 // One argument more
1053 createTextField("tf5", 102, 10, 130, 3, 2, 12);
1054 check_equals(tf5._name, "tf5");
1055 check_equals(tf5._target, "/tf5");
1056 check_equals(tf5.getDepth(), 102);
1057 check_equals(tf5._x, 10);
1058 check_equals(tf5._y, 130);
1059 check_equals(tf5._width, 3);
1060 check_equals(tf5._height, 2);
1062 // One argument missing
1063 createTextField("tf6", 103, 10, 10, 160);
1064 check_equals(typeof(tf6), 'undefined');
1066 /// Test TextField.replaceSel
1068 createTextField('repl1', 99, 10, 10, 10, 10);
1069 Selection.setFocus(repl1);
1070 check_equals(Selection.getFocus(), '_level0.repl1');
1071 repl1.text = "Text in a string";
1073 ret = repl1.replaceSel("More ");
1074 /// Check that the selection start and end indices are adjusted.
1075 check_equals(Selection.getBeginIndex(), 5);
1076 check_equals(Selection.getEndIndex(), 5);
1077 check_equals(repl1.text, "More Text in a string");
1079 ret = repl1.replaceSel("");
1080 check_equals(Selection.getEndIndex(), 5);
1081 check_equals(repl1.text, "More Text in a string");
1084 Selection.setSelection(0, 1);
1085 ret = repl1.replaceSel("HU");
1086 check_equals(ret, undefined);
1087 check_equals(repl1.text, "HUore Text in a string");
1089 check_equals(Selection.getBeginIndex(), 2);
1090 check_equals(Selection.getEndIndex(), 2);
1092 Selection.setSelection(2, 5);
1093 ret = repl1.replaceSel("HUU");
1094 check_equals(ret, undefined);
1095 check_equals(repl1.text, "HUHUU Text in a string");
1097 check_equals(Selection.getBeginIndex(), 5);
1098 check_equals(Selection.getEndIndex(), 5);
1100 Selection.setSelection(10, 13);
1101 repl1.replaceSel(7);
1102 check_equals(repl1.text, "HUHUU Text7 a string");
1103 check_equals(Selection.getBeginIndex(), 11);
1104 check_equals(Selection.getEndIndex(), 11);
1106 Selection.setSelection(10, 13);
1107 repl1.replaceSel(new Object());
1108 check_equals(repl1.text, "HUHUU Text[object Object] string");
1109 check_equals(Selection.getBeginIndex(), 25);
1110 check_equals(Selection.getEndIndex(), 25);
1112 Selection.setSelection(1, 20);
1113 repl1.replaceSel("");
1114 #if OUTPUT_VERSION < 8
1115 check_equals(repl1.text, "HUHUU Text[object Object] string");
1116 check_equals(Selection.getBeginIndex(), 1);
1117 check_equals(Selection.getEndIndex(), 20);
1118 #else
1119 check_equals(repl1.text, "Hject] string");
1120 check_equals(Selection.getBeginIndex(), 1);
1121 check_equals(Selection.getEndIndex(), 1);
1122 #endif
1124 repl1.text = "New text";
1126 Selection.setSelection(2, 5);
1127 repl1.replaceSel();
1128 check_equals(repl1.text, "New text");
1129 check_equals(Selection.getBeginIndex(), 2);
1130 check_equals(Selection.getEndIndex(), 5);
1132 //------------------------------------------------------------
1133 // Test TextField.replaceText
1134 //------------------------------------------------------------
1136 #if OUTPUT_VERSION > 6
1137 createTextField ("t", 0, 0, 0, 200, 150);
1138 check_equals(t.text, '');
1139 r = t.replaceText();
1140 check_equals(typeof(r), 'undefined');
1141 check_equals(t.text, '');
1142 r = t.replaceText(0, 0);
1143 check_equals(typeof(r), 'undefined');
1144 check_equals(t.text, '');
1145 r = t.replaceText(0, 0, 'a');
1146 check_equals(typeof(r), 'undefined');
1147 check_equals(t.text, 'a');
1148 r = t.replaceText(0, 0, 'b');
1149 check_equals(t.text, 'ba');
1150 t.replaceText(-1, 0, 'c');
1151 check_equals(t.text, 'ba');
1152 t.replaceText(0, 5, 'd');
1153 check_equals(t.text, 'd');
1154 t.replaceText(-1, 5, 'e');
1155 check_equals(t.text, 'd');
1156 t.replaceText(1, 5, 'f');
1157 check_equals(t.text, 'df');
1158 t.replaceText(0, 5, 'ϦeϦ');
1159 check_equals(t.text, 'ϦeϦ');
1160 t.replaceText(1, 1, 'h');
1161 check_equals(t.text, 'ϦheϦ');
1162 t.replaceText(4, 4, 'h');
1163 check_equals(t.text, 'ϦheϦh');
1164 t.replaceText(4, 4, undef);
1165 check_equals(t.text, 'ϦheϦundefinedh');
1166 t.replaceText(3, 10, 't');
1167 check_equals(t.text, 'Ϧhetnedh');
1168 t.replaceText(3, -1, 'y');
1169 check_equals(t.text, 'Ϧhetnedh');
1170 // TODO: check registered variables
1171 #endif
1173 //------------------------------------------------------------
1174 // Test properties
1175 //------------------------------------------------------------
1177 _root._visible = true; // just to be sure
1178 _root._xscale = _root._yscale = 100;
1179 _root.createTextField('htf',0,0,0,0,0);
1180 check_equals(typeof(htf), 'object');
1181 tf = htf;
1182 with(tf) {
1183 _x=10;
1184 _y=11;
1185 _visible=false;
1186 _xscale=200;
1187 _yscale=201;
1188 _parent='fake_parent';
1189 _name='fake_name';
1190 _target='fake';
1193 check_equals(_root._x, 0);
1194 check_equals(_root._y, 0);
1195 check_equals(_root._visible, true);
1196 check_equals(_root._xscale, 100);
1197 check_equals(_root._yscale, 100);
1198 check_equals(_root._target, '/');
1199 xcheck_equals(_root._parent, 'fake_parent');
1200 check_equals(_root._name, '');
1202 check_equals(tf._x, 10);
1203 check_equals(tf._y, 11);
1204 check_equals(tf._visible, false);
1205 check_equals(tf._xscale, 200);
1206 check_equals(tf._yscale, 201);
1207 check_equals(tf._target, '/fake_name');
1208 check_equals(tf._parent, _level0);
1209 check_equals(tf._name, 'fake_name');
1211 _root._visible = true;
1212 _root._x = _root._y = 0;
1213 _root._xscale = _root._yscale = 100;
1216 // Check that "new _global.TextField()" is called in createTextField
1218 backup = _global.TextField;
1219 count = 0;
1220 args = 0;
1222 storedthis = undefined;
1224 _global.TextField = function() {
1225 storedthis = this;
1226 this.bo = "stringo";
1227 args = arguments.length;
1228 count++;
1231 TextField.prototype = {};
1232 TextField.prototype.toString = function() { return "Hoppla!"; };
1234 // The fact that createTextField works even when _global.TextField is
1235 // replaced shows that the native functions (making into a real TextField)
1236 // is done in createTextField.
1237 r = _root.createTextField("tfmo", 2, 2, 10, 10, 6);
1238 check_equals(count, 1);
1239 check_equals(args, 0);
1240 check_equals(_root.tfmo._x, 2);
1242 /// The returned object is still the this pointer that our fake constructor
1243 /// worked on.
1244 check_equals(_root.tfmo, storedthis);
1245 xcheck(_root.tfmo === storedthis);
1247 check_equals(_root.tfmo.bo, "stringo");
1248 check(_root.tfmo.hasOwnProperty("bo"));
1250 // Not sure why this isn't the case for version 6 or 7.
1251 #if OUTPUT_VERSION >= 8
1252 check_equals(r.toString(), "Hoppla!");
1253 #else
1254 check_equals(r.toString(), undefined);
1255 #endif
1257 _global.TextField = backup;
1259 // So if createTextField calls the TextField ctor, what does that constructor
1260 // do?
1262 // This only confirms that the TextField constructor a) removes the
1263 // array typing, b) removes the relay, and c) doesn't produce a
1264 // DisplayObject. We still don't have a way to check what happens
1265 // inside createTextField.
1267 CTF = function () {
1269 // We are called with 'new'.
1270 fun = ASnative(2, 0);
1271 xcheck_equals(fun(), true);
1273 backup = this;
1274 this.__proto__.__constructor__ = Array;
1275 super ();
1276 check_equals(this.length, 0);
1278 // It's not a proper TextField.
1279 this.__proto__.__constructor__ = TextField;
1280 super ();
1281 check_equals(backup, this);
1282 check_equals(this.length, 0);
1283 check_equals(this._x, undefined);
1284 check_equals(this._visible, undefined);
1285 check_equals(this._width, undefined);
1287 // It is no longer an array.
1288 this[2] = 3;
1289 check_equals(this.length, 0);
1290 check_equals(this[2], 3);
1292 this.__proto__.__constructor__ = Date;
1293 this.getTime = Date.prototype.getTime;
1294 super();
1295 check_equals(typeof(this.getTime()), "number");
1297 this.__proto__.__constructor__ = TextField;
1298 super();
1299 check_equals(typeof(this.getTime()), "undefined");
1303 o = new CTF();
1305 //------------------------------------------------------------
1306 // END OF TESTS
1307 //------------------------------------------------------------
1309 #if OUTPUT_VERSION == 6
1310 check_totals(531);
1311 #elif OUTPUT_VERSION == 7
1312 check_totals(555);
1313 #elif OUTPUT_VERSION == 8
1314 check_totals(556);
1315 #endif
1317 #endif