~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/qa/jstests/nsIDocCharsetTest.txt

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 
2
<html>
 
3
<title> nsIDocCharset Interface Test </title>
 
4
<!-- Descrpt: nsIDocCharset Interface Test Case
 
5
     Author: dsirnapalli@netscape.com
 
6
     Revs: 09.10.01 - Created
 
7
     Last Run On:10.23.01.
 
8
   - The contents of this file are subject to the Mozilla Public
 
9
   - License Version 1.1 (the "License"); you may not use this file
 
10
   - except in compliance with the License. You may obtain a copy of
 
11
   - the License at http://www.mozilla.org/MPL/
 
12
   -
 
13
   - Software distributed under the License is distributed on an "AS
 
14
   - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
15
   - implied. See the License for the specific language governing
 
16
   - rights and limitations under the License.
 
17
   -
 
18
   - The Original Code is Mozilla Communicator Test Cases.
 
19
   -
 
20
   - The Initial Developer of the Original Code is Netscape Communications
 
21
   - Corp.  Portions created by Netscape Communications Corp. are
 
22
   - Copyright (C) 1999 Netscape Communications Corp.  All
 
23
   - Rights Reserved.
 
24
   -
 
25
   - Contributor(s):
 
26
  -->
 
27
<head>
 
28
 
 
29
<!-- script below is ngdriverspecific  -->
 
30
<script type="text/javascript" src="http://bubblegum/ngdriver/suites/testlib.js">
 
31
</script>
 
32
 
 
33
<script type="text/javascript">
 
34
 
 
35
function getnsIDOMWindow()
 
36
{
 
37
  try
 
38
  {
 
39
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
 
40
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
41
    var domobject = window.QueryInterface(Components.interfaces.nsIDOMWindow);
 
42
  }
 
43
  catch(e) {
 
44
    dump ("\nError getting nsIDOMWindow\n");
 
45
  }
 
46
  return domobject;
 
47
}
 
48
 
 
49
function getdocCharset()
 
50
{
 
51
  try
 
52
  {
 
53
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
 
54
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
55
    // You get nsIDocCharset by GI' ing off nsIDOMWindow.
 
56
    // nsIDOMWindow doesnot implement getInterface directly. So you need to QI first.
 
57
    var charsetObj = domWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
 
58
                              .getInterface(Components.interfaces.nsIDocCharset);
 
59
    return(charsetObj);
 
60
  }
 
61
  catch(e) {
 
62
    dump ("\nError getting nsIDocCharset\n");
 
63
  }
 
64
}
 
65
 
 
66
function constructResult(initialcharset, charset)
 
67
{
 
68
  var results = "";
 
69
 
 
70
  initialcharsetvalue = "Fail";
 
71
  charsetvalue = "Fail";
 
72
 
 
73
  initialcharsetcolor = "white";
 
74
  charsetcolor = "white";
 
75
 
 
76
  if(initialcharset != null) initialcharsetvalue = "Pass" ;
 
77
  if(charset == setCharsetValueTo) charsetvalue = "Pass" ;
 
78
 
 
79
  if(initialcharset == null) initailcharsetcolor = "red" ;
 
80
  if(charset != setCharsetValueTo) charsetcolor = "red" ;
 
81
 
 
82
  results = results + "<html>";
 
83
 
 
84
  results = results + "<font color='#CC6600'> NOTE: </font>" + "<br>";
 
85
  results = results + "For the Test Case to run correctly include the following line into your prefs.js file." + "<br>";
 
86
  results = results + 'user_pref("signed.applets.codebase_principal_support", true);' + "<br>";
 
87
  results = results + 'prefs.js can be found at' + '<br>';
 
88
  results = results + 'WINNT:C:\\WINNT\\Profiles\\profileyouareusing\\Application Data\\MfcEmbed\\Profiles\\default\\somefolder.slt\\prefs.js' + '<br>';
 
89
  results = results + 'WIN98:C:\\WINDOWS\\Application Data\\MfcEmbed\\Profiles\\default\\somefolder.slt\\prefs.js' + '<br>';
 
90
  results = results + '<br><hr ALIGN=LEFT SIZE=5 NOSHADE WIDTH="80%">' + '\n';
 
91
 
 
92
  results = results + "  <table bgcolor='white' border='4'>";
 
93
  results = results + "  <tbody>";
 
94
  results = results + "  <caption> <center> <b> nsIDocCharset Results </b> </center> </caption><br>";
 
95
  results = results + "    <tr>";
 
96
  results = results + "      <td> <b> Case# </b> </td>";
 
97
  results = results + "      <td> <b> Description </b> </td>";
 
98
  results = results + "      <td> <b> Value </b> </td>";
 
99
  results = results + "      <td> <b> Result </b> </td>";
 
100
  results = results + "    </tr>";
 
101
  results = results + "    <tr bgcolor = '" + initialcharsetcolor + "'>";
 
102
  results = results + "      <td> 1 </td>";
 
103
  results = results + "      <td> Initial charset value </td>";
 
104
  results = results + "      <td>" + initialcharset + "</td>";
 
105
  results = results + "      <td>" + initialcharsetvalue + "</td>";
 
106
  results = results + "    </tr>";
 
107
  results = results + "    <tr bgcolor = '" + charsetcolor + "'>";
 
108
  results = results + "      <td> 2 </td>";
 
109
  results = results + "      <td> charset value after setting </td>";
 
110
  results = results + "      <td>" + charset + "</td>";
 
111
  results = results + "      <td>" + charsetvalue + "</td>";
 
112
  results = results + "    </tr>";
 
113
  results = results + "  </tbody>";
 
114
  results = results + "  </table>";
 
115
 
 
116
  results = results + '<br><hr ALIGN=LEFT SIZE=5 NOSHADE WIDTH="80%">' + '\n';
 
117
  results = results + "</html>";
 
118
 
 
119
  document.results.textarea.value = results;
 
120
  if (top.name == "testWindow")
 
121
  {
 
122
        fixSubmit();
 
123
  }
 
124
  else
 
125
  {
 
126
        document.write(document.results.textarea.value);
 
127
  }
 
128
}
 
129
 
 
130
</script>
 
131
 
 
132
<script language="JavaScript">
 
133
 
 
134
function createCookie(name,value,days)
 
135
{
 
136
  if (days)
 
137
  {
 
138
    var date = new Date();
 
139
    date.setTime(date.getTime()+(days*24*60*60*1000));
 
140
    var expires = "; expires="+date.toGMTString();
 
141
  }
 
142
  else expires = "";
 
143
  document.cookie = name+"="+value+expires+"; path=/";
 
144
}
 
145
 
 
146
function readCookie(name)
 
147
{
 
148
  var nameEQ = name + "=";
 
149
  var ca = document.cookie.split(';');
 
150
  for(var i=0;i < ca.length;i++)
 
151
  {
 
152
    var c = ca[i];
 
153
    while (c.charAt(0)==' ')
 
154
      c = c.substring(1,c.length);
 
155
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 
156
  }
 
157
  return null;
 
158
}
 
159
 
 
160
function eraseCookie(name)
 
161
{
 
162
  createCookie(name,"",-1);
 
163
}
 
164
 
 
165
</script>
 
166
 
 
167
</head>
 
168
<body>
 
169
 
 
170
<!-- form below is ngdriverspecific  -->
 
171
<form name="results" action="/ngdriver/cgi-bin/writeresults.cgi" method="post">
 
172
<script type="text/javascript">
 
173
document.write('<input name="resultsfile" type="hidden" value="' + window.opener.document.resultsform.resultsfile.value + '">');
 
174
</script>
 
175
<input type="hidden" name="textarea">
 
176
</form>
 
177
 
 
178
<script type="text/javascript">
 
179
 
 
180
var domWindow = getnsIDOMWindow();
 
181
var docCharset = getdocCharset();
 
182
var setCharsetValueTo = "ISO-8859-1";
 
183
 
 
184
if(readCookie("docCharset") == null)
 
185
{
 
186
  try
 
187
  {
 
188
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
 
189
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
190
    var charsetValue = docCharset.charset;
 
191
    docCharset.charset = setCharsetValueTo;
 
192
  }
 
193
  catch(e) {
 
194
    dump ("\nError getting nsIDocCharset\n");
 
195
  }
 
196
 
 
197
  createCookie("docCharset", charsetValue, 14);
 
198
  window.location.reload();
 
199
}
 
200
else
 
201
{
 
202
  var cookieValue = readCookie("docCharset");
 
203
  try
 
204
  {
 
205
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
 
206
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
207
    constructResult(cookieValue, docCharset.charset);
 
208
  }
 
209
  catch(e) {
 
210
    dump ("\nError getting nsIDocCharset\n");
 
211
  }
 
212
  eraseCookie("docCharset");
 
213
}
 
214
</script>
 
215
 
 
216
</body>
 
217
</html>
 
 
b'\\ No newline at end of file'