2 // Copyright (C) 2008, 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 2 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
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if OUTPUT_VERSION
< 6
28 _root
.createTextField
("textfield1", 1, 10, 10, 100, 100);
29 tf
= _root
.textfield1
;
31 // Text is not parsed as HTML unless the html property is true, regardless
32 // of whether you set htmlText or Text.
33 tf
.htmlText
= "<b>bold</b>";
34 check_equals
(tf
.text
, "<b>bold</b>");
35 tf
.text
= "<i>italic</i>";
36 check_equals
(tf
.text
, "<i>italic</i>");
38 // Changing the property afterwards makes no difference.
40 check_equals
(tf
.text
, "<i>italic</i>");
41 tf
.text
= "<b>bold</b>";
43 // Only setting the htmlText property causes tag parsing.
44 check_equals
(tf
.text
, "<b>bold</b>");
45 tf
.htmlText
= "<i>italic</i>";
46 xcheck_equals
(tf
.text
, "italic");
50 // The htmlText value is generated on-the-fly from the text's properties,
51 // but only when the html property is true.
52 tf
.htmlText
= "<font>font</font>";
53 check_equals
(tf
.text
, "<font>font</font>");
55 // Here there is no html output.
56 check_equals
(tf
.htmlText
, "<font>font</font>");
60 // Here there is html output, even though the text has not changed.
61 xcheck_equals
(tf
.htmlText
, '<P ALIGN="LEFT"><FONT FACE="Times" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"><font>font</font></FONT></P>');
63 // Check font color attribute.
64 // The html property is still true now.
66 tf
.htmlText
= '<font color="#00FF00">green</font>';
67 xcheck_equals
(tf
.text
, "green");
68 // The TextField textColor remains black.
69 check_equals
(tf
.textColor
, 0);
70 // The characters are green.
71 format
= tf
.getTextFormat
(1, 4);
72 xcheck_equals
(format
.color
, 0x00ff00);
74 // This fails (no quotes)
75 tf
.htmlText
= '<font color=#00FF00>green2</font>';
76 xcheck_equals
(tf
.text
, "");
77 // The TextField textColor remains black.
78 check_equals
(tf
.textColor
, 0);
80 // Lower case is fine.
81 tf
.htmlText
= '<font color="#0000ff">blue</font>';
82 xcheck_equals
(tf
.text
, "blue");
83 // The TextField textColor remains black.
84 check_equals
(tf
.textColor
, 0);
85 format
= tf
.getTextFormat
(1, 4);
86 xcheck_equals
(format
.color
, 0x0000ff);
88 // WARNING!! The disabled code crashes Gnash at the moment.
89 // When that's fixed, this code can be reenabled to get the totals() pass,
90 // and the failures in this section (only!) can be expected.
92 // A color string that is this short doesn't change the color.
93 tf
.htmlText
= '<font color="#ff">too short</font>';
94 xcheck_equals
(tf
.text
, "too short");
95 format
= tf
.getTextFormat
(1, 4);
96 xcheck_equals
(format
.color
, 0x0000ff);
98 // When it's three characters it does change the color.
99 tf
.htmlText
= '<font color="#ff0">a bit short</font>';
100 xcheck_equals
(tf
.text
, "a bit short");
101 format
= tf
.getTextFormat
(1, 4);
102 xcheck_equals
(format
.color
, 0x000ff0);
104 // Without a hash it sets the color to black.
105 tf
.htmlText
= '<font color="ff00ff">no hash</font>';
106 xcheck_equals
(tf
.text
, "no hash");
107 format
= tf
.getTextFormat
(1, 4);
108 check_equals
(format
.color
, 0);
110 tf
.htmlText
= '<font color="hi">no hash 2</font>';
111 xcheck_equals
(tf
.text
, "no hash 2");
112 format
= tf
.getTextFormat
(1, 4);
113 check_equals
(format
.color
, 0);
115 tf
.htmlText
= '<font color="">empty</font>';
116 xcheck_equals
(tf
.text
, "empty");
117 format
= tf
.getTextFormat
(1, 4);
118 check_equals
(format
.color
, 0);
120 // Extra long strings are truncated, but the end counts, not the beginning.
121 tf
.htmlText
= '<font color="#ff00ffffee">long</font>';
122 xcheck_equals
(tf
.text
, "long");
123 format
= tf
.getTextFormat
(1, 4);
124 xcheck_equals
(format
.color
, 0xffffee);
126 // Strings containing non-hex characters ignore those characters.
127 tf
.htmlText
= '<font color="#ff00gp">corrupt</font>';
128 xcheck_equals
(tf
.text
, "corrupt");
129 format
= tf
.getTextFormat
(1, 4);
130 xcheck_equals
(format
.color
, 0x00ff00);
132 // Check empty face value (bug #32508)
133 tf
.htmlText
= '<font face="">#32508</font>';
134 xcheck_equals
(tf
.text
, "#32508");