fune/browser/base/content/test/trackingUI/browser_trackingUI_3.js
Johann Hofmann 5584301845 Bug 1476218 - Part 3 - Update Tracking Protection tests to reflect Content Blocking changes. r=nhnt11
This commit also moves the remaining trackingUI_* tests out of b/b/c/test/general,
since I needed to touch them anyway

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

--HG--
rename : browser/base/content/test/general/benignPage.html => browser/base/content/test/trackingUI/benignPage.html
rename : browser/base/content/test/general/browser_trackingUI_3.js => browser/base/content/test/trackingUI/browser_trackingUI_3.js
rename : browser/base/content/test/general/browser_trackingUI_4.js => browser/base/content/test/trackingUI/browser_trackingUI_animation_2.js
rename : browser/base/content/test/general/browser_trackingUI_6.js => browser/base/content/test/trackingUI/browser_trackingUI_fetch.js
rename : browser/base/content/test/general/browser_trackingUI_5.js => browser/base/content/test/trackingUI/browser_trackingUI_pbmode_exceptions.js
rename : browser/base/content/test/general/browser_trackingUI_telemetry.js => browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
rename : browser/base/content/test/general/file_trackingUI_6.html => browser/base/content/test/trackingUI/file_trackingUI_fetch.html
rename : browser/base/content/test/general/file_trackingUI_6.js => browser/base/content/test/trackingUI/file_trackingUI_fetch.js
rename : browser/base/content/test/general/file_trackingUI_6.js^headers^ => browser/base/content/test/trackingUI/file_trackingUI_fetch.js^headers^
rename : browser/base/content/test/general/trackingPage.html => browser/base/content/test/trackingUI/trackingPage.html
extra : rebase_source : 2a12463ab2ba39bdcf077580a2d6e565f80c879c
2018-08-08 14:31:34 +02:00

52 lines
2.1 KiB
JavaScript

/*
* Test that the Tracking Protection is correctly enabled / disabled
* in both normal and private windows given all possible states of the prefs:
* privacy.trackingprotection.enabled
* privacy.trackingprotection.pbmode.enabled
* See also Bug 1178985.
*/
const PREF = "privacy.trackingprotection.enabled";
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF);
Services.prefs.clearUserPref(PB_PREF);
});
add_task(async function testNormalBrowsing() {
let TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
ok(TrackingProtection, "TP is attached to the browser window");
Services.prefs.setBoolPref(PREF, true);
Services.prefs.setBoolPref(PB_PREF, false);
ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=false)");
Services.prefs.setBoolPref(PB_PREF, true);
ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=true)");
Services.prefs.setBoolPref(PREF, false);
Services.prefs.setBoolPref(PB_PREF, false);
ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=false)");
Services.prefs.setBoolPref(PB_PREF, true);
ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=true)");
});
add_task(async function testPrivateBrowsing() {
let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
let TrackingProtection = privateWin.gBrowser.ownerGlobal.TrackingProtection;
ok(TrackingProtection, "TP is attached to the browser window");
Services.prefs.setBoolPref(PREF, true);
Services.prefs.setBoolPref(PB_PREF, false);
ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=false)");
Services.prefs.setBoolPref(PB_PREF, true);
ok(TrackingProtection.enabled, "TP is enabled (ENABLED=true,PB=true)");
Services.prefs.setBoolPref(PREF, false);
Services.prefs.setBoolPref(PB_PREF, false);
ok(!TrackingProtection.enabled, "TP is disabled (ENABLED=false,PB=false)");
Services.prefs.setBoolPref(PB_PREF, true);
ok(TrackingProtection.enabled, "TP is enabled (ENABLED=false,PB=true)");
privateWin.close();
});