diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/uitour/test/browser_trackingProtection_tour.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/uitour/test/browser_trackingProtection_tour.js')
-rw-r--r-- | browser/components/uitour/test/browser_trackingProtection_tour.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/browser/components/uitour/test/browser_trackingProtection_tour.js b/browser/components/uitour/test/browser_trackingProtection_tour.js new file mode 100644 index 000000000..0ee0e1686 --- /dev/null +++ b/browser/components/uitour/test/browser_trackingProtection_tour.js @@ -0,0 +1,77 @@ +"use strict"; + +var gTestTab; +var gContentAPI; +var gContentWindow; + +const { UrlClassifierTestUtils } = Cu.import("resource://testing-common/UrlClassifierTestUtils.jsm", {}); + +const TP_ENABLED_PREF = "privacy.trackingprotection.enabled"; + +add_task(setup_UITourTest); + +add_task(function* test_setup() { + Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true); + yield UrlClassifierTestUtils.addTestTrackers(); + + registerCleanupFunction(function() { + UrlClassifierTestUtils.cleanupTestTrackers(); + Services.prefs.clearUserPref("privacy.trackingprotection.enabled"); + }); +}); + +add_UITour_task(function* test_unblock_target() { + yield* checkToggleTarget("controlCenter-trackingUnblock"); +}); + +add_UITour_task(function* setup_block_target() { + // Preparation for test_block_target. These are separate since the reload + // interferes with UITour as it does a teardown. All we really care about + // is the permission manager entry but UITour tests shouldn't rely on that + // implementation detail. + TrackingProtection.disableForCurrentPage(); +}); + +add_UITour_task(function* test_block_target() { + yield* checkToggleTarget("controlCenter-trackingBlock"); + TrackingProtection.enableForCurrentPage(); +}); + + +function* checkToggleTarget(targetID) { + let popup = document.getElementById("UITourTooltip"); + + yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () { + let doc = content.document; + let iframe = doc.createElement("iframe"); + iframe.setAttribute("id", "tracking-element"); + iframe.setAttribute("src", "https://tracking.example.com/"); + doc.body.insertBefore(iframe, doc.body.firstChild); + }); + + let testTargetAvailability = function* (expectedAvailable) { + let data = yield getConfigurationPromise("availableTargets"); + let available = (data.targets.indexOf(targetID) != -1); + is(available, expectedAvailable, "Target has expected availability."); + }; + yield testTargetAvailability(false); + yield showMenuPromise("controlCenter"); + yield testTargetAvailability(true); + + yield showInfoPromise(targetID, "This is " + targetID, + "My arrow should be on the side"); + is(popup.popupBoxObject.alignmentPosition, "end_before", + "Check " + targetID + " position"); + + let hideMenuPromise = + promisePanelElementHidden(window, gIdentityHandler._identityPopup); + yield gContentAPI.hideMenu("controlCenter"); + yield hideMenuPromise; + + ok(!is_visible(popup), "The tooltip should now be hidden."); + yield testTargetAvailability(false); + + yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () { + content.document.getElementById("tracking-element").remove(); + }); +} |