2 // Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
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.
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
="$Id: TextField.as,v 1.56 2008/06/05 03:26:32 zoulunkai Exp $";
26 printBounds
= function(b
)
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
),
46 note
(_level0
.__shared_assets
.instance1
._xtrace_win
.toString
());
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);
59 xcheck
(tf instanceOf
TextField);
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');
117 check_equals
(typeof(TextField.prototype
.getFontList
), 'undefined');
119 check
(TextField.prototype
.hasOwnProperty
('replaceText'));
120 #if OUTPUT_VERSION
> 6
121 check_equals
(typeof(TextField.prototype
.replaceText
), 'function');
123 check_equals
(typeof(TextField.prototype
.replaceText
), 'undefined');
127 tfObj
= new TextField();
128 check_equals
(typeof(tfObj
), 'object');
129 check
(tfObj
instanceof TextField);
131 check_equals
(typeof(tfObj
.setTextFormat
), 'function');
132 check_equals
(typeof(tfObj
.getTextFormat
), 'function');
133 check_equals
(typeof(tfObj
.setNewTextFormat
), 'function');
134 check_equals
(typeof(tfObj
.getNewTextFormat
), 'function');
135 check_equals
(typeof(tfObj
.addListener
), 'function');
136 check_equals
(typeof(tfObj
.removeListener
), 'function');
137 check_equals
(typeof(tfObj
.getDepth
), 'function');
138 check_equals
(typeof(tfObj
.removeTextField
), 'function');
139 check_equals
(typeof(tfObj
.replaceSel
), 'function');
140 // this is a static method, it's available as TextField.getFontList
141 check_equals
(typeof(tfObj
.getFontList
), 'undefined');
142 check_equals
(typeof(tfObj
._parent
), 'undefined'); // no parent
144 //--------------------------------------------------
145 // Check textfield creation trough createTextField
146 //--------------------------------------------------
148 ret
= createTextField
("tf", 99, 10, 10, 500, 500);
149 #if OUTPUT_VERSION
< 8
150 check_equals
(typeof(ret
), 'undefined');
152 check_equals
(typeof(ret
), 'object');
153 check_equals
(ret
, _root
.tf
);
156 check
(tf
instanceof TextField);
157 check_equals
(typeof(tf
), 'object');
158 check
(tf
.hasOwnProperty
('_listeners'));
159 check_equals
(tf
._listeners
.length
, 1); // adds self to the listeners
160 check_equals
(tf
._listeners
[0], tf
); // adds self to the listeners set
161 check
(!tf
.hasOwnProperty
('broadcastMessage'));
162 check
(!tf
.hasOwnProperty
('addListener'));
163 check
(!tf
.hasOwnProperty
('removeListener'));
165 // NOTE: the following were false before the call to createTextField ! Seek backward to see..
166 check
( TextField.prototype
.hasOwnProperty
('background'));
167 check
( TextField.prototype
.hasOwnProperty
('backgroundColor'));
168 check
( TextField.prototype
.hasOwnProperty
('autoSize') );
169 check
( TextField.prototype
.hasOwnProperty
('border') );
170 check
( TextField.prototype
.hasOwnProperty
('borderColor') );
171 check
( TextField.prototype
.hasOwnProperty
('bottomScroll') );
172 check
( TextField.prototype
.hasOwnProperty
('embedFonts') );
173 check
( TextField.prototype
.hasOwnProperty
('hscroll') );
174 check
( TextField.prototype
.hasOwnProperty
('html') );
175 check
( TextField.prototype
.hasOwnProperty
('htmlText') );
176 check
( TextField.prototype
.hasOwnProperty
('length') );
177 check
( TextField.prototype
.hasOwnProperty
('maxChars') );
178 check
( TextField.prototype
.hasOwnProperty
('maxhscroll') );
179 check
( TextField.prototype
.hasOwnProperty
('maxscroll') );
180 check
( TextField.prototype
.hasOwnProperty
('multiline') );
181 check
( TextField.prototype
.hasOwnProperty
('password') );
182 check
( TextField.prototype
.hasOwnProperty
('restrict') );
183 check
( TextField.prototype
.hasOwnProperty
('scroll') );
184 check
( TextField.prototype
.hasOwnProperty
('selectable') );
185 check
( TextField.prototype
.hasOwnProperty
('text') );
186 check
( TextField.prototype
.hasOwnProperty
('textColor') );
187 check
( TextField.prototype
.hasOwnProperty
('textHeight') );
188 check
( TextField.prototype
.hasOwnProperty
('textWidth') );
189 check
( TextField.prototype
.hasOwnProperty
('type') );
190 check
( TextField.prototype
.hasOwnProperty
('variable') );
191 check
( TextField.prototype
.hasOwnProperty
('wordWrap') );
192 check
( TextField.prototype
.hasOwnProperty
('length') );
194 check
( ! TextField.prototype
.hasOwnProperty
('valueOf') );
195 check
( ! TextField.prototype
.hasOwnProperty
('toString') );
196 check
( TextField.prototype
.__proto__
.hasOwnProperty
('valueOf') );
197 check
( TextField.prototype
.__proto__
.hasOwnProperty
('toString') );
199 // Check TextField._alpha
201 check_equals
(typeof(tf
._alpha
), 'number');
202 check
( ! tf
.hasOwnProperty
('_alpha') );
203 check
( ! tf
.__proto__
.hasOwnProperty
('_alpha') );
205 // Check TextField.autoSize
207 check_equals
(typeof(tf
.autoSize
), 'string');
208 check_equals
(tf
.autoSize
, 'none'); // TODO: research which valid values we have
209 check
(! tf
.hasOwnProperty
('autoSize'));
211 check_equals
(tf
.autoSize
, 'none'); // false is a synonim for 'none'
213 check_equals
(tf
.autoSize
, 'left'); // true is a synonim for 'left'
214 tf
.autoSize
= 'true';
215 check_equals
(tf
.autoSize
, 'none'); // 'true' (as a string) is invalid, thus equivalent to 'none'
216 tf
.autoSize
= 'center';
217 check_equals
(tf
.autoSize
, 'center'); // 'center' is a valid value
218 tf
.autoSize
= 'right';
219 check_equals
(tf
.autoSize
, 'right'); // 'right' is a valid value
220 o
= new Object(); o
.toString
= function() { return 'center'; };
222 check_equals
(tf
.autoSize
, 'center'); // toString is called for object args
223 tf
.autoSize
= 'lEft';
224 check_equals
(tf
.autoSize
, 'left'); // arg is not case sensitive
225 tf
.autoSize
= new Boolean(true);
226 check_equals
(tf
.autoSize
, 'none'); // a Boolean is the same as any other object
228 tf
.autoSize
= 'none';
230 // Check TextField.background
232 check_equals
(typeof(tf
.background
), 'boolean');
233 check
(!tf
.hasOwnProperty
('background'));
234 check_equals
(tf
.background
, false);
235 tf
.background
= true;
236 check_equals
(tf
.background
, true);
238 check_equals
(tf
.background
, false);
239 check_equals
(typeof(tf
.background
), 'boolean');
240 tf
.background
= 54.3;
241 check_equals
(typeof(tf
.background
), 'boolean');
242 check_equals
(tf
.background
, true);
243 o
= new Object; o
.valueOf
= function() { return 0x0000FF; };
245 check_equals
(tf
.background
, true);
246 o
= new Object; o
.valueOf
= function() { return 'string'; };
248 check_equals
(typeof(tf
.background
), 'boolean');
249 check_equals
(tf
.background
, true); // 'string' evaluates to true
250 tf
.background
= new Boolean(false);
251 check_equals
(typeof(tf
.background
), 'boolean');
252 check_equals
(tf
.background
, true); // dunno why, but Boolean evaluates to false
253 tf
.background
= false;
255 // Check TextField.backgroundColor
257 check_equals
(typeof(tf
.backgroundColor
), 'number');
258 check
(!tf
.hasOwnProperty
('backgroundColor'));
259 tf
.backgroundColor
= 0x00FF00;
260 check_equals
(tf
.backgroundColor
, 0x00FF00);
261 tf
.backgroundColor
= 'red';
262 check_equals
(tf
.backgroundColor
, 0x000000); // string value evaluates to NaN thus 0
263 o
= new Object; o
.valueOf
= function() { return 0x0000FF; };
264 tf
.backgroundColor
= o
;
265 check_equals
(tf
.backgroundColor
, 0x0000FF); // valueOf is invoked
267 // Check TextField.border
269 check_equals
(typeof(tf
.border
), 'boolean');
270 check
(!tf
.hasOwnProperty
('border'));
272 // Check TextField.borderColor
274 check_equals
(typeof(tf
.borderColor
), 'number');
275 check
(!tf
.hasOwnProperty
('borderColor'));
277 // Check TextField.bottomScroll
279 check_equals
(typeof(tf
.bottomScroll
), 'number');
280 check
(!tf
.hasOwnProperty
('bottomScroll'));
281 check_equals
(tf
.bottomScroll
, 1);
282 tf
.bottomScroll
= 100; // bottomScroll is read-only
283 check_equals
(tf
.bottomScroll
, 1);
285 // Check TextField.embedFonts
287 check_equals
(typeof(tf
.embedFonts
), 'boolean');
288 check
(!tf
.hasOwnProperty
('embedFonts'));
289 check_equals
(tf
.embedFonts
, false);
290 tf
.embedFonts
= true;
291 check_equals
(tf
.embedFonts
, true);
292 tf
.embedFonts
= new Number(0); // will be converted to bool (true)
293 check_equals
(typeof(tf
.embedFonts
), 'boolean');
294 check_equals
(tf
.embedFonts
, true);
295 tf
.embedFonts
= ""; // will be converted to bool (false);
296 check_equals
(typeof(tf
.embedFonts
), 'boolean');
297 check_equals
(tf
.embedFonts
, false);
298 // TODO: do this test with really embedded fonts, in misc-ming.all/DefineEditTextTest.c
300 // Check TextField._highquality
302 check_equals
(typeof(tf
._highquality
), 'number');
303 check
(!tf
.hasOwnProperty
('_highquality'));
304 check
(!tf
.__proto__
.hasOwnProperty
('_highquality'));
305 check_equals
(tf
._highquality
, 1);
307 check_equals
(tf
._highquality
, 0);
310 // Check TextField._height (how is this different from textHeight?)
312 check_equals
(typeof(tf
._height
), 'number');
313 check
(!tf
.hasOwnProperty
('_height'));
314 check
(!tf
.__proto__
.hasOwnProperty
('_height'));
315 check_equals
(tf
._height
, 500); // as we created it, see createTextField call
317 check_equals
(tf
._height
, 99999);
320 // Check TextField.hscroll
322 check_equals
(typeof(tf
.hscroll
), 'number');
323 check
(!tf
.hasOwnProperty
('hscroll'));
324 check_equals
(tf
.hscroll
, 0);
326 xcheck_equals
(tf
.hscroll
, 0);
329 // Check TextField.html
331 check_equals
(typeof(tf
.html
), 'boolean');
332 check
(!tf
.hasOwnProperty
('html'));
333 check_equals
(tf
.html
, false);
335 check_equals
(tf
.html
, true);
338 // Check TextField.htmlText (the displayed text in explicit HTML)
340 check_equals
(typeof(tf
.htmlText
), 'string');
341 check
(!tf
.hasOwnProperty
('htmlText'));
342 check_equals
(tf
.htmlText
, '');
343 tf
.htmlText
= new Array;
344 check_equals
(typeof(tf
.htmlText
), 'string'); // forced cast to string
345 check_equals
(tf
.htmlText
, '');
346 check_equals
(tf
.html
, false);
347 tf
.htmlText
= "Hello <b>html</b> world";
348 check_equals
(tf
.html
, false); // assigning to htmlText doesn't change the 'html' flag
349 check_equals
(tf
.htmlText
, 'Hello <b>html</b> world');
350 // Changing htmlText also changes text
351 check_equals
(tf
.text
, 'Hello <b>html</b> world');
352 tf
.text
= "Hello world";
353 check_equals
(tf
.htmlText
, 'Hello world');
355 //-------------------------------------------------------------------------
356 // Check TextField.length (number of characters in text)
357 //-------------------------------------------------------------------------
359 check_equals
(typeof(tf
.length
), 'number');
360 check
(!tf
.hasOwnProperty
('length'));
362 check_equals
(tf
.length
, 0);
363 tf
.length
= 10; // you don't change lenght like this, you assign to text instead
364 check_equals
(tf
.length
, 0);
365 tf
.text
= "Hello world";
366 check_equals
(tf
.length
, 11);
367 tf
.htmlText
= "Hello <b>world</b>";
368 check_equals
(tf
.length
, 18); // the tags are also counted
370 // Check TextField.maxChars
372 check_equals
(typeof(tf
.maxChars
), 'null');
373 check
(!tf
.hasOwnProperty
('maxChars'));
375 check_equals
(tf
.maxChars
, 5);
376 tf
.text
= "0123456789";
377 // no effect (maybe only limits user input)
378 check_equals
(tf
.text
, "0123456789");
379 tf
.maxChars
= "string";
380 check_equals
(typeof(tf
.maxChars
), "null");
382 check_equals
(typeof(tf
.maxChars
), "number");
383 check_equals
(tf
.maxChars
, -6);
385 check_equals
(typeof(tf
.maxChars
), "null");
389 // Check TextField.maxhscroll
391 check_equals
(typeof(tf
.maxhscroll
), 'number');
392 check
(!tf
.hasOwnProperty
('maxhscroll'));
393 check_equals
(tf
.maxhscroll
, 0);
395 check_equals
(tf
.maxhscroll
, 0); // read-only
397 // Check TextField.maxscroll
399 check_equals
(typeof(tf
.maxscroll
), 'number');
400 check
(!tf
.hasOwnProperty
('maxscroll'));
401 check_equals
(tf
.maxscroll
, 1);
403 check_equals
(tf
.maxscroll
, 1); // read-only
405 // Check TextField.multiline
407 check_equals
(typeof(tf
.multiline
), 'boolean');
408 check_equals
(tf
.multiline
, false);
409 check
(!tf
.hasOwnProperty
('multiline'));
410 check_equals
(tf
.multiline
, false);
412 check_equals
(tf
.multiline
, true);
414 check_equals
(typeof(tf
.multiline
), 'boolean'); // always converted
415 tf
.multiline
= false;
417 //-------------------------------------------------------------------------
418 // Check TextField._name
419 //-------------------------------------------------------------------------
421 check_equals
(typeof(tf
._name
), 'string');
422 check
(!tf
.hasOwnProperty
('_name'));
423 check
(!tf
.__proto__
.hasOwnProperty
('_name'));
424 check_equals
(tf
._name
, 'tf');
426 tf
._name
= 'changed';
427 check_equals
(typeof(tf
), 'undefined');
428 check_equals
(typeof(tfref
), 'object');
429 check_equals
(tfref
._name
, 'changed');
430 check_equals
(tfref
._target
, '/changed');
432 check_equals
(typeof(tf
), 'object');
433 check_equals
(typeof(tfref
), 'object');
434 // TODO: see effects of unloading the textfield ?
436 //-------------------------------------------------------------------------
437 // Check TextField._root and _global
438 //-------------------------------------------------------------------------
441 check_equals
(_root
, _root
.tf
._root
);
444 check_equals
(_global
, _root
.tf
._global
);
448 // They would exist if they had been loaded...
452 #if OUTPUT_VERSION
> 6
453 check
(tf
._root
!= tf
._ROOT
);
454 check
(tf
._root
!= tf
._GLOBAL
);
455 check
(tf
._level0
!= tf
._LEVEL0
);
458 //-------------------------------------------------------------------------
459 // Check TextField._parent
460 //-------------------------------------------------------------------------
462 check_equals
(typeof(tf
._parent
), 'movieclip');
463 check
(!tf
.hasOwnProperty
('_parent'));
464 check
(!tf
.__proto__
.hasOwnProperty
('_parent'));
465 check_equals
(tf
._parent
, _root
);
468 xcheck_equals
(tf
._parent
, 23); // can be overridden !
469 check_equals
(tf
._target
, "/tf"); // but won't change _target
470 r
= delete tf
._parent
;
472 r
= delete tf
._parent
;
474 TextField.prototype
._parent
= "from proto";
475 check_equals
(tf
._parent
, _root
); // still unchanged
476 delete TextField.prototype
._parent
;
479 //-------------------------------------------------------------------------
480 // Check TextField.password
481 //-------------------------------------------------------------------------
483 // This verifies it really uses to_bool.
485 check_equals
(typeof(tf
.password
), 'boolean');
486 check_equals
(tf
.password
, false);
487 check
(!tf
.hasOwnProperty
('password'));
488 check_equals
(tf
.password
, false);
490 check_equals
(tf
.password
, true);
492 check_equals
(tf
.password
, true);
493 tf
.password
= "string";
494 #if OUTPUT_VERSION
> 6
495 check_equals
(tf
.password
, true);
497 check_equals
(tf
.password
, false);
500 check_equals
(tf
.password
, false);
501 tf
.password
= "a string";
502 #if OUTPUT_VERSION
> 6
503 check_equals
(tf
.password
, true);
505 check_equals
(tf
.password
, false);
507 tf
.password
= undefined;
508 check_equals
(tf
.password
, false);
509 // TODO: check effects of setting to 'password' (should hide characters)
512 // Check TextField.quality
514 // TODO: check this, might be a string
515 check_equals
(typeof(tf
._quality
), 'string');
516 check
(!tf
.hasOwnProperty
('_quality'));
517 check
(!tf
.__proto__
.hasOwnProperty
('_quality'));
518 check
(!tf
.__proto__
.__proto__
.hasOwnProperty
('_quality'));
519 check
(!tf
.__proto__
.__proto__
.__proto__
.hasOwnProperty
('_quality'));
520 check_equals
(tf
._quality
, "HIGH");
521 tf
._quality
= "FAKE VALUE";
522 check_equals
(tf
._quality
, "HIGH");
524 check_equals
(tf
._quality
, "LOW");
525 tf
._quality
= "HIGH";
527 // Check TextField.restrict (the set of characters a user can input)
529 check_equals
(typeof(tf
.restrict
), 'null');
530 check
(!tf
.hasOwnProperty
('restrict'));
531 check_equals
(typeof(tf
.restrict
), 'null');
532 tf
.text
= "Hello World";
534 check_equals
(typeof(tf
.restrict
), 'string');
535 check_equals
(tf
.text
, "Hello World");
536 tf
.text
= "Hello World"; // override
537 // doesn't influence explicit setting, only GUI modification
538 // of the textfield (TODO: test with a MovieTester)
539 check_equals
(tf
.text
, "Hello World");
542 check_equals
(tf
.restrict
, "");
543 check_equals
(typeof(tf
.restrict
), 'string');
545 check_equals
(tf
.restrict
, "ä");
546 check_equals
(typeof(tf
.restrict
), 'string');
549 check_equals
(tf
.restrict
, "9");
550 check_equals
(typeof(tf
.restrict
), 'string');
553 o
.toString
= function() { return "üöä"; };
554 o
.valueOf
= function() { return 8; };
557 check_equals
(tf
.restrict
, "üöä");
558 check_equals
(typeof(tf
.restrict
), 'string');
561 xcheck_equals
(tf
.restrict
, null);
562 xcheck_equals
(typeof(tf
.restrict
), "null");
564 // Check TextField._rotation
566 check_equals
(typeof(tf
._rotation
), 'number');
567 check
(!tf
.hasOwnProperty
('_rotation'));
568 check
(!tf
.__proto__
.hasOwnProperty
('_rotation'));
569 check_equals
(tf
._rotation
, 0);
570 check_equals
(tf
._width
, 500);
572 check_equals
(tf
._rotation
, 10);
573 check_equals
(tf
._width
, 579.2);
574 check_equals
(tf
._xscale
, 100.0);
576 check_equals
(tf
._width
, 500.0);
577 check_equals
(tf
._xscale
, 100.0);
579 // Check TextField.scroll
581 // TODO: better test for this, might do nothing if there's no scrollin
582 check_equals
(typeof(tf
.scroll
), 'number');
583 check
( ! tf
.hasOwnProperty
('scroll') );
584 check_equals
(tf
.scroll
, 1);
586 xcheck_equals
(tf
.scroll
, 1); // read-only // is it?
588 // Check TextField.selectable
590 check_equals
(typeof(tf
.selectable
), 'boolean');
591 check
( ! tf
.hasOwnProperty
('selectable') );
592 check_equals
(tf
.selectable
, true);
593 tf
.selectable
= false;
594 check_equals
(tf
.selectable
, false);
595 tf
.selectable
= "Hello";
596 check_equals
(typeof(tf
.selectable
), 'boolean');
597 tf
.selectable
= true;
599 // Check TextField._soundbuftime
601 check_equals
(typeof(tf
._soundbuftime
), 'number');
602 check
( ! tf
.hasOwnProperty
('_soundbuftime') );
603 check
( ! tf
.__proto__
.hasOwnProperty
('_soundbuftime') );
604 xcheck_equals
(tf
._soundbuftime
, 5); // the default is 5, it seems
606 // These seem to be only valid for MovieClips, but they are still read-only
607 check_equals
(typeof(tf
._currentframe
), 'undefined');
608 tf
._currentframe
= "6";
609 check_equals
(tf
._currentframe
, undefined);
611 check_equals
(typeof(tf
._totalframes
), 'undefined');
612 tf
._totalframes
= 67;
613 check_equals
(tf
._totalframes
, undefined);
615 check_equals
(typeof(tf
._framesloaded
), 'undefined');
616 tf
._framesloaded
= "hi";
617 check_equals
(tf
._framesloaded
, undefined);
619 // Check TextField._focusrect
620 check
(tf
._focusrect
!== 'null');
621 check
(tf
._focusRect
!== 'null');
622 xcheck_equals
(typeof(tf
._focusrect
), 'null');
623 xcheck_equals
(typeof(tf
._focusRect
), 'null');
624 check
(! tf
.hasOwnProperty
('_focusrect') );
625 check
(! tf
.__proto__
.hasOwnProperty
('_focusrect') );
628 // Check TextField.tabEnabled
630 check_equals
(typeof(tf
.tabEnabled
), 'undefined');
631 check
( ! tf
.hasOwnProperty
('tabEnabled') );
632 check
( ! tf
.__proto__
.hasOwnProperty
('tabEnabled') );
633 tf
.tabEnabled
= false;
634 check_equals
(tf
.tabEnabled
, false);
635 delete(tf
.tabEnabled
);
637 // Check TextField.tabIndex
639 check_equals
(typeof(tf
.tabIndex
), 'undefined');
640 check
( ! tf
.hasOwnProperty
('tabIndex') );
641 check
( ! tf
.__proto__hasOwnProperty
('tabIndex') );
643 check_equals
(tf
.tabIndex
, 9);
646 //-------------------------------------------------------------------------
647 // Check TextField._target
648 //-------------------------------------------------------------------------
650 check_equals
(typeof(tf
._target
), 'string');
651 check
( ! tf
.hasOwnProperty
('_target') );
652 check
( ! tf
.__proto__
.hasOwnProperty
('_target') );
653 check_equals
(tf
._target
, '/tf');
654 // TODO: check the effect of changing _name on the _target value
655 tf
._target
= "fake_target"; // read-only
656 check_equals
(tf
._target
, '/tf');
658 // Check TextField.text
660 check_equals
(typeof(tf
.text
), 'string');
661 check
( ! tf
.hasOwnProperty
('text') );
662 check_equals
(tf
.text
, 'Hello World');
663 tf
.text
= "hello world";
664 check_equals
(tf
.text
, 'hello world');
665 check_equals
(tf
.length
, 11); // number of characters in "hello world"
668 // Check TextField.textColor
670 check_equals
(typeof(tf
.textColor
), 'number');
671 check
( ! tf
.hasOwnProperty
('textColor') );
672 check_equals
(tf
.textColor
, 0);
673 tf
.textColor
= 0xFF0000;
674 check_equals
(tf
.textColor
, 0xFF0000);
675 // TODO: check color (use misc-ming.all/DefineEditTextTest.swf and a test runner with check_pixel)
677 // Check TextField.textHeight (height of the bounding box)
679 check_equals
(typeof(tf
.textHeight
), 'number');
680 check
( ! tf
.hasOwnProperty
('textHeight') );
681 currentHeight
= tf
.textHeight
; // WARNING: this might depend on the default font height
682 tf
.textHeight
= 1000;
683 check_equals
(tf
.textHeight
, currentHeight
); // was read-only (I think)
685 // Check TextField.textWidth (width of the bounding box)
687 check_equals
(typeof(tf
.textWidth
), 'number');
688 check
( ! tf
.hasOwnProperty
('textWidth') );
689 currentWidth
= tf
.textWidth
; // WARNING: this might depend on the default font height
691 check_equals
(tf
.textWidth
, currentWidth
); // was read-only (I think)
693 // Check TextField.type (input or dynamic)
695 check_equals
(typeof(tf
.type
), 'string');
696 check
( ! tf
.hasOwnProperty
('type') );
697 check_equals
(tf
.type
, 'dynamic');
699 check_equals
(tf
.type
, 'input');
700 tf
.type
= new Array();
701 check_equals
(typeof(tf
.type
), 'string'); // invalid assignment
702 check_equals
(tf
.type
, 'input'); // keeps previous value
704 check_equals
(tf
.type
, 'dynamic');
705 tf
.type
= new Array();
706 check_equals
(tf
.type
, 'dynamic'); // keeps previous value
707 o
= {}; o
.toString
= function() { return 'Input'; };
709 check_equals
(tf
.type
, 'input');
711 // Check TextField._url (url of the SWF that created the textfield)
713 check_equals
(typeof(tf
._url
), 'string');
714 check
( ! tf
.hasOwnProperty
('_url') );
715 check
( ! tf
.__proto__
.hasOwnProperty
('_url') );
716 check_equals
(tf
._url
, _root
._url
);
717 tf
._url
= "fake url";
718 check_equals
(tf
._url
, _root
._url
); // read-only
720 //-------------------------------------------------------------------------
721 // Check TextField.variable (variable name associated with the textfield)
722 //-------------------------------------------------------------------------
724 // SUMMARY: write summary here
726 //-------------------------------------------------------------------------
728 check_equals
(typeof(tf
.variable
), 'null');
729 check
( ! tf
.hasOwnProperty
('variable') );
730 tf
.variable
= _level0
.inputVar
;
731 check_equals
(typeof(tf
.variable
), 'null'); // _level0.inputVar doesn't exist !
733 check_equals
(typeof(tf
.variable
), 'string');
734 check_equals
(tf
.variable
, '2');
735 tf
.variable
= undefined;
736 check_equals
(typeof(tf
.variable
), 'null');
739 check_equals
(typeof(tf
.variable
), 'null');
740 tf
.variable
= "_level0.inputVar";
741 check_equals
(tf
.variable
, '_level0.inputVar');
742 xcheck_equals
(typeof(_level0
.inputVar
), 'undefined');
743 check_equals
(tf
.text
, "hello world"); // as _level0.inputVar is unexistent
744 xcheck
(!_level0
.hasOwnProperty
('inputVar'));
745 _level0
.inputVar
= "dynamic variable";
746 check_equals
(tf
.text
, "dynamic variable");
747 tf
.text
= "back-propagated";
748 check_equals
(_level0
.inputVar
, "back-propagated");
750 tf
.variable
= "_level0.o.t"; // non-existent member (yet)
751 check_equals
(tf
.text
, "back-propagated"); // _level0.o.t doesn't exist yet
752 o
.t
= "from object"; // here we create _level0.o.t
753 check_equals
(tf
.text
, "back-propagated"); // but creating _level0.o.t doesn't trigger textfield text update
754 tf
.text
= "back-to-object"; // instead, assigning to TextField.text updates the object
755 check_equals
(o
.t
, "back-to-object");
756 o
.t
= "from object again"; // but updates to the object still don't update the TextField
757 check_equals
(tf
.text
, "back-to-object"); // assigning to the object doesn't trigger update of text ?
758 tf
.variable
= "_level0.o.t"; // We re-assign TextField.variable, now the variable exists
759 xcheck_equals
(tf
.text
, "from object again"); // this time the TextField.text is updated
760 check_equals
(o
.t
, "from object again");
762 xcheck_equals
(tf
.text
, "from object again"); // but updating o.t still doesn't trigger update of the text ?
763 tf
.text
= "and forever back";
764 check_equals
(o
.t
, "and forever back"); // while updating textfield's text updates o.t
766 // Test value of variable if the property is present but undefined.
768 mc45
= _root
.createEmptyMovieClip
("mc45", getNextHighestDepth
());
769 mc45
.createTextField
("tf45", 0, 0, 100, 100, getNextHighestDepth
());
770 mc45
.tf45
.variable
= "_root.mc45.vari";
771 _root
.mc45
.vari
= undefined;
772 #if OUTPUT_VERSION
< 7
773 check_equals
(mc45
.tf45
.text
, "");
775 check_equals
(mc45
.tf45
.text
, "undefined");
778 //-------------------------------------------------------------------------
779 // TODO: check TextField.getDepth()
780 //-------------------------------------------------------------------------
782 //-------------------------------------------------------------------------
783 // Check TextField.removeTextField and soft references
784 //-------------------------------------------------------------------------
786 // TextField as_value references are soft references like MovieClip ones.
787 // Till the ref is not danglign, typeof(ref) will return 'object', once
788 // the ref is dangling it will return 'movieclip' and will successfully
789 // rebind to a real MovieClip ! When rebound, typeof(ref) will return 'object'
790 // or 'movieclip' depending on the bound thing.
792 //-------------------------------------------------------------------------
794 createTextField
("hardref", 23, 10, 10, 160, 200);
797 check_equals
(typeof(hardref
), 'object');
798 check_equals
(typeof(softref
), 'object');
799 check_equals
(softref
.prop
, 5);
800 check_equals
(softref
.getDepth
(), 23);
801 hardref
.removeTextField
();
802 check_equals
(typeof(hardref
), 'undefined');
803 check_equals
(typeof(softref
), 'movieclip'); // a dangling character ref is always reported to be a 'movieclip' (historical reasons probably)
804 check_equals
(typeof(softref
.prop
), 'undefined');
805 createEmptyMovieClip
("hardref", 24);
806 check_equals
(typeof(hardref
), 'movieclip');
808 check_equals
(typeof(softref
), 'movieclip');
809 check_equals
(softref
.prop
, 7); // and it's actually also rebound to one if available
810 hardref
.removeMovieClip
();
811 createTextField
("hardref", 25, 10, 10, 160, 200);
813 check_equals
(typeof(softref
), 'object'); // changes type on rebind
814 check_equals
(softref
.prop
, 9);
817 //-------------------------------------------------------------------------
818 // Check TextField._visible
819 //-------------------------------------------------------------------------
821 check_equals
(typeof(tf
._visible
), 'boolean');
822 check
( ! tf
.hasOwnProperty
('_visible') );
823 check
( ! tf
.__proto__
.hasOwnProperty
('_visible') );
824 check_equals
(tf
._visible
, true);
826 check_equals
(tf
._visible
, false);
829 //-------------------------------------------------------------------------
830 // Check TextField._width (how is this different from textWidth ?)
831 //-------------------------------------------------------------------------
833 check_equals
(typeof(tf
._width
), 'number');
834 check
( ! tf
.hasOwnProperty
('_width') );
835 check
( ! tf
.__proto__
.hasOwnProperty
('_width') );
836 check_equals
(tf
._width
, 500); // as it was set by createTextField, see above
838 check_equals
(tf
._width
, 99999);
839 b
= tf
.getBounds
(_root
); bs
= printBounds
(b
);
840 check_equals
(bs
, 'xmin:10 ymin:10 xmax:100009 ymax:510');
842 tf
.text
= 'small'; // doesn't reset bounds (being autoSize false);
843 check_equals
(tf
._width
, 99999);
844 b
= tf
.getBounds
(_root
); bs
= printBounds
(b
);
845 check_equals
(bs
, 'xmin:10 ymin:10 xmax:100009 ymax:510');
847 tf
.autoSize
= true; // changes width !!
848 check
(tf
._width
< 99999);
851 tf
.autoSize
= false; // doesn't reset to last manually set one
852 check_equals
(tf
._width
, ow
);
856 //-------------------------------------------------------------------------
857 // Check TextField.wordWrap (should text wrap when bbox limit is hit?)
858 //-------------------------------------------------------------------------
860 check_equals
(typeof(tf
.wordWrap
), 'boolean');
861 check
( ! tf
.hasOwnProperty
('wordWrap') );
862 check_equals
(tf
.wordWrap
, false);
863 // TODO: check what can be assigned to wordWrap and what not...
865 //-------------------------------------------------------------------------
866 // Check TextField._x
867 //-------------------------------------------------------------------------
869 check_equals
(typeof(tf
._x
), 'number');
870 check_equals
(typeof(tf
._X
), 'number');
871 check
( ! tf
.hasOwnProperty
('_x') );
872 check
( ! tf
.__proto__
.hasOwnProperty
('_x') );
873 check_equals
(tf
._x
, 10); // as set by createTextField
875 check_equals
(tf
._x
, 20);
877 //-------------------------------------------------------------------------
878 // Check TextField._xmouse
879 //-------------------------------------------------------------------------
881 check_equals
(typeof(tf
._xmouse
), 'number');
882 check
( ! tf
.hasOwnProperty
('_xmouse') );
883 check
( ! tf
.__proto__
.hasOwnProperty
('_xmouse') );
884 currXmouse
= tf
._xmouse
; // unsafe, if user moves the mouse while running the test
885 tf
._xmouse
= "a string";
886 check_equals
(typeof(tf
._xmouse
), 'number');
887 check_equals
(tf
._xmouse
, currXmouse
); // possibly unsafe, if user moves the mouse while running the test
889 //-------------------------------------------------------------------------
890 // Check TextField._xscale
891 //-------------------------------------------------------------------------
893 check_equals
(typeof(tf
._xscale
), 'number');
894 check
( ! tf
.hasOwnProperty
('_xscale') );
895 check
( ! tf
.__proto__
.hasOwnProperty
('_xscale') );
896 check_equals
(tf
._xscale
, 100);
897 // check how .textWidth and ._width change when changing _xscale
898 currTextWidth
= tf
.textWidth
;
899 currWidth
= tf
._width
;
901 note
("textWidth: _xscale=100: "+currTextWidth
+"; _xscale=200: "+tf
.textWidth
);
902 // check_equals(tf.textWidth, currTextWidth*2); // not clear what does textWidth depend on
903 check_equals
(tf
._width
, currWidth
*2);
906 //-------------------------------------------------------------------------
907 // Check TextField._y
908 //-------------------------------------------------------------------------
910 check_equals
(typeof(tf
._y
), 'number');
911 check
( ! tf
.hasOwnProperty
('_y') );
912 check
( ! tf
.__proto__
.hasOwnProperty
('_y') );
913 check_equals
(tf
._y
, 10); // as set by createTextField
915 check_equals
(tf
._y
, 5);
917 //-------------------------------------------------------------------------
918 // Check TextField._ymouse
919 //-------------------------------------------------------------------------
921 check_equals
(typeof(tf
._ymouse
), 'number');
922 check
( ! tf
.hasOwnProperty
('_ymouse') );
923 check
( ! tf
.__proto__
.hasOwnProperty
('_ymouse') );
924 currYmouse
= tf
._ymouse
;
925 tf
._ymouse
= "a string";
926 check_equals
(typeof(tf
._ymouse
), 'number');
927 check_equals
(tf
._ymouse
, currYmouse
); // possibly unsafe, if user moves the mouse while running the test
929 //-------------------------------------------------------------------------
930 // Check TextField._yscale
931 //-------------------------------------------------------------------------
933 check_equals
(typeof(tf
._yscale
), 'number');
934 check
( ! tf
.hasOwnProperty
('_yscale') );
935 check
( ! tf
.__proto__
.hasOwnProperty
('_yscale') );
936 check_equals
(tf
._yscale
, 100);
937 // check how .textHeight and ._height change based on _yscale
938 currTextHeight
= tf
.textHeight
;
939 currHeight
= tf
._height
;
941 note
("textHeight: _yscale=100: "+currTextHeight
+"; _yscale=200: "+tf
.textHeight
);
942 // check_equals(tf.textHeight, currTextHeight*2); // not clear what does textHeight depend on
943 check_equals
(tf
._height
, currHeight
*2);
946 //-------------------------------------------------------------------------
947 // Check interaction between autoSize and _width and wordWrap
948 //-------------------------------------------------------------------------
950 tf
._width
= 10; // "hello world" text should overflow this
951 tf
.text
= "Hello world";
952 tf
.autoSize
= 'none';
954 check_equals
(tf
._width
, 10);
955 origTextWidth
= tf
.textWidth
;
956 tf
.autoSize
= 'center';
957 check
(tf
._width
> 10);
958 check_equals
(tf
.textWidth
, origTextWidth
); // textWidth isn't influenced by autoSize
959 tf
.autoSize
= 'none';
961 note
("After setting wordWrap flat: textWidth: "+tf
.textWidth
+" origTextWidth:"+origTextWidth
);
962 check_equals
(tf
.textWidth
, origTextWidth
);
964 note
("After reducing _width: textWidth: "+tf
.textWidth
+" origTextWidth:"+origTextWidth
);
965 check_equals
(tf
._width
, 10);
967 #if OUTPUT_VERSION
< 8
968 check_equals
(origTextWidth
, tf
.textWidth
);
970 xcheck
(origTextWidth
> tf
.textWidth
);
973 // test that adding a newline doesn't change the bounds width
975 tf
.autoSize
= 'center';
977 // Word wrap is still true, so nothing should happen!
978 check_equals
(tf
._width
, 10);
979 tf
.text
= "single line";
981 // Changing text should also not change width.
982 check_equals
(tf
._width
, 10);
984 linewidth
= tf
._width
;
985 tf
.text
= "single line\n";
987 check_equals
(tf
._width
, 10);
988 check_equals
(tf
._width
, linewidth
);
990 // Test that setting autoSize = none
991 // doesn't reset the bounding box.
994 oldwidth
= tf
._width
;
995 note
("width: "+oldwidth
);
996 check
(oldwidth
>0); // or the test is invalid
997 tf
.autoSize
= 'none'; // tf was created with bounds 0,0
998 check_equals
(tf
._width
, oldwidth
); // but _width didn't change to that
1000 // Test that when autoSize != none,
1001 // and wordWrap is true, text box isn't
1002 // reset. See #24348
1004 tf
.wordWrap
= false;
1005 check_equals
(tf
._width
, oldwidth
); // text takes more width with wordWrap false
1006 note
("width on wordWrap="+tf
.wordWrap
+" autoSize="+tf
.autoSize
+": "+tf
._width
);
1007 tf
.autoSize
= 'center';
1008 note
("width on wordWrap="+tf
.wordWrap
+" autoSize="+tf
.autoSize
+": "+tf
._width
);
1009 check
(tf
._width
> oldwidth
);
1010 oldwidth
= tf
._width
;
1012 note
("width on wordWrap="+tf
.wordWrap
+" autoSize="+tf
.autoSize
+": "+tf
._width
);
1013 check_equals
(tf
._width
, oldwidth
); // wordWrap change didn't reset the bbox
1016 //------------------------------------------------------------
1017 // Test insane calls
1018 //------------------------------------------------------------
1020 ret
= createTextField
("tf2", 99, 5, 6, -1, -2);
1021 check_equals
(typeof(tf2
), 'object');
1022 check_equals
(tf2
._width
, 1);
1023 check_equals
(tf2
._height
, 2);
1024 check_equals
(tf2
._x
, 5);
1025 check_equals
(tf2
._y
, 6);
1027 createTextField
("tf3", 99, 10.87, 10.12, NAN
, 50.74);
1028 check_equals
(tf3
._x
, 10);
1029 check_equals
(tf3
._y
, 10);
1030 check_equals
(tf3
._width
, 0);
1031 check_equals
(tf3
._height
, 50);
1033 createTextField
("tf4", 99, 10, 50, NAN
, "20");
1034 check_equals
(tf4
._width
, 0);
1035 check_equals
(tf4
._height
, 20);
1037 createTextField
(3, "101", "10", '100', '32', '15');
1038 check_equals
(_root
[3].getDepth
(), 101);
1039 check_equals
(_root
[3]._x
, 10);
1040 check_equals
(_root
[3]._y
, 100);
1041 check_equals
(_root
[3]._width
, 32);
1042 check_equals
(_root
[3]._height
, 15);
1044 // One argument more
1045 createTextField
("tf5", 102, 10, 130, 3, 2, 12);
1046 check_equals
(tf5
._name
, "tf5");
1047 check_equals
(tf5
._target
, "/tf5");
1048 check_equals
(tf5
.getDepth
(), 102);
1049 check_equals
(tf5
._x
, 10);
1050 check_equals
(tf5
._y
, 130);
1051 check_equals
(tf5
._width
, 3);
1052 check_equals
(tf5
._height
, 2);
1054 // One argument missing
1055 createTextField
("tf6", 103, 10, 10, 160);
1056 check_equals
(typeof(tf6
), 'undefined');
1058 /// Test TextField.replaceSel
1060 createTextField
('repl1', 99, 10, 10, 10, 10);
1061 Selection
.setFocus
(repl1
);
1062 check_equals
(Selection
.getFocus
(), '_level0.repl1');
1063 repl1
.text
= "Text in a string";
1065 ret
= repl1
.replaceSel
("More ");
1066 /// Check that the selection start and end indices are adjusted.
1067 check_equals
(Selection
.getBeginIndex
(), 5);
1068 check_equals
(Selection
.getEndIndex
(), 5);
1069 check_equals
(repl1
.text
, "More Text in a string");
1071 ret
= repl1
.replaceSel
("");
1072 check_equals
(Selection
.getEndIndex
(), 5);
1073 check_equals
(repl1
.text
, "More Text in a string");
1076 Selection
.setSelection
(0, 1);
1077 ret
= repl1
.replaceSel
("HU");
1078 check_equals
(ret
, undefined);
1079 check_equals
(repl1
.text
, "HUore Text in a string");
1081 check_equals
(Selection
.getBeginIndex
(), 2);
1082 check_equals
(Selection
.getEndIndex
(), 2);
1084 Selection
.setSelection
(2, 5);
1085 ret
= repl1
.replaceSel
("HUU");
1086 check_equals
(ret
, undefined);
1087 check_equals
(repl1
.text
, "HUHUU Text in a string");
1089 check_equals
(Selection
.getBeginIndex
(), 5);
1090 check_equals
(Selection
.getEndIndex
(), 5);
1092 Selection
.setSelection
(10, 13);
1093 repl1
.replaceSel
(7);
1094 check_equals
(repl1
.text
, "HUHUU Text7 a string");
1095 check_equals
(Selection
.getBeginIndex
(), 11);
1096 check_equals
(Selection
.getEndIndex
(), 11);
1098 Selection
.setSelection
(10, 13);
1099 repl1
.replaceSel
(new Object());
1100 check_equals
(repl1
.text
, "HUHUU Text[object Object] string");
1101 check_equals
(Selection
.getBeginIndex
(), 25);
1102 check_equals
(Selection
.getEndIndex
(), 25);
1104 Selection
.setSelection
(1, 20);
1105 repl1
.replaceSel
("");
1106 #if OUTPUT_VERSION
< 8
1107 check_equals
(repl1
.text
, "HUHUU Text[object Object] string");
1108 check_equals
(Selection
.getBeginIndex
(), 1);
1109 check_equals
(Selection
.getEndIndex
(), 20);
1111 check_equals
(repl1
.text
, "Hject] string");
1112 check_equals
(Selection
.getBeginIndex
(), 1);
1113 check_equals
(Selection
.getEndIndex
(), 1);
1116 repl1
.text
= "New text";
1118 Selection
.setSelection
(2, 5);
1120 check_equals
(repl1
.text
, "New text");
1121 check_equals
(Selection
.getBeginIndex
(), 2);
1122 check_equals
(Selection
.getEndIndex
(), 5);
1124 //------------------------------------------------------------
1125 // Test TextField.replaceText
1126 //------------------------------------------------------------
1128 #if OUTPUT_VERSION
> 6
1129 createTextField
("t", 0, 0, 0, 200, 150);
1130 check_equals
(t
.text
, '');
1131 r
= t
.replaceText
();
1132 check_equals
(typeof(r
), 'undefined');
1133 check_equals
(t
.text
, '');
1134 r
= t
.replaceText
(0, 0);
1135 check_equals
(typeof(r
), 'undefined');
1136 check_equals
(t
.text
, '');
1137 r
= t
.replaceText
(0, 0, 'a');
1138 check_equals
(typeof(r
), 'undefined');
1139 check_equals
(t
.text
, 'a');
1140 r
= t
.replaceText
(0, 0, 'b');
1141 check_equals
(t
.text
, 'ba');
1142 t
.replaceText
(-1, 0, 'c');
1143 check_equals
(t
.text
, 'ba');
1144 t
.replaceText
(0, 5, 'd');
1145 check_equals
(t
.text
, 'd');
1146 t
.replaceText
(-1, 5, 'e');
1147 check_equals
(t
.text
, 'd');
1148 t
.replaceText
(1, 5, 'f');
1149 check_equals
(t
.text
, 'df');
1150 t
.replaceText
(0, 5, 'ϦeϦ');
1151 check_equals
(t
.text
, 'ϦeϦ');
1152 t
.replaceText
(1, 1, 'h');
1153 check_equals
(t
.text
, 'ϦheϦ');
1154 t
.replaceText
(4, 4, 'h');
1155 check_equals
(t
.text
, 'ϦheϦh');
1156 t
.replaceText
(4, 4, undef
);
1157 check_equals
(t
.text
, 'ϦheϦundefinedh');
1158 t
.replaceText
(3, 10, 't');
1159 check_equals
(t
.text
, 'Ϧhetnedh');
1160 t
.replaceText
(3, -1, 'y');
1161 check_equals
(t
.text
, 'Ϧhetnedh');
1162 // TODO: check registered variables
1165 //------------------------------------------------------------
1167 //------------------------------------------------------------
1169 _root
._visible
= true; // just to be sure
1170 _root
._xscale
= _root
._yscale
= 100;
1171 _root
.createTextField
('htf',0,0,0,0,0);
1172 check_equals
(typeof(htf
), 'object');
1180 _parent
='fake_parent';
1185 check_equals
(_root
._x
, 0);
1186 check_equals
(_root
._y
, 0);
1187 check_equals
(_root
._visible
, true);
1188 check_equals
(_root
._xscale
, 100);
1189 check_equals
(_root
._yscale
, 100);
1190 check_equals
(_root
._target
, '/');
1191 xcheck_equals
(_root
._parent
, 'fake_parent');
1192 check_equals
(_root
._name
, '');
1194 check_equals
(tf
._x
, 10);
1195 check_equals
(tf
._y
, 11);
1196 check_equals
(tf
._visible
, false);
1197 check_equals
(tf
._xscale
, 200);
1198 check_equals
(tf
._yscale
, 201);
1199 check_equals
(tf
._target
, '/fake_name');
1200 check_equals
(tf
._parent
, _level0
);
1201 check_equals
(tf
._name
, 'fake_name');
1203 _root
._visible
= true;
1204 _root
._x
= _root
._y
= 0;
1205 _root
._xscale
= _root
._yscale
= 100;
1208 // Check that "new _global.TextField()" is called in createTextField
1210 backup
= _global
.TextField;
1214 storedthis
= undefined;
1216 _global
.TextField = function() {
1218 this.bo
= "stringo";
1219 args
= arguments.length
;
1223 TextField.prototype
= {};
1224 TextField.prototype
.toString
= function() { return "Hoppla!"; };
1226 // The fact that createTextField works even when _global.TextField is
1227 // replaced shows that the native functions (making into a real TextField)
1228 // is done in createTextField.
1229 r
= _root
.createTextField
("tfmo", 2, 2, 10, 10, 6);
1230 check_equals
(count
, 1);
1231 check_equals
(args
, 0);
1232 check_equals
(_root
.tfmo
._x
, 2);
1234 /// The returned object is still the this pointer that our fake constructor
1236 check_equals
(_root
.tfmo
, storedthis
);
1237 xcheck
(_root
.tfmo
=== storedthis
);
1239 check_equals
(_root
.tfmo
.bo
, "stringo");
1240 check
(_root
.tfmo
.hasOwnProperty
("bo"));
1242 // Not sure why this isn't the case for version 6 or 7.
1243 #if OUTPUT_VERSION
>= 8
1244 check_equals
(r
.toString
(), "Hoppla!");
1246 check_equals
(r
.toString
(), undefined);
1249 _global
.TextField = backup
;
1251 // So if createTextField calls the TextField ctor, what does that constructor
1254 // This only confirms that the TextField constructor a) removes the
1255 // array typing, b) removes the relay, and c) doesn't produce a
1256 // DisplayObject. We still don't have a way to check what happens
1257 // inside createTextField.
1261 // We are called with 'new'.
1262 fun
= ASnative
(2, 0);
1263 xcheck_equals
(fun
(), true);
1266 this.__proto__
.__constructor__
= Array;
1268 check_equals
(this.length
, 0);
1270 // It's not a proper TextField.
1271 this.__proto__
.__constructor__
= TextField;
1273 check_equals
(backup
, this);
1274 check_equals
(this.length
, 0);
1275 check_equals
(this._x
, undefined);
1276 check_equals
(this._visible
, undefined);
1277 check_equals
(this._width
, undefined);
1279 // It is no longer an array.
1281 check_equals
(this.length
, 0);
1282 check_equals
(this[2], 3);
1284 this.__proto__
.__constructor__
= Date;
1285 this.getTime
= Date.prototype
.getTime
;
1287 check_equals
(typeof(this.getTime
()), "number");
1289 this.__proto__
.__constructor__
= TextField;
1291 check_equals
(typeof(this.getTime
()), "undefined");
1297 //------------------------------------------------------------
1299 //------------------------------------------------------------
1301 #if OUTPUT_VERSION
== 6
1303 #elif OUTPUT_VERSION
== 7
1305 #elif OUTPUT_VERSION
== 8