mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
71 lines
2.1 KiB
XML
71 lines
2.1 KiB
XML
<?xml version="1.0"?>
|
|
<window id="PROT_unittest"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
onload="onProtUnittestLoad();"
|
|
title="prot unittests">
|
|
|
|
<script><![CDATA[
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
|
|
function G_Debug(zone, s) {
|
|
var label = document.createElement('label');
|
|
var txt = "[" + zone + "] " + s;
|
|
label.appendChild(document.createTextNode(txt));
|
|
|
|
document.documentElement.appendChild(label);
|
|
}
|
|
|
|
function G_Assert(zone, cond, msg) {
|
|
if (!cond) {
|
|
G_Debug(zone, msg);
|
|
throw msg;
|
|
}
|
|
}
|
|
|
|
function ProtectionPhishWardenTests() {
|
|
var z = "phishwarden UNITTEST";
|
|
G_Debug(z, "Starting");
|
|
|
|
var listManager = Cc["@mozilla.org/protection/protectionlistmanager;1"]
|
|
.getService(Ci.nsIProtectionListManager);
|
|
var warden = Cc['@mozilla.org/protection/phishwarden;1']
|
|
.createInstance(Ci.nsIProtectionListWarden);
|
|
// Register tables that we are interested in.
|
|
warden.registerBlackTable("test-black-url");
|
|
|
|
var blacklistedCount = 0;
|
|
|
|
var blackURLs = [
|
|
"http://foo.com/1",
|
|
"http://foo.com/2",
|
|
"http://foo.com/3",
|
|
"http://foo.com/4",
|
|
"http://www.goodsite.com/test",
|
|
];
|
|
|
|
for (var i = 0; i < blackURLs.length; i++)
|
|
listManager.safeInsert("test-black-url", blackURLs[i], "1");
|
|
|
|
G_Assert(z, !warden.checkUrl("http://bar.com/"), 'should not have found');
|
|
G_Assert(z, warden.checkUrl("http://foo.com/1"), 'should have found (1)');
|
|
G_Assert(z, warden.checkUrl("http://foo.com/2"), 'should have found (2)');
|
|
G_Assert(z, warden.checkUrl("http://foo.com/3"), 'should have found (3)');
|
|
G_Assert(z, warden.checkUrl("http://foo.com/4"), 'should have found (4)');
|
|
|
|
warden.registerWhiteTable('test-white-domain');
|
|
listManager.safeInsert("test-white-domain", "http://www.goodsite.com/", "1");
|
|
|
|
G_Assert(z, !warden.checkUrl("http://www.goodsite.com/"),
|
|
'whitelist failed?')
|
|
|
|
|
|
G_Debug(z, "PASSED");
|
|
}
|
|
|
|
function onProtUnittestLoad() {
|
|
ProtectionPhishWardenTests();
|
|
}
|
|
]]></script>
|
|
</window>
|