Closed Bug 1362787 Opened 4 years ago Closed 4 years ago

Implement chrome.privacy.websites.referrersEnabled

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(firefox56 fixed)

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: Manuel.Spam, Assigned: bsilverberg)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, Whiteboard: [privacy]triaged)

Attachments

(1 file)

Implement "chrome.privacy.websites" API as described here:
https://developer.chrome.com/extensions/privacy#property-websites
I want to use this API to create a simple button to toggle sending the Referrer. I prefer to surf with Referrer disabled completely. I toggle it "on" temporarily for sites which force me to use the Referrer.
Flags: needinfo?(bob.silverberg)
Whiteboard: investigating
This is only asking for one of the settings under chrome.privacy.websites, which is `referrersEnabled`, so I am updating the bug title.

Based on my initial research into the privacy API, this can be implemented by changing the pref `network.http.sendRefererHeader` to 0 when set to "false" and to 2 (which is the default) when set to "true".

As this is fairly simple I will take it on and work on implementing it.
Assignee: nobody → bob.silverberg
Blocks: 1363856
Flags: needinfo?(bob.silverberg)
Priority: -- → P3
Summary: Implement chrome.privacy.websites API → Implement chrome.privacy.websites.referrersEnabled
Whiteboard: investigating → [privacy]triaged
Comment on attachment 8876791 [details]
Bug 1362787 - Implement chrome.privacy.websites.referrersEnabled,

https://reviewboard.mozilla.org/r/148114/#review152604

::: toolkit/components/extensions/ext-privacy.js:123
(Diff revision 1)
> +  // When this setting is true, the pref should be set to 2, and when
> +  // this setting is false, the pref should be set to 0.

This comment is really not helpful, can you include a reference to docs or code where these values come from.

::: toolkit/components/extensions/test/xpcshell/test_ext_privacy.js:277
(Diff revision 1)
> -  async function testSetting(setting, value, truePrefs) {
> +  function checkBoolean(value, pref, prefValue, truePrefs) {
> +    equal(prefValue, truePrefs.includes(pref), `${pref} set correctly for ${value}`);
> +  }
> +
> +  function checkSinglePrefValue(value, pref, prefValue, expectedValue) {
> +    equal(prefValue, expectedValue, `${pref} set correctly for ${value}`);
> +  }
> +
> +  async function testSetting(setting, value, checkArgs, checkFn = checkBoolean) {
>      extension.sendMessage("set", {value: value}, setting);
>      let data = await extension.awaitMessage("settingData");
>      equal(data.value, value);
>      for (let pref in SETTINGS[setting]) {
>        let prefValue = Preferences.get(pref);
> -      equal(prefValue, truePrefs.includes(pref), `${pref} set correctly for ${value}`);
> +      checkFn(value, pref, prefValue, checkArgs);
>      }
>    }

This seems unnecessarily roundabout, it might be more verbose but it would be much more clear to just pass in an array or object with the expected values in all cases.
Attachment #8876791 - Flags: review?(aswan) → review-
Comment on attachment 8876791 [details]
Bug 1362787 - Implement chrome.privacy.websites.referrersEnabled,

https://reviewboard.mozilla.org/r/148114/#review152940

::: toolkit/components/extensions/ext-privacy.js:125
(Diff revisions 1 - 2)
>      "network.http.sendRefererHeader",
>    ],
>  
> -  // When this setting is true, the pref should be set to 2, and when
> -  // this setting is false, the pref should be set to 0.
> +  // Values for network.http.sendRefererHeader:
> +  // 0=don't send any, 1=send only on clicks, 2=send on image requests as well
> +  // http://searchfox.org/mozilla-central/source/modules/libpref/init/all.js#1585

Please make this a permalink

::: toolkit/components/extensions/test/xpcshell/test_ext_privacy.js:281
(Diff revisions 1 - 2)
> -    for (let pref in SETTINGS[setting]) {
> -      let prefValue = Preferences.get(pref);
> +    for (let pref in expected) {
> +      equal(Preferences.get(pref), expected[pref], `${pref} set correctly for ${value}`);
> -      checkFn(value, pref, prefValue, checkArgs);
>      }

nit: can you just use `Assert.deepEqual()` here?
Attachment #8876791 - Flags: review?(aswan) → review+
Pushed by bsilverberg@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6787902423dc
Implement chrome.privacy.websites.referrersEnabled, r=aswan
https://hg.mozilla.org/mozilla-central/rev/6787902423dc
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Keywords: dev-doc-needed
I've updated the compat data for this:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/privacy/websites

Marking as dev-doc-complete, but please let me know if we need anything else here.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.