Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop vestigial Firefox support #7237

Merged
merged 8 commits into from
Jan 1, 2024
Merged

Drop vestigial Firefox support #7237

merged 8 commits into from
Jan 1, 2024

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Dec 31, 2023

What does this PR do?

Drops all Firefox-related code as per #7236 (comment)

Checklist

  • Add tests
  • New files added to src/tsconfig.strictNullChecks.json (if possible)
  • Designate a primary reviewer: @twschiller

Copy link

codecov bot commented Dec 31, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (9dc1388) 71.50% compared to head (753bd55) 71.63%.

Files Patch % Lines
src/background/webextAlert.ts 0.00% 1 Missing ⚠️
src/contrib/zapier/PushOptions.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7237      +/-   ##
==========================================
+ Coverage   71.50%   71.63%   +0.12%     
==========================================
  Files        1213     1208       -5     
  Lines       37797    37699      -98     
  Branches     7098     7078      -20     
==========================================
- Hits        27028    27005      -23     
+ Misses      10769    10694      -75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -5,7 +5,6 @@
<content url="file://$MODULE_DIR$">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this file? It has some ancient directories

Copy link
Contributor

@twschiller twschiller Dec 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from IntelliJ - those excludeFolder entries tell IntelliJ not to index those folders. The outdated directories don't hurt anything, but could drop them to clean up the file

@@ -51,7 +50,7 @@ const NetworkErrorDetail: React.FunctionComponent<{
const absoluteUrl = selectAbsoluteUrl(error.config);

const permissionsState = useAsyncState<boolean | undefined>(
async () => containsPermissions({ origins: [absoluteUrl] }),
async () => browser.permissions.contains({ origins: [absoluteUrl] }),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Chrome there's no change, it was already short-circuited this way.


import { expectContext } from "@/utils/expectContext";

export async function onTabClose(watchedTabId: number): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -139 to -141
async function requestPermissionsFromUserGesture(
permissions: Permissions.Permissions,
): Promise<boolean> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has no special logic around browser.permissions.request that actually deals with user-gesture loss. Is it only named this way to be aware of the possibility?

I dropped the entire thing because it just had exceptions for Firefox, but ensurePermissionsFromUserGesture remains above, also without special logic.

Copy link
Contributor

@twschiller twschiller Dec 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.permissions.request that actually deals with user-gesture

What do you mean it "deals" with it? If the gesture is lost, IIRC it just returns false (or maybe throws?)

Is it only named this way to be aware of the possibility?

Correct, requestPermissionsFromUserGesture is named that way to remind callers that it needs to come from a detectable gesture (so there should be no long-running operations between the gesture and the call)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.request() will throw with "xx must be triggered by user gesture"

What do you mean it "deals" with it?

I think that PB does have a way to request permissions even outside user gestures, and I thought this was it. The "way" I remember looked something like "if .request() fails, then show a popup so that the user will have to click"

Copy link
Contributor

@twschiller twschiller Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "way" I remember looked something like "if .request() fails, then show a popup so that the user will have to click"

I don't think so?

Even so, it should always have been called from a button click for activate or grant permissions. (I don't think we had any flows where it could trigger a popup at a seemingly arbitrary time). We had reworked network call ordering, etc. to ensure that the Chrome permissions call was always made within the timeout window

Copy link
Contributor Author

@fregante fregante Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh here it is, the copy-to-clipboard brick uses that:

image

The detection is here:

function isDocumentFocusError(error: unknown): boolean {
// Chrome throws a DOMException with the message "Document is not focused" when it can't establish a user action
// for the clipboard write request
// https://stackoverflow.com/questions/56306153/domexception-on-calling-navigator-clipboard-readtext/70386674#70386674
return getErrorMessage(error)
.toLowerCase()
.includes("document is not focused");
}

What I was suggesting was basically:

  1. permissions.request()
  2. if it fails with "user gesture", inject "click anywhere to continue"
  3. call permissions.request() in document.onclick

I'll open an issue:

Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@twschiller twschiller merged commit 2b37d84 into main Jan 1, 2024
21 checks passed
@twschiller twschiller deleted the F/feature/drop-firefox branch January 1, 2024 21:13
@grahamlangford grahamlangford added this to the 1.8.6 milestone Jan 2, 2024
@fregante fregante mentioned this pull request Jan 20, 2024
1 task
fregante added a commit that referenced this pull request Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
firefox Issues related to Firefox
Development

Successfully merging this pull request may close these issues.

3 participants