Refactor FXIOS-14739 [Webview delegates] Javascript alerts with async variant#31827
Refactor FXIOS-14739 [Webview delegates] Javascript alerts with async variant#31827
Conversation
|
Build failed due to increased warnings count, but I see duplicates in there. Not sure what's up |
d89cbeb to
332e72e
Compare
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
|
FYI It's late here so I'll test the use cases again tomorrow morning! Requesting review now just to kick-start the process forward in the meantime. |
🥇 Perfect PR sizeSmaller PRs are easier to review. Thanks for making life easy for reviewers! ✨ 💬 Description craftsmanGreat PR description! Reviewers salute you 🫡 🦊 BrowserViewController CheckWe’re tracking the size of
❌ Per-file test coverage gateThe following changed file(s) are below 35.0% coverage:
Client.app: Coverage: 37.23
Generated by 🚫 Danger Swift against 1de00d0 |
|
Went through the tests cases again, all LGTM this is ready for review |
mattreaganmozilla
left a comment
There was a problem hiding this comment.
This seems like a potentially significant change in how these are being executed, so hopefully @ih-codes can also take a look. Approving, but I haven't had a chance to test the branch yet, I can do so later today. Can you also LMK if we've tested the JS alert spam bug? If not I can do that before we merge.
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
ih-codes
left a comment
There was a problem hiding this comment.
A few thoughts... I'm going to tinker a bit more to see if I can think of a way to rewrite the handler method instead of duplicating the logic. 🤔
Still have to test as well before I approve, but wanted to give this a first pass!
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
...ontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift
Show resolved
Hide resolved
You can look at the |
|
I'll get back to this soon, finishing up on the incident. Probably by tomorrow I should be able to give this another go |
ih-codes
left a comment
There was a problem hiding this comment.
During testing, I tried Test Case 3 from the ticket. Seems after I tab switch via swipe to add a new homepage tab, and then swipe to go back the tab after 5 seconds, it is in a glitched state. The screen is blank. But if I open the tab manager to re-visit the same tab, everything starts working again.
BUT... on main I just don't see the alerts at all? So... I'm sure something was glitchy with the swipe switing tabs to begin with, but it looks slightly worse here...?
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-01-29.at.13.20.59.mov
All the other test cases checked out as far as I could tell. We should update the main ticket with all the test cases + @mattreaganmozilla's prompt spam case as well just so QA knows where to look.
FYI I think we're ok with the prompt spam, I tested the branch and looked good to me. |
332e72e to
6722490
Compare
|
As Isabella commented, indeed when we swipe tabs we're not dequeueing the alerts. We had that problem before this PR, since the This is why I am currently moving the JS alert dequeuing temporarily to |
|
Ready for another review! Cleaned up with the comments + made a fix as explained above. @mattreaganmozilla I didn't DRY it out, as per Isabella's investigation. Let me know if this isn't satisfactory! |
There was a problem hiding this comment.
Thanks for the detailed explanation and followup ticket @lmarceau!
I pulled down and tested all the cases in the ticket once more after your change. I'm not seeing that issue with the swiping tabs anymore. 😃
I will approve since we made a ticket to revisit that later. By the way, CI failed with testPopUpBlocker. I'll retrigger it for you just in case it was a one-time thing. I noticed that it passed locally for me. 🤔
/Users/vagrant/git/firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift:224 - failed - Timed out waiting for element "AddressToolbar.address" TextField to contain value [example.com](https://example.com/)
| /// `WKNavigationDelegate` JS alert async methods return prematurely, the web page may resume early, leading to incorrect | ||
| /// behavior. | ||
| /// Previously we used the `WKNavigationDelegate` JS alert methods with `completionHandler`s. Failing to call the | ||
| /// `completionHandler` would crash the app with a runtime exception. We've replace them with `continuation`s to |
There was a problem hiding this comment.
We've replaced them
I must have given you documentation with a typo, I'm sorry 🥹 (Don't waste your time fixing unless you commit for something else lol)
There was a problem hiding this comment.
I'll make this change in another PR!
|
🚀 PR merged to |
📜 Tickets
Jira ticket
Github issue
💡 Description
Trying to make minimal changes only in that area, using continuations instead of completion handlers. This work is needed due to the same reasons explained in #31792.
Testing Instructions
Tested with use cases under this JIRA ticket. There are 6 use cases in total.
📝 Checklist