Fix AccessibilityInfo.isHighTextContrastEnabled unresolved promise#56066
Closed
chicio wants to merge 1 commit intofacebook:mainfrom
Closed
Fix AccessibilityInfo.isHighTextContrastEnabled unresolved promise#56066chicio wants to merge 1 commit intofacebook:mainfrom
chicio wants to merge 1 commit intofacebook:mainfrom
Conversation
Collaborator
|
This pull request was successfully merged by @chicio in 5c9a571 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This PR fixes a bug in the
AccessibilityInfocomponent. This is a follow up of the work I started with the PRs I opened in the last weeks #55920 #56019.AccessibilityInfoexposes the methodisHighTextContrastEnabled. In the else branch, Promise.resolve(false) as return value was creating a new unrelated promise that never calls the resolve function provided by the promise executor constructor, so it hangs indefinitely (in the previous PRs the same bug affected the Android branch).This means that if a user calls this method eg. on iOS without any
Platform.OS === 'android'guard, it will result in an unresolved promise.I fixed the bug in the same way as in the other PRs: by aligning the implementation of
isHighTextContrastEnabledto the one of other methods.I also added the tests to avoid regression, and additionally verify that the Android method is doing what we are expecting (in both cases for when
NativeAccessibilityInfoAndroid.isHighTextContrastEnabledis available or not).The mock of the Platform object has been done the same way I saw while doing another contribution in the Pressability-test (see #55378).
PS I will open one (or more if I see it is too big) PR to add the missing tests for the other `AccessibilityInfo methods still not tested.
Changelog:
[GENERAL] [FIXED] - Fix AccessibilityInfo.isHighTextContrastEnabled unresolved (never ending) promise
Test Plan:
This fix (as for the other PRs), was developed using TDD. I first added a failing test to reproduce that the iOS branch of the
isHighTextContrastEnabledmethod was acting as described above (resulting in failure due to jest timeout because the promise was not returning). Then I applied the fix, and finally added also the test for the Android counterpart.