pjs/testing/mochitest/tests/test_bug366645.xhtml

109 строки
3.2 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=366645
-->
<head>
<title>Test for Bug 366645</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366645">Mozilla Bug 366645</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for Bug 366645 **/
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var Cc = Components.classes;
var Ci = Components.interfaces;
var table = Cc["@mozilla.org/url-classifier/table;1?type=url"].createInstance();
var componentScope = table.wrappedJSObject.__parent__;
ok(!!componentScope, "unable to get wrapped js object");
var PROT_EnchashDecrypter = componentScope.PROT_EnchashDecrypter;
var l = new PROT_EnchashDecrypter();
// Test getCanonicalUrl
var testing = {
"http://030.0254.0x89d5./": "http://24.172.137.213/",
"http://030.0254.0x89d5.../": "http://24.172.137.213/",
"http://...030.0254.0x89d5.../": "http://24.172.137.213/",
"http://127.0.0.1./": "http://127.0.0.1/",
"http://127.0.0.1/": "http://127.0.0.1/",
"http://a.b.c.d.e.f.g/path": "http://a.b.c.d.e.f.g/path",
"http://a.b.c.d.e.f.g...../path": "http://a.b.c.d.e.f.g/path",
"http://a.b.c.d.e.f.g./path": "http://a.b.c.d.e.f.g/path"
}
for (var key in testing) {
ok(l.getCanonicalUrl(key) === testing[key],
"getCanonicalUrl broken on " + key + "(got: " + l.getCanonicalUrl(key));
}
// Test individual regular expressions
function testRE(re, replaceStr, inputValPairs) {
for (var i = 0; i < inputValPairs.length; i += 2) {
var inStr = inputValPairs[i];
var outStr = inputValPairs[i + 1];
ok(inStr.replace(re, replaceStr) == outStr,
uneval(inStr) + ".replace(" + uneval(re) + "," + uneval(replaceStr) + ") == " + uneval(outStr) + ")");
}
};
/*
- [no_dots, false,
- one_dot, false,
- trailing_dot, true,
- trailing_dots, true];
-testRE(r.FIND_TRAILING_DOTS, tests);
*/
testing = [
"", "",
"normal chars;!@#$%^&*&(", "normal chars;!@#$%^&*&(",
"MORE NORMAL ,./<>?;':{}", "MORE NORMAL ,./<>?;':{}",
"Slightly less\2 normal", "Slightly less normal",
"\245 stuff \4\5foo", " stuff foo",
];
testRE(PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS_GLOBAL, "", testing);
testing = [
"", "",
"abcd123;[]", "abcd123;[]",
"abc.123", "abc.123",
"two..dots", "two..dots",
"trailing.", "trailing",
"trailing..", "trailing",
".leading", "leading",
"..leading", "leading",
".both.", "both",
".both..", "both",
"..both.", "both",
"..both..", "both",
"..a.b.c.d..", "a.b.c.d",
"..127.0.0.1..", "127.0.0.1",
];
testRE(PROT_EnchashDecrypter.REs.FIND_END_DOTS_GLOBAL, "", testing);
testing = [
"", "",
"nodots", "nodots",
"127.0.0.1", "127.0.0.1",
".127.0.0.1.", ".127.0.0.1.",
"127..0.0.1", "127.0.0.1",
"127.0..0.1", "127.0.0.1",
"127..0..0..1", "127.0.0.1",
];
testRE(PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL, ".", testing);
]]>
</script>
</pre>
</body>
</html>