1 <!-- ***** BEGIN LICENSE BLOCK *****
2 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 - The contents of this file are subject to the Mozilla Public License Version
5 - 1.1 (the "License"); you may not use this file except in compliance with
6 - the License. You may obtain a copy of the License at
7 - http://www.mozilla.org/MPL/
9 - Software distributed under the License is distributed on an "AS IS" basis,
10 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 - for the specific language governing rights and limitations under the
14 - The Original Code is Mozilla Communicator Test Cases.
16 - The Initial Developer of the Original Code is Netscape Communications
17 - Corp. Portions created by Netscape Communications Corp. are
18 - Copyright (C) 1999 Netscape Communications Corp. All
22 - dsirnapalli@netscape.com.
24 - Alternatively, the contents of this file may be used under the terms of
25 - either the GNU General Public License Version 2 or later (the "GPL"), or
26 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 - in which case the provisions of the GPL or the LGPL are applicable instead
28 - of those above. If you wish to allow use of your version of this file only
29 - under the terms of either the GPL or the LGPL, and not to allow others to
30 - use your version of this file under the terms of the MPL, indicate your
31 - decision by deleting the provisions above and replace them with the notice
32 - and other provisions required by the LGPL or the GPL. If you do not delete
33 - the provisions above, a recipient may use your version of this file under
34 - the terms of any one of the MPL, the GPL or the LGPL.
36 - ***** END LICENSE BLOCK ***** -->
38 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
40 <title> nsIDocCharset Interface Test </title>
41 <!-- Descrpt: nsIDocCharset Interface Test Case
43 Revs: 09.10.01 - Created
48 <!-- script below is ngdriverspecific -->
49 <script type="text/javascript" src="http://bubblegum/ngdriver/suites/testlib.js">
52 <script type="text/javascript">
54 function getnsIDOMWindow()
58 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
59 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
60 var domobject = window.QueryInterface(Components.interfaces.nsIDOMWindow);
63 dump ("\nError getting nsIDOMWindow\n");
68 function getdocCharset()
72 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
73 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
74 // You get nsIDocCharset by GI' ing off nsIDOMWindow.
75 // nsIDOMWindow doesnot implement getInterface directly. So you need to QI first.
76 var charsetObj = domWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
77 .getInterface(Components.interfaces.nsIDocCharset);
81 dump ("\nError getting nsIDocCharset\n");
85 function constructResult(initialcharset, charset)
89 initialcharsetvalue = "Fail";
90 charsetvalue = "Fail";
92 initialcharsetcolor = "white";
93 charsetcolor = "white";
95 if(initialcharset != null) initialcharsetvalue = "Pass" ;
96 if(charset == setCharsetValueTo) charsetvalue = "Pass" ;
98 if(initialcharset == null) initailcharsetcolor = "red" ;
99 if(charset != setCharsetValueTo) charsetcolor = "red" ;
101 results = results + "<html>";
103 results = results + "<font color='#CC6600'> NOTE: </font>" + "<br>";
104 results = results + "For the Test Case to run correctly include the following line into your prefs.js file." + "<br>";
105 results = results + 'user_pref("signed.applets.codebase_principal_support", true);' + "<br>";
106 results = results + 'prefs.js can be found at' + '<br>';
107 results = results + 'WINNT:C:\\WINNT\\Profiles\\profileyouareusing\\Application Data\\MfcEmbed\\Profiles\\default\\somefolder.slt\\prefs.js' + '<br>';
108 results = results + 'WIN98:C:\\WINDOWS\\Application Data\\MfcEmbed\\Profiles\\default\\somefolder.slt\\prefs.js' + '<br>';
109 results = results + '<br><hr ALIGN=LEFT SIZE=5 NOSHADE WIDTH="80%">' + '\n';
111 results = results + " <table bgcolor='white' border='4'>";
112 results = results + " <tbody>";
113 results = results + " <caption> <center> <b> nsIDocCharset Results </b> </center> </caption><br>";
114 results = results + " <tr>";
115 results = results + " <td> <b> Case# </b> </td>";
116 results = results + " <td> <b> Description </b> </td>";
117 results = results + " <td> <b> Value </b> </td>";
118 results = results + " <td> <b> Result </b> </td>";
119 results = results + " </tr>";
120 results = results + " <tr bgcolor = '" + initialcharsetcolor + "'>";
121 results = results + " <td> 1 </td>";
122 results = results + " <td> Initial charset value </td>";
123 results = results + " <td>" + initialcharset + "</td>";
124 results = results + " <td>" + initialcharsetvalue + "</td>";
125 results = results + " </tr>";
126 results = results + " <tr bgcolor = '" + charsetcolor + "'>";
127 results = results + " <td> 2 </td>";
128 results = results + " <td> charset value after setting </td>";
129 results = results + " <td>" + charset + "</td>";
130 results = results + " <td>" + charsetvalue + "</td>";
131 results = results + " </tr>";
132 results = results + " </tbody>";
133 results = results + " </table>";
135 results = results + '<br><hr ALIGN=LEFT SIZE=5 NOSHADE WIDTH="80%">' + '\n';
136 results = results + "</html>";
138 document.results.textarea.value = results;
139 if (top.name == "testWindow")
145 document.write(document.results.textarea.value);
151 <script language="JavaScript">
153 function createCookie(name,value,days)
157 var date = new Date();
158 date.setTime(date.getTime()+(days*24*60*60*1000));
159 var expires = "; expires="+date.toGMTString();
162 document.cookie = name+"="+value+expires+"; path=/";
165 function readCookie(name)
167 var nameEQ = name + "=";
168 var ca = document.cookie.split(';');
169 for(var i=0;i < ca.length;i++)
172 while (c.charAt(0)==' ')
173 c = c.substring(1,c.length);
174 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
179 function eraseCookie(name)
181 createCookie(name,"",-1);
189 <!-- form below is ngdriverspecific -->
190 <form name="results" action="/ngdriver/cgi-bin/writeresults.cgi" method="post">
191 <script type="text/javascript">
192 document.write('<input name="resultsfile" type="hidden" value="' + window.opener.document.resultsform.resultsfile.value + '">');
194 <input type="hidden" name="textarea">
197 <script type="text/javascript">
199 var domWindow = getnsIDOMWindow();
200 var docCharset = getdocCharset();
201 var setCharsetValueTo = "ISO-8859-1";
203 if(readCookie("docCharset") == null)
207 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
208 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
209 var charsetValue = docCharset.charset;
210 docCharset.charset = setCharsetValueTo;
213 dump ("\nError getting nsIDocCharset\n");
216 createCookie("docCharset", charsetValue, 14);
217 window.location.reload();
221 var cookieValue = readCookie("docCharset");
224 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
225 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
226 constructResult(cookieValue, docCharset.charset);
229 dump ("\nError getting nsIDocCharset\n");
231 eraseCookie("docCharset");