Page MenuHomePhabricator

Bug 1656171 - Shim requestStorageAccess calls for Kinja-powered blogs. r=twisniewski!,#anti-tracking-reviewers
ClosedPublic

Authored by emz on Sep 3 2021, 6:32 PM.
Referenced Files
Unknown Object (File)
Mon, Jun 2, 8:20 PM
Unknown Object (File)
May 30 2025, 4:54 AM
Unknown Object (File)
May 27 2025, 11:50 PM
Unknown Object (File)
May 27 2025, 9:53 AM
Unknown Object (File)
May 26 2025, 9:31 PM
Unknown Object (File)
May 24 2025, 10:34 AM
Unknown Object (File)
May 15 2025, 7:33 AM
Unknown Object (File)
May 13 2025, 6:54 AM
Subscribers

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emz planned changes to this revision.Sep 3 2021, 6:32 PM
emz created this revision.
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".Sep 3 2021, 6:33 PM
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
emz retitled this revision from WIP: Bug 1656171 - Kinja shim to WIP: Bug 1656171 - Shim requestStorageAccess calls for Kinja-powered blogs. r=twisniewski!,#anti-tracking-reviewers.
emz planned changes to this revision.Sep 29 2021, 3:20 PM
emz requested review of this revision.Sep 29 2021, 3:31 PM
emz updated this revision to Diff 488354.
emz retitled this revision from WIP: Bug 1656171 - Shim requestStorageAccess calls for Kinja-powered blogs. r=twisniewski!,#anti-tracking-reviewers to Bug 1656171 - Shim requestStorageAccess calls for Kinja-powered blogs. r=twisniewski!,#anti-tracking-reviewers.

D126879 fixes an issue where the popup blocker would block subsequent calls of window.open the website made after the shim requested storage access. There is still a remaining issue I need to address on the platform side: If the user gets prompted for storage access and doesn't accept the prompt within 5 seconds we will block window.open calls. However this is currently rare since we mostly auto grant storage access.

Note that when testing, you should set the pref privacy.antitracking.enableWebcompat to false. This is necessary because the sites are currently on the exception list for partitioning. The pref will also disable the auto grants and trigger a storage access prompt every time.

Good stuff.

r+ with nits addressed.

browser/extensions/webcompat/data/shims.js
512

As we discussed elsewhere, this check isn't currently working for contentScripts, so until that's fixed we need to make sure that it's alright for this shim to apply even if dFPI isn't active.

browser/extensions/webcompat/manifest.json
5

This will of course have to change when we finally land; we're up to 27.1.0 already :)

132

Minor nit: let's keep this in alphabetized order

browser/extensions/webcompat/shims/kinja.js
86

If I'm not misreading this, we could optionally simplify it a little to use this form:

const SITE_LOGIN_BUTTON_SELECTOR = `
  button svg[aria-label^="Facebook"],
  button svg[aria-label^="Google"],
  button svg[aria-label^="Twitter"]
`;

function getSiteLoginButtons(parentElement) {
  return Array.from(
    parentElement
     .querySelectorAll(SITE_LOGIN_BUTTON_SELECTOR)
     .map(el => el.closest("button")
  );
}

And if we worry that the DOM of the buttons changes, we could add the filter check as well (for null closest elements).

We could of course pre-generate the string out of the array, so it doesn't have to be hard-coded:

const SITE_LOGIN_BUTTON_SELECTOR =
   SITE_LOGIN_BUTTON_SVG_LABELS
     .map(label => `button svg[aria-label^="${label}"]`)
     .join(",");

But the first variant strikes me as being more readable.

137

nit: const instead of let for these

145

nit: should this var name not be *_ID instead of *_CLASS?

This revision is now accepted and ready to land.Sep 29 2021, 6:09 PM

This revision requires a Testing Policy Project Tag to be set before landing. Please apply one of testing-approved, testing-exception-unchanged, testing-exception-ui, testing-exception-elsewhere, testing-exception-other. Tip: this Firefox add-on makes it easy!

emz marked 5 inline comments as done.
browser/extensions/webcompat/data/shims.js
512

There is a slightly higher risk of breaking the site, just because we run the shim script even if we don't strictly require it. However, requesting storage access with dFPI turned off works fine and the site still works normally.
I think this can land like this in Nightly, but we should still make the dFPI flag work for content scripts.

I've filed https://bugzilla.mozilla.org/show_bug.cgi?id=1733370 for adding support for the flag.

browser/extensions/webcompat/shims/kinja.js
86

Great suggestion, thank you!

We don't have a testing harness for shims yet. Also, testing the actual shim with the production site isn't feasible.

emz marked an inline comment as done.

Rebased and bumped extension version.

emz requested review of this revision.Oct 6 2021, 3:23 PM

New approach where the window.open call does not get blocked by the popup blocker. This is also much simpler and shouldn't break as easily as relying on specific buttons.

This revision is now accepted and ready to land.Oct 15 2021, 7:20 PM