b=450088 backing out (new reftest failed)
[wine-gecko.git] / testing / mochitest / tests / test_bug366645.xhtml
blobc035a3dc0cfd30a67957a9ad11d9aa1c90d18d6a
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=366645
4 -->
5 <head>
6 <title>Test for Bug 366645</title>
7 <script type="text/javascript" src="/MochiKit/packed.js"></script>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366645">Mozilla Bug 366645</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script class="testbody" type="text/javascript">
19 <![CDATA[
21 /** Test for Bug 366645 **/
23 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
24 var Cc = Components.classes;
25 var Ci = Components.interfaces;
26 var table = Cc["@mozilla.org/url-classifier/table;1?type=url"].createInstance();
27 var componentScope = table.wrappedJSObject.__parent__;
28 ok(!!componentScope, "unable to get wrapped js object");
30 var PROT_EnchashDecrypter = componentScope.PROT_EnchashDecrypter;
31 var l = new PROT_EnchashDecrypter();
33 // Test getCanonicalUrl
34 var testing = {
35 "http://030.0254.0x89d5./": "http://24.172.137.213/",
36 "http://030.0254.0x89d5.../": "http://24.172.137.213/",
37 "http://...030.0254.0x89d5.../": "http://24.172.137.213/",
38 "http://127.0.0.1./": "http://127.0.0.1/",
39 "http://127.0.0.1/": "http://127.0.0.1/",
40 "http://a.b.c.d.e.f.g/path": "http://a.b.c.d.e.f.g/path",
41 "http://a.b.c.d.e.f.g...../path": "http://a.b.c.d.e.f.g/path",
42 "http://a.b.c.d.e.f.g./path": "http://a.b.c.d.e.f.g/path"
44 for (var key in testing) {
45 ok(l.getCanonicalUrl(key) === testing[key],
46 "getCanonicalUrl broken on " + key + "(got: " + l.getCanonicalUrl(key));
49 // Test individual regular expressions
50 function testRE(re, replaceStr, inputValPairs) {
51 for (var i = 0; i < inputValPairs.length; i += 2) {
52 var inStr = inputValPairs[i];
53 var outStr = inputValPairs[i + 1];
54 ok(inStr.replace(re, replaceStr) == outStr,
55 uneval(inStr) + ".replace(" + uneval(re) + "," + uneval(replaceStr) + ") == " + uneval(outStr) + ")");
60 - [no_dots, false,
61 - one_dot, false,
62 - trailing_dot, true,
63 - trailing_dots, true];
64 -testRE(r.FIND_TRAILING_DOTS, tests);
66 testing = [
67 "", "",
68 "normal chars;!@#$%^&*&(", "normal chars;!@#$%^&*&(",
69 "MORE NORMAL ,./<>?;':{}", "MORE NORMAL ,./<>?;':{}",
70 "Slightly less\2 normal", "Slightly less normal",
71 "\245 stuff \4\5foo", " stuff foo",
73 testRE(PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS_GLOBAL, "", testing);
75 testing = [
76 "", "",
77 "abcd123;[]", "abcd123;[]",
78 "abc.123", "abc.123",
79 "two..dots", "two..dots",
80 "trailing.", "trailing",
81 "trailing..", "trailing",
82 ".leading", "leading",
83 "..leading", "leading",
84 ".both.", "both",
85 ".both..", "both",
86 "..both.", "both",
87 "..both..", "both",
88 "..a.b.c.d..", "a.b.c.d",
89 "..127.0.0.1..", "127.0.0.1",
91 testRE(PROT_EnchashDecrypter.REs.FIND_END_DOTS_GLOBAL, "", testing);
93 testing = [
94 "", "",
95 "nodots", "nodots",
96 "127.0.0.1", "127.0.0.1",
97 ".127.0.0.1.", ".127.0.0.1.",
98 "127..0.0.1", "127.0.0.1",
99 "127.0..0.1", "127.0.0.1",
100 "127..0..0..1", "127.0.0.1",
102 testRE(PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL, ".", testing);
105 </script>
106 </pre>
107 </body>
108 </html>