Bug 601299: Find RegExpStatics in cx->globalObject if necessary. (r=mrbkap)
[mozilla-central.git] / netwerk / test / TestURLManipulation.html
blobfd58652b7be8b9cae6e45db3eca52a66a73d164a
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>URL manipulation</title>
5 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
7 <script type="text/javascript">
8 var gIOService = null;
9 function getIOService()
11 if (gIOService)
12 return gIOService;
14 try {
15 gIOService = Components.classes["@mozilla.org/network/io-service;1"]
16 .getService(Components.interfaces.nsIIOService);
17 } catch(e) { dump("problem creating nsIURL for: "+inURLString+"\n"); }
19 return gIOService;
22 function getnsIURL(inURLString)
24 var URL = null;
25 var ioserv = getIOService();
26 try {
27 var URI = ioserv.newURI(inURLString, "", null);
28 URL = URI.QueryInterface(Components.interfaces.nsIURL);
29 } catch(e) { dump("problem creating nsIURL for: "+inURLString+"\n"); }
30 return URL;
33 function getCommonSpec()
35 var URL1 = getnsIURL(document.foo.baseEdit.value);
36 var URL2 = getnsIURL(document.foo.compareEdit.value);
37 var result = "";
38 try {
39 result = URL1.getCommonBaseSpec(URL2);
40 } catch(e) { dump("problem with getCommonSpec ("+e+")\n"); }
41 document.foo.resultEdit.value = result;
44 function getRelativeSpec()
46 var URL1 = getnsIURL(document.foo.baseEdit.value);
47 var URL2 = getnsIURL(document.foo.compareEdit.value);
48 var result = "";
49 try {
50 result = URL1.getRelativeSpec(URL2);
51 } catch(e) { dump("problem with getRelativeSpec ("+e+")\n"); }
52 document.foo.resultEdit.value = result;
55 function doResolve()
57 var URL = getnsIURL(document.foo.baseEdit.value);
58 var result = "";
59 try {
60 result = URL.resolve(document.foo.resultEdit.value);
61 } catch(e) { dump("problem with getRelativeSpec ("+e+")\n"); }
62 document.foo.compareEdit.value = result;
64 </script>
65 </head>
66 <body>
67 <h1>testing of URL manipulation:</h1>
68 <p>
69 <form name="foo">
70 <p>
71 <label for="baseEdit">base url (absolute)</label><br>
72 <input type="input" name="baseEdit" size="80" value="http://www.mozilla.org/">
74 <p>
75 <label for="compareEdit">comparison uri (absolute)</label><br>
76 <input type="input" name="compareEdit" size="80">
78 <p>
79 <label for="resultEdit">resolved url</label><br>
80 <input type="input" name="resultEdit" size="80">
82 <p>
83 <input type="button" onclick="getCommonSpec();" value="Get Common Spec">
84 <input type="button" onclick="getRelativeSpec();" value="Get Relative Spec">
85 <input type="button" onclick="doResolve();" value="Resolve">
86 <h5> note: results from "resolve" are placed in "comparison uri" edit field</h5>
87 </form>
88 <p>
89 <br>
91 <h3>notes for testing</h3>
92 different types of uris:<br>
93 <ul>
94 <li>about:</li>
95 <li>about:blank</li>
96 <li>mailbox://nsmail-2.mcom.com/xxx</li>
97 <li>mailto:brade@netscape.com)</li>
98 <li>junk</li>
99 <li>http://foo/</li>
100 <li>http://foo.com/</li>
101 <li>https://foo.com/</li>
102 <li>ftp://ftp.mozilla.org/</li>
103 <li>http://foo.com:8080/</li>
104 <li>http://brade@foo.com/</li>
105 <li>http://brade:password@foo.com/</li>
106 <li>http://brade:@foo.com:8080/</li>
107 <li>file:///</li>
108 <li>file:///Quest/Desktop%20Folder/test.html</li>
109 </ul>
110 other variations:<br>
111 <ul>
112 <li>sub-directories on above list</li>
113 <li>files on above list</li>
114 <li>sub-directories and files on above list<br>
115 </li>
116 <li>directories which don't end in a '/'</li>
117 <li>files with queries</li>
118 <li>files with no extension</li>
119 <li>files with references</li>
120 <li>files with params</li>
121 <li>other schemes (chrome, ldap, news, finger, etc.)<br>
122 </li>
123 </ul>
124 <br>
125 This should be true:<br>
126 &nbsp; resultString = baseURL.getRelativeSpec(URL);<br>
127 &lt;==&gt;<br>
128 &nbsp; baseURL.resolve(resultString) == URL.spec;<br>
129 </body>
130 </html>