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

« back to all changes in this revision

Viewing changes to mozilla/embedding/qa/jstests/networking/nsIIOService.html

  • 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
<html>
 
2
 
 
3
<!--
 
4
/* ***** BEGIN LICENSE BLOCK *****
 
5
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
6
 *
 
7
 * The contents of this file are subject to the Netscape Public License
 
8
 * Version 1.1 (the "License"); you may not use this file except in
 
9
 * compliance with the License. You may obtain a copy of the License at
 
10
 * http://www.mozilla.org/NPL/
 
11
 *
 
12
 * Software distributed under the License is distributed on an "AS IS" basis,
 
13
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
14
 * for the specific language governing rights and limitations under the
 
15
 * License.
 
16
 *
 
17
 * The Original Code is mozilla.org code.
 
18
 *
 
19
 * The Initial Developer of the Original Code is
 
20
 * Netscape Communications Corporation.
 
21
 * Portions created by the Initial Developer are Copyright (C) 1998
 
22
 * the Initial Developer. All Rights Reserved.
 
23
 *
 
24
 * Contributor(s):
 
25
 *   Ashish Bhatt <ashishbhatt@netscape.com>
 
26
 *
 
27
 *
 
28
 * Alternatively, the contents of this file may be used under the terms of
 
29
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
30
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
31
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
32
 * of those above. If you wish to allow use of your version of this file only
 
33
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
34
 * use your version of this file under the terms of the NPL, indicate your
 
35
 * decision by deleting the provisions above and replace them with the notice
 
36
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
37
 * the provisions above, a recipient may use your version of this file under
 
38
 * the terms of any one of the NPL, the GPL or the LGPL.
 
39
 *
 
40
 * ***** END LICENSE BLOCK ***** */
 
41
  -->
 
42
 
 
43
<title>nsIIOService Tets case</title>
 
44
 
 
45
<head>
 
46
 
 
47
<script type="text/javascript" src="http://www.mozilla.org/quality/embed/jstests/bridge.js"></script>
 
48
<script type="text/javascript" src="nsIIOService.js"></script>
 
49
<script type="text/javascript">
 
50
 
 
51
var buffer ;
 
52
var scheme = new Array("http","https", "ftp","file","javascript","data","about","gopher","chrome", "jar");
 
53
 
 
54
var ioservice = new IOService();
 
55
 
 
56
 
 
57
function WritePassFail()
 
58
{
 
59
 
 
60
  if (ioservice.success)
 
61
  {
 
62
          buffer += "<td>"+ ioservice.returnvalue +"</td>" ;
 
63
          buffer += "<td>Pass</td>"
 
64
  }
 
65
  else
 
66
  {
 
67
          buffer += "<td>" +"Exception: " + ioservice.exception + "</td>" ;
 
68
          buffer += "<td bgcolor='#FF0000'>Fail</td>"
 
69
  }
 
70
 
 
71
  buffer += "</tr>"
 
72
  ioservice.exception= null;
 
73
 
 
74
}
 
75
 
 
76
 
 
77
function WriteTableHeader(name,params)
 
78
{
 
79
        buffer += "<tr>" ;
 
80
        buffer += "<td>" + name + "</td>" ;
 
81
        buffer += "<td>" + params + "</td>" ;
 
82
}
 
83
 
 
84
 
 
85
function WriteHeader()
 
86
{
 
87
 
 
88
        buffer = "<b>Results for <a href='http://lxr.mozilla.org/seamonkey/source/netwerk/base/public/nsIIOService.idl'>nsIIOService :</a></b><br><br>"
 
89
        buffer += "<table border cols=4 width='70%'>"
 
90
        buffer += "<tr>"
 
91
        buffer += "<td><b>Property/Method</b></td>"
 
92
        buffer += "<td><b>Params</b></td>"
 
93
        buffer += "<td><b>Output/Bug/Error</b></td>"
 
94
        buffer += "<td><b>Result</b></td>"
 
95
        buffer += "</tr>"
 
96
 
 
97
}
 
98
 
 
99
function WriteFooter()
 
100
{
 
101
        buffer += "</table>"
 
102
}
 
103
 
 
104
function RunAllTests()
 
105
{
 
106
        WriteHeader();
 
107
 
 
108
        getProtocolHandler();
 
109
 
 
110
        getProtocolFlags();
 
111
        newURI();
 
112
        newFileURI();
 
113
        newChannelFromURI();
 
114
        newChannel();
 
115
        Getoffline();
 
116
        Setoffline();
 
117
        allowPort();
 
118
        extractScheme();
 
119
 
 
120
 
 
121
 
 
122
        WriteFooter();
 
123
 
 
124
 
 
125
        if (isRunningStandalone())
 
126
        {
 
127
           document.clear();
 
128
           document.write(buffer);
 
129
        }
 
130
        else
 
131
                WriteResults(buffer);
 
132
 
 
133
 
 
134
}
 
135
 
 
136
function getProtocolHandler()
 
137
{
 
138
        for (i=0;i<scheme.length;i++)
 
139
        {
 
140
                ioservice.getProtocolHandler(scheme[i]);
 
141
                if (i==0)
 
142
                        WriteTableHeader("getProtocolHandler",scheme[i]);
 
143
                else
 
144
                        WriteTableHeader("",scheme[i]);
 
145
                WritePassFail();
 
146
        }
 
147
}
 
148
 
 
149
function getProtocolFlags()
 
150
{
 
151
 
 
152
        for (i=0;i<scheme.length;i++)
 
153
        {
 
154
                ioservice.getProtocolFlags(scheme[i]);
 
155
                if (i==0)
 
156
                        WriteTableHeader("getProtocolFlags",scheme[i]);
 
157
                else
 
158
                        WriteTableHeader("",scheme[i]);
 
159
 
 
160
                WritePassFail();
 
161
        }
 
162
}
 
163
 
 
164
function newURI()
 
165
{
 
166
 
 
167
        var url = "http://slip.mcom.com" ;
 
168
        ioservice.newURI(url,null,null);
 
169
        WriteTableHeader("newURI","Spec,OriginCharset,BaseURI");
 
170
        WritePassFail();
 
171
}
 
172
 
 
173
function newFileURI()
 
174
{
 
175
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
 
176
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
177
    var phandler = ioservice.service.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
 
178
    var file =  phandler.getFileFromURLSpec("file:///c:/");
 
179
 
 
180
    ioservice.newFileURI(file);
 
181
 
 
182
        WriteTableHeader("newFileURI","nsIFile");
 
183
        WritePassFail();
 
184
}
 
185
 
 
186
 
 
187
function newChannelFromURI()
 
188
{
 
189
 
 
190
        var url = "http://slip.mcom.com" ;
 
191
        ioservice.newURI(url,null,null);
 
192
 
 
193
    ioservice.newChannelFromURI(ioservice.returnvalue);
 
194
 
 
195
        WriteTableHeader("newChannelFromURI","URI");
 
196
        WritePassFail();
 
197
}
 
198
 
 
199
 
 
200
function newChannel()
 
201
{
 
202
 
 
203
        var url = "http://slip.mcom.com" ;
 
204
        ioservice.newChannel(url,null,null);
 
205
 
 
206
        WriteTableHeader("newChannel","Spec,OriginCharset,BaseURI");
 
207
        WritePassFail();
 
208
 
 
209
}
 
210
 
 
211
function Getoffline()
 
212
{
 
213
        ioservice.Getoffline();
 
214
 
 
215
        WriteTableHeader("offline(get)","");
 
216
        WritePassFail();
 
217
}
 
218
 
 
219
 
 
220
function Setoffline()
 
221
{
 
222
        ioservice.Setoffline(true);
 
223
 
 
224
        WriteTableHeader("offline(set)","true");
 
225
        WritePassFail();
 
226
}
 
227
 
 
228
function allowPort()
 
229
{
 
230
 
 
231
        var port ;
 
232
        var scheme ;
 
233
 
 
234
        ioservice.allowPort(90, "http");
 
235
 
 
236
        WriteTableHeader("allowPort","Port, Scheme");
 
237
        WritePassFail();
 
238
}
 
239
 
 
240
function extractScheme()
 
241
{
 
242
    var url = new Array("http://mozilla.org",
 
243
                                                "https://ec.aoltw.net",
 
244
                                                "ftp://ftp.mozilla.org",
 
245
                                                "file://c:/",
 
246
                                                "javascript:alert('e');",
 
247
                                                "data:",
 
248
                                                "about:",
 
249
                                                "ghoper://",
 
250
                                                "chrome://communicator/skin/communicator.css",
 
251
                                                "jar://resource");
 
252
 
 
253
        for (i=0;i<url.length;i++)
 
254
        {
 
255
 
 
256
           ioservice.extractScheme(url[i]);
 
257
 
 
258
                if (i==0)
 
259
                        WriteTableHeader("extractScheme",url[i]);
 
260
                else
 
261
                        WriteTableHeader("",url[i]);
 
262
 
 
263
           WritePassFail();
 
264
        }
 
265
}
 
266
 
 
267
 
 
268
</script>
 
269
 
 
270
</head>
 
271
 
 
272
<body>
 
273
<script type="text/javascript">
 
274
   RunAllTests();
 
275
</script>
 
276
</body>
 
277
 
 
278
</html>
 
279
 
 
280
 
 
281
 
 
282
 
 
283