Bug 1375277 - Test case for new error code NS_ERROR_HARMFUL_URI. r=francois
The test is based on "test-harmful-simple" so we can add testing entries in a human-readable way. MozReview-Commit-ID: IJcYrp04uFs
This commit is contained in:
@@ -86,7 +86,7 @@ function waitForDBInit(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Services.prefs.setCharPref("urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple");
|
Services.prefs.setCharPref("urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple,test-harmful.simple");
|
||||||
Services.prefs.setCharPref("urlclassifier.phishTable", "test-phish-simple");
|
Services.prefs.setCharPref("urlclassifier.phishTable", "test-phish-simple");
|
||||||
Services.prefs.setCharPref("urlclassifier.blockedTable", "test-block-simple");
|
Services.prefs.setCharPref("urlclassifier.blockedTable", "test-block-simple");
|
||||||
SafeBrowsing.init();
|
SafeBrowsing.init();
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ var testData = [
|
|||||||
},
|
},
|
||||||
{ url: "blocked.example.com/",
|
{ url: "blocked.example.com/",
|
||||||
db: "test-block-simple"
|
db: "test-block-simple"
|
||||||
}
|
},
|
||||||
|
{ url: "harmful.example.com/",
|
||||||
|
db: "test-harmful-simple"
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const Cc = SpecialPowers.Cc;
|
const Cc = SpecialPowers.Cc;
|
||||||
@@ -81,6 +84,16 @@ var testURLs = [
|
|||||||
table: "test-phish-simple",
|
table: "test-phish-simple",
|
||||||
result: Cr.NS_ERROR_PHISHING_URI
|
result: Cr.NS_ERROR_PHISHING_URI
|
||||||
},
|
},
|
||||||
|
{ url: "http://harmful.example.com",
|
||||||
|
trackingProtection: false,
|
||||||
|
table: "test-harmful-simple",
|
||||||
|
result: Cr.NS_ERROR_HARMFUL_URI
|
||||||
|
},
|
||||||
|
{ url: "http://harmful.example.com",
|
||||||
|
trackingProtection: true,
|
||||||
|
table: "test-harmful-simple",
|
||||||
|
result: Cr.NS_ERROR_HARMFUL_URI
|
||||||
|
},
|
||||||
{ url: "http://tracking.example.com",
|
{ url: "http://tracking.example.com",
|
||||||
trackingProtection: false,
|
trackingProtection: false,
|
||||||
table: "test-track-simple",
|
table: "test-track-simple",
|
||||||
@@ -135,7 +148,7 @@ function testService() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let test = testURLs.shift();
|
let test = testURLs.shift();
|
||||||
let tables = "test-malware-simple,test-unwanted-simple,test-phish-simple,test-track-simple,test-block-simple";
|
let tables = "test-malware-simple,test-unwanted-simple,test-phish-simple,test-track-simple,test-block-simple,test-harmful-simple";
|
||||||
let uri = ios.newURI(test.url);
|
let uri = ios.newURI(test.url);
|
||||||
let prin = ssm.createCodebasePrincipal(uri, {});
|
let prin = ssm.createCodebasePrincipal(uri, {});
|
||||||
is(service.classifyLocal(uri, tables), test.table,
|
is(service.classifyLocal(uri, tables), test.table,
|
||||||
@@ -158,10 +171,11 @@ function testService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv(
|
SpecialPowers.pushPrefEnv(
|
||||||
{"set" : [["urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple"],
|
{"set" : [["urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple,test-harmful-simple"],
|
||||||
["urlclassifier.phishTable", "test-phish-simple"],
|
["urlclassifier.phishTable", "test-phish-simple"],
|
||||||
["urlclassifier.downloadBlockTable", "test-block-simple"],
|
["urlclassifier.downloadBlockTable", "test-block-simple"],
|
||||||
["urlclassifier.trackingTable", "test-track-simple"],
|
["urlclassifier.trackingTable", "test-track-simple"],
|
||||||
|
["browser.safebrowsing.debug", true],
|
||||||
["privacy.trackingprotection.annotate_channels", true]]},
|
["privacy.trackingprotection.annotate_channels", true]]},
|
||||||
function() {
|
function() {
|
||||||
classifierHelper.waitForInit()
|
classifierHelper.waitForInit()
|
||||||
|
|||||||
@@ -56,12 +56,14 @@ function cleanUp() {
|
|||||||
delFile("safebrowsing/test-malware-simple.sbstore");
|
delFile("safebrowsing/test-malware-simple.sbstore");
|
||||||
delFile("safebrowsing/test-unwanted-simple.sbstore");
|
delFile("safebrowsing/test-unwanted-simple.sbstore");
|
||||||
delFile("safebrowsing/test-block-simple.sbstore");
|
delFile("safebrowsing/test-block-simple.sbstore");
|
||||||
|
delFile("safebrowsing/test-harmful-simple.sbstore");
|
||||||
delFile("safebrowsing/test-track-simple.sbstore");
|
delFile("safebrowsing/test-track-simple.sbstore");
|
||||||
delFile("safebrowsing/test-trackwhite-simple.sbstore");
|
delFile("safebrowsing/test-trackwhite-simple.sbstore");
|
||||||
delFile("safebrowsing/test-phish-simple.pset");
|
delFile("safebrowsing/test-phish-simple.pset");
|
||||||
delFile("safebrowsing/test-malware-simple.pset");
|
delFile("safebrowsing/test-malware-simple.pset");
|
||||||
delFile("safebrowsing/test-unwanted-simple.pset");
|
delFile("safebrowsing/test-unwanted-simple.pset");
|
||||||
delFile("safebrowsing/test-block-simple.pset");
|
delFile("safebrowsing/test-block-simple.pset");
|
||||||
|
delFile("safebrowsing/test-harmful-simple.pset");
|
||||||
delFile("safebrowsing/test-track-simple.pset");
|
delFile("safebrowsing/test-track-simple.pset");
|
||||||
delFile("safebrowsing/test-trackwhite-simple.pset");
|
delFile("safebrowsing/test-trackwhite-simple.pset");
|
||||||
delFile("safebrowsing/moz-phish-simple.sbstore");
|
delFile("safebrowsing/moz-phish-simple.sbstore");
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ function run_test() {
|
|||||||
equal(urlUtils.convertListNameToThreatType("goog-malware-proto"), 1);
|
equal(urlUtils.convertListNameToThreatType("goog-malware-proto"), 1);
|
||||||
equal(urlUtils.convertListNameToThreatType("googpub-phish-proto"), 2);
|
equal(urlUtils.convertListNameToThreatType("googpub-phish-proto"), 2);
|
||||||
equal(urlUtils.convertListNameToThreatType("goog-unwanted-proto"), 3);
|
equal(urlUtils.convertListNameToThreatType("goog-unwanted-proto"), 3);
|
||||||
|
equal(urlUtils.convertListNameToThreatType("goog-harmful-proto"), 4);
|
||||||
equal(urlUtils.convertListNameToThreatType("goog-phish-proto"), 5);
|
equal(urlUtils.convertListNameToThreatType("goog-phish-proto"), 5);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -23,6 +24,7 @@ function run_test() {
|
|||||||
equal(urlUtils.convertThreatTypeToListNames(1), "goog-malware-proto");
|
equal(urlUtils.convertThreatTypeToListNames(1), "goog-malware-proto");
|
||||||
equal(urlUtils.convertThreatTypeToListNames(2), "googpub-phish-proto,test-phish-proto");
|
equal(urlUtils.convertThreatTypeToListNames(2), "googpub-phish-proto,test-phish-proto");
|
||||||
equal(urlUtils.convertThreatTypeToListNames(3), "goog-unwanted-proto,test-unwanted-proto");
|
equal(urlUtils.convertThreatTypeToListNames(3), "goog-unwanted-proto,test-unwanted-proto");
|
||||||
|
equal(urlUtils.convertThreatTypeToListNames(4), "goog-harmful-proto");
|
||||||
equal(urlUtils.convertThreatTypeToListNames(5), "goog-phish-proto");
|
equal(urlUtils.convertThreatTypeToListNames(5), "goog-phish-proto");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user