Conversation
|
✅ Work item link check complete. Description contains link AB#3547597 to an Azure Boards work item. |
- Skip super.onViewCreated() call to prevent OnBackPressedCallback registration - Add Robolectric unit test verifying no back press callback is registered Co-authored-by: mohitc1 <22034758+mohitc1@users.noreply.github.com>
|
❌ Invalid work item number: AB#3547597
Click here to learn more. |
1 similar comment
|
❌ Invalid work item number: AB#3547597
Click here to learn more. |
|
@copilot add changelog |
Co-authored-by: mohitc1 <22034758+mohitc1@users.noreply.github.com>
|
@copilot update test to run without robolectic and activity. Just use kotlin mockito. |
…ewAuthorizationFragment Co-authored-by: mohitc1 <22034758+mohitc1@users.noreply.github.com>
Done in 63af79e. Replaced the Robolectric+Activity test with a plain Key change to enable spying: The test:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot revert last commit |
Co-authored-by: mohitc1 <22034758+mohitc1@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR prevents SilentWebViewAuthorizationFragment (used for silent/invisible WebView auth flows) from intercepting device back presses by skipping the OnBackPressedCallback registration inherited from AuthorizationFragment.
Changes:
- Override
SilentWebViewAuthorizationFragment.onViewCreated()to avoid registering the parentOnBackPressedCallback. - Add a Robolectric unit test intended to verify no enabled back-pressed callbacks are registered.
- Add a
vNextchangelog entry documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/SilentWebViewAuthorizationFragment.kt | Skips parent onViewCreated() to prevent silent fragment from registering a back-press callback. |
| common/src/test/java/com/microsoft/identity/common/internal/providers/oauth2/SilentWebViewAuthorizationFragmentTest.kt | Adds a Robolectric test to assert no enabled OnBackPressedCallback is registered. |
| changelog.txt | Adds a [PATCH] vNext entry for the back button interception fix. |
You can also share your feedback on Copilot code review. Take the survey.
SilentWebViewAuthorizationFragmentinheritedAuthorizationFragment.onViewCreated(), which registers an enabledOnBackPressedCallback. During silent/invisible flows (SWAG), this caused the invisible fragment to intercept device back presses — either navigating within a hidden WebView or cancelling authorization unexpectedly — breaking host app back navigation.Changes
SilentWebViewAuthorizationFragment.ktonViewCreated()without callingsuper.onViewCreated(), skipping theOnBackPressedCallbackregistration inAuthorizationFragmentcancelAuthorizationOnTimeOut()is retained asprivate; timeout behavior is unaffectedSilentWebViewAuthorizationFragmentTest.ktOnBackPressedCallbackis registered afteronViewCreated()by launching a realSilentAuthorizationActivityand assertingonBackPressedDispatcher.hasEnabledCallbacks()returnsfalsechangelog.txt[PATCH]entry for this fix undervNextOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.