Bug 1584479 - Part 2: Update socialtracking test. r=Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D51444

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nihanth Subramanya 2019-11-02 09:53:51 +00:00
parent 2164478f1e
commit 7f0b6eecd8
8 changed files with 73 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -175,6 +175,7 @@ http://fingerprinting.example.com:80
http://not-tracking.example.com:80
http://tracking.example.org:80
http://another-tracking.example.net:80
http://social-tracking.example.org:80
http://itisatracker.org:80
https://itisatracker.org:443
http://trackertest.org:80
@ -192,6 +193,7 @@ https://fingerprinting.example.com:443
https://not-tracking.example.com:443
https://tracking.example.org:443
https://another-tracking.example.net:443
https://social-tracking.example.org:443
#
# Used while testing flash blocking (Bug 1307604)

View File

@ -140,4 +140,5 @@ support-files = matchAll.js
skip-if = fission
support-files = sharedWorker.js partitionedSharedWorker.js
[browser_socialtracking.js]
skip-if = fission
[browser_urlDecorationStripping.js]

View File

@ -11,8 +11,6 @@ function runTest(obj) {
["privacy.trackingprotection.pbmode.enabled", false],
["privacy.trackingprotection.annotate_channels", true],
["privacy.storagePrincipal.enabledForTrackers", false],
["urlclassifier.features.socialtracking.annotate.blacklistHosts", "not-tracking.example.com"],
["urlclassifier.features.socialtracking.blacklistHosts", "not-tracking.example.com"],
["privacy.trackingprotection.socialtracking.enabled", obj.protectionEnabled],
["privacy.socialtracking.block_cookies.enabled", obj.cookieBlocking],
],
@ -29,8 +27,8 @@ function runTest(obj) {
await ContentTask.spawn(
browser,
{
page: TEST_4TH_PARTY_DOMAIN + TEST_PATH + "localStorage.html",
image: TEST_4TH_PARTY_DOMAIN + TEST_PATH + "raptor.jpg",
page: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "localStorage.html",
image: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "raptor.jpg",
loading: obj.loading,
result: obj.result,
},
@ -70,6 +68,21 @@ function runTest(obj) {
}
);
info("Checking content blocking log.");
let contentBlockingLog = JSON.parse(await browser.getContentBlockingLog());
for (let origin of Object.keys(contentBlockingLog)) {
is(
origin + "/",
TEST_3RD_PARTY_DOMAIN_STP,
"Correct tracker origin must be reported"
);
Assert.deepEqual(
contentBlockingLog[origin],
obj.expectedLogItems,
"Content blocking log should be as expected"
);
}
BrowserTestUtils.removeTab(tab);
UrlClassifierTestUtils.cleanupTestTrackers();
@ -82,6 +95,10 @@ runTest({
loading: true,
cookieBlocking: false,
result: true,
expectedLogItems: [
[Ci.nsIWebProgressListener.STATE_COOKIES_LOADED, true, 1],
[Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_SOCIALTRACKER, true, 1]
],
});
runTest({
@ -90,6 +107,12 @@ runTest({
loading: true,
cookieBlocking: true,
result: false,
expectedLogItems: [
[Ci.nsIWebProgressListener.STATE_COOKIES_LOADED, true, 1],
[Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_SOCIALTRACKER, true, 1],
[Ci.nsIWebProgressListener.STATE_LOADED_SOCIALTRACKING_CONTENT, true, 2],
[Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_SOCIALTRACKER, true, 2]
],
});
runTest({
@ -98,4 +121,7 @@ runTest({
loading: false,
cookieBlocking: true,
result: false,
expectedLogItems: [
[Ci.nsIWebProgressListener.STATE_BLOCKED_SOCIALTRACKING_CONTENT, true, 1]
],
});

View File

@ -14,6 +14,7 @@ const TEST_DOMAIN_6 = "http://mochi.test:8888/";
const TEST_3RD_PARTY_DOMAIN = "https://tracking.example.org/";
const TEST_3RD_PARTY_DOMAIN_HTTP = "http://tracking.example.org/";
const TEST_3RD_PARTY_DOMAIN_TP = "https://tracking.example.com/";
const TEST_3RD_PARTY_DOMAIN_STP = "https://social-tracking.example.org/";
const TEST_4TH_PARTY_DOMAIN = "http://not-tracking.example.com/";
const TEST_ANOTHER_3RD_PARTY_DOMAIN = "https://another-tracking.example.net/";

View File

@ -13,6 +13,13 @@ const TRACKING_TABLE_PREF = "urlclassifier.trackingTable";
const WHITELIST_TABLE_NAME = "mochitest2-trackwhite-simple";
const WHITELIST_TABLE_PREF = "urlclassifier.trackingWhitelistTable";
const SOCIAL_ANNOTATION_TABLE_NAME = "mochitest3-track-simple";
const SOCIAL_ANNOTATION_TABLE_PREF =
"urlclassifier.features.socialtracking.annotate.blacklistTables";
const SOCIAL_TRACKING_TABLE_NAME = "mochitest4-track-simple";
const SOCIAL_TRACKING_TABLE_PREF =
"urlclassifier.features.socialtracking.blacklistTables";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
@ -30,11 +37,12 @@ var UrlClassifierTestUtils = {
let trackingURL2 = "itisatracker.org/";
let trackingURL3 = "trackertest.org/";
let whitelistedURL = "itisatrap.org/?resource=itisatracker.org";
let socialTrackingURL = "social-tracking.example.org/";
let annotationUpdate =
"n:1000\ni:" +
ANNOTATION_TABLE_NAME +
"\nad:4\n" +
"\nad:5\n" +
"a:1:32:" +
annotationURL1.length +
"\n" +
@ -60,6 +68,15 @@ var UrlClassifierTestUtils = {
"\n" +
annotationURL5 +
"\n";
let socialAnnotationUpdate =
"n:1000\ni:" +
SOCIAL_ANNOTATION_TABLE_NAME +
"\nad:1\n" +
"a:1:32:" +
socialTrackingURL.length +
"\n" +
socialTrackingURL +
"\n";
let annotationWhitelistUpdate =
"n:1000\ni:" +
ANNOTATION_WHITELIST_TABLE_NAME +
@ -88,6 +105,15 @@ var UrlClassifierTestUtils = {
"\n" +
trackingURL3 +
"\n";
let socialTrackingUpdate =
"n:1000\ni:" +
SOCIAL_TRACKING_TABLE_NAME +
"\nad:1\n" +
"a:1:32:" +
socialTrackingURL.length +
"\n" +
socialTrackingURL +
"\n";
let whitelistUpdate =
"n:1000\ni:" +
WHITELIST_TABLE_NAME +
@ -104,6 +130,11 @@ var UrlClassifierTestUtils = {
name: ANNOTATION_TABLE_NAME,
update: annotationUpdate,
},
{
pref: SOCIAL_ANNOTATION_TABLE_PREF,
name: SOCIAL_ANNOTATION_TABLE_NAME,
update: socialAnnotationUpdate,
},
{
pref: ANNOTATION_WHITELIST_TABLE_PREF,
name: ANNOTATION_WHITELIST_TABLE_NAME,
@ -114,6 +145,11 @@ var UrlClassifierTestUtils = {
name: TRACKING_TABLE_NAME,
update: trackingUpdate,
},
{
pref: SOCIAL_TRACKING_TABLE_PREF,
name: SOCIAL_TRACKING_TABLE_NAME,
update: socialTrackingUpdate,
},
{
pref: WHITELIST_TABLE_PREF,
name: WHITELIST_TABLE_NAME,
@ -145,8 +181,10 @@ var UrlClassifierTestUtils = {
cleanupTestTrackers() {
Services.prefs.clearUserPref(ANNOTATION_TABLE_PREF);
Services.prefs.clearUserPref(SOCIAL_ANNOTATION_TABLE_PREF);
Services.prefs.clearUserPref(ANNOTATION_WHITELIST_TABLE_PREF);
Services.prefs.clearUserPref(TRACKING_TABLE_PREF);
Services.prefs.clearUserPref(SOCIAL_TRACKING_TABLE_PREF);
Services.prefs.clearUserPref(WHITELIST_TABLE_PREF);
},