Skip to content

Commit

Permalink
Use placeholders for "trackers found" options text
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Jul 16, 2018
1 parent 1d32577 commit 1f805af
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
21 changes: 15 additions & 6 deletions src/_locales/en_US/messages.json
Expand Up @@ -191,10 +191,6 @@
"message": "Privacy Badger Options",
"description": ""
},
"options_pb_has_detected": {
"message": "Privacy Badger has detected",
"description": "Beginning of message on the Tracking Domains options page tab that shows the total number of trackers detected so far."
},
"report_terms": {
"message": "This will automatically send the following information to EFF: the site you're currently visiting, your browser version, the version of Privacy Badger, and the state of all of the sliders for this site.",
"description": ""
Expand Down Expand Up @@ -403,8 +399,21 @@
"description": "Intro page paragraph."
},
"options_domain_list_trackers": {
"message": "potential <a target='_blank' tabindex=-1 title='i18n_what_is_a_tracker' class='tooltip' href='https://www.eff.org/privacybadger#faq-What-is-a-third-party-tracker?'>tracking domains</a> so far. These sliders let you control how Privacy Badger handles each tracker.",
"description": "Continuation of message on the Tracking Domains options page tab that shows the total number of trackers detected so far."
"message": "Privacy Badger has detected $COUNT$ potential $TRACKER_LINK_START$tracking domains$TRACKER_LINK_END$ so far. These sliders let you control how Privacy Badger handles each tracker.",
"description": "Message under the Tracking Domains tab on the options page. Shown after Privacy Badger learned about more than one tracker.",
"placeholders": {
"count": {
"content": "$1",
"example": "900"
},
"tracker_link_start": {
"content": "$2",
"example": "<a title='What is a tracker?' href='https://www.eff.org/privacybadger#faq-What-is-a-third-party-tracker?'>"
},
"tracker_link_end": {
"content": "</a>"
}
}
},
"name": {
"message": "Privacy Badger",
Expand Down
15 changes: 7 additions & 8 deletions src/js/options.js
Expand Up @@ -459,8 +459,6 @@ function reloadTrackingDomainsTab() {
var allTrackingDomains = getOriginsArray(originCache);
if (!allTrackingDomains || allTrackingDomains.length === 0) {
// leave out number of trackers and slider instructions message if no sliders will be displayed
$("#pb_has_detected").hide();
$("#count").hide();
$("#options_domain_list_trackers").hide();
$("#options_domain_list_one_tracker").hide();

Expand All @@ -480,18 +478,19 @@ function reloadTrackingDomainsTab() {
$("#tracking-domains-div").show();

// Update messages according to tracking domain count.
if (allTrackingDomains.length === 1) {
if (allTrackingDomains.length == 1) {
// leave out messages about multiple trackers
$("#pb_has_detected").hide();
$("#count").hide();
$("#options_domain_list_trackers").hide();

// show singular "tracker" message
$("#options_domain_list_one_tracker").show();
} else {
$("#pb_has_detected").show();
$("#count").text(allTrackingDomains.length).show();
$("#options_domain_list_trackers").show();
$("#options_domain_list_trackers").html(i18n.getMessage(
"options_domain_list_trackers", [
allTrackingDomains.length,
"<a target='_blank' title='" + _.escape(i18n.getMessage("what_is_a_tracker")) + "' class='tooltip' href='https://www.eff.org/privacybadger#faq-What-is-a-third-party-tracker?'>"
]
)).show();
}

// Get containing HTML for domain list along with toggle legend icons.
Expand Down
2 changes: 1 addition & 1 deletion src/skin/options.html
Expand Up @@ -70,7 +70,7 @@ <h1><span class="i18n_options_title"></span></h1>
</div>
<div id="blockedResourcesContainer">
<p id="pbInstructions">
<span id="pb_has_detected" class="i18n_options_pb_has_detected"></span> <span id='count'>0</span> <span id="options_domain_list_trackers" class="i18n_options_domain_list_trackers"></span>
<span id="options_domain_list_trackers"></span>
<span id="options_domain_list_one_tracker" class="i18n_options_domain_list_one_tracker" style="display:none"></span>
<span id="options_domain_list_no_trackers" class="i18n_options_domain_list_no_trackers" style="display:none"></span>
</p>
Expand Down
20 changes: 5 additions & 15 deletions tests/selenium/options_test.py
Expand Up @@ -98,10 +98,6 @@ def test_added_origin_display(self):
self.driver.find_element_by_id("options_domain_list_one_tracker").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_no_trackers").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("pb_has_detected").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("count").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_trackers").is_displayed(), error_message)

Expand All @@ -126,21 +122,19 @@ def test_added_multiple_origins_display(self):
self.select_domain_list_tab()

error_message = "Only the 'multiple tracker' messages should be displayed after adding 2 origins"
self.assertTrue(
self.driver.find_element_by_id("pb_has_detected").is_displayed(), error_message)
self.assertTrue(
self.driver.find_element_by_id("count").is_displayed(), error_message)
self.assertTrue(
self.driver.find_element_by_id("options_domain_list_trackers").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_one_tracker").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_no_trackers").is_displayed(), error_message)

# Check tracker count.
error_message = "Origin tracker count should be 2 after adding origin"
# check tracker count
self.assertEqual(
self.driver.find_element_by_id("count").text, "2", error_message)
self.driver.find_element_by_id("options_domain_list_trackers").text,
"Privacy Badger has detected 2 potential tracking domains so far. These sliders let you control how Privacy Badger handles each tracker.",
"Origin tracker count should be 2 after adding origin"
)

# Check those origins are displayed.
origins = self.driver.find_element_by_id("blockedResourcesInner")
Expand Down Expand Up @@ -190,10 +184,6 @@ def test_removed_origin_display(self):
error_message = "Only the 'no trackers' message should be displayed before adding an origin"
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_one_tracker").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("pb_has_detected").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("count").is_displayed(), error_message)
self.assertFalse(
self.driver.find_element_by_id("options_domain_list_trackers").is_displayed(), error_message)

Expand Down

0 comments on commit 1f805af

Please sign in to comment.