1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=366645
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" />
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=366645">Mozilla Bug
366645</a>
14 <div id=
"content" style=
"display: none">
18 <script class=
"testbody" type=
"text/javascript">
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
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) +
")");
63 - trailing_dots, true];
64 -testRE(r.FIND_TRAILING_DOTS, tests);
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);
77 "abcd123;[]",
"abcd123;[]",
79 "two..dots",
"two..dots",
80 "trailing.",
"trailing",
81 "trailing..",
"trailing",
82 ".leading",
"leading",
83 "..leading",
"leading",
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);
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);