4
/* ***** BEGIN LICENSE BLOCK *****
5
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
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/
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
17
* The Original Code is mozilla.org code.
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.
25
* Ashish Bhatt <ashishbhatt@netscape.com>
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.
40
* ***** END LICENSE BLOCK ***** */
43
<title>nsIIOService Tets case</title>
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">
52
var scheme = new Array("http","https", "ftp","file","javascript","data","about","gopher","chrome", "jar");
54
var ioservice = new IOService();
57
function WritePassFail()
60
if (ioservice.success)
62
buffer += "<td>"+ ioservice.returnvalue +"</td>" ;
63
buffer += "<td>Pass</td>"
67
buffer += "<td>" +"Exception: " + ioservice.exception + "</td>" ;
68
buffer += "<td bgcolor='#FF0000'>Fail</td>"
72
ioservice.exception= null;
77
function WriteTableHeader(name,params)
80
buffer += "<td>" + name + "</td>" ;
81
buffer += "<td>" + params + "</td>" ;
85
function WriteHeader()
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%'>"
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>"
99
function WriteFooter()
104
function RunAllTests()
108
getProtocolHandler();
125
if (isRunningStandalone())
128
document.write(buffer);
131
WriteResults(buffer);
136
function getProtocolHandler()
138
for (i=0;i<scheme.length;i++)
140
ioservice.getProtocolHandler(scheme[i]);
142
WriteTableHeader("getProtocolHandler",scheme[i]);
144
WriteTableHeader("",scheme[i]);
149
function getProtocolFlags()
152
for (i=0;i<scheme.length;i++)
154
ioservice.getProtocolFlags(scheme[i]);
156
WriteTableHeader("getProtocolFlags",scheme[i]);
158
WriteTableHeader("",scheme[i]);
167
var url = "http://slip.mcom.com" ;
168
ioservice.newURI(url,null,null);
169
WriteTableHeader("newURI","Spec,OriginCharset,BaseURI");
173
function newFileURI()
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:/");
180
ioservice.newFileURI(file);
182
WriteTableHeader("newFileURI","nsIFile");
187
function newChannelFromURI()
190
var url = "http://slip.mcom.com" ;
191
ioservice.newURI(url,null,null);
193
ioservice.newChannelFromURI(ioservice.returnvalue);
195
WriteTableHeader("newChannelFromURI","URI");
200
function newChannel()
203
var url = "http://slip.mcom.com" ;
204
ioservice.newChannel(url,null,null);
206
WriteTableHeader("newChannel","Spec,OriginCharset,BaseURI");
211
function Getoffline()
213
ioservice.Getoffline();
215
WriteTableHeader("offline(get)","");
220
function Setoffline()
222
ioservice.Setoffline(true);
224
WriteTableHeader("offline(set)","true");
234
ioservice.allowPort(90, "http");
236
WriteTableHeader("allowPort","Port, Scheme");
240
function extractScheme()
242
var url = new Array("http://mozilla.org",
243
"https://ec.aoltw.net",
244
"ftp://ftp.mozilla.org",
246
"javascript:alert('e');",
250
"chrome://communicator/skin/communicator.css",
253
for (i=0;i<url.length;i++)
256
ioservice.extractScheme(url[i]);
259
WriteTableHeader("extractScheme",url[i]);
261
WriteTableHeader("",url[i]);
273
<script type="text/javascript">