Commit Graph

12270 Commits

Author SHA1 Message Date
Tim Yung 5a8327857b RN: Configure Jest for React 19 (#44989)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44989

Enables these 2 global feature flags for React Native Jest testing:

- `IS_REACT_ACT_ENVIRONMENT`
- `IS_REACT_NATIVE_TEST_ENVIRONMENT`

Changelog:
[General][Changed] - Enables React global flag that causes Jest testing environment to require `act()`

Reviewed By: robhogan

Differential Revision: D58644562

fbshipit-source-id: 4de5ea3a89e8ca99ac4c1c21721872db4f5552b3
2024-06-17 02:59:55 -07:00
Tim Yung 180dbbf0fb RN: Mitigate Remaining Jest Failures for React 19 (#45002)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45002

There are a couple Jest unit test cases for `VirtualizedList-test.js` that require further investigation.

We believe that these are problems with Jest fake timers in the test and not with the component itself, so for now let's skip them so as to unblock the upgrade to React 19.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58656948

fbshipit-source-id: d52f3ad8277def6eae20cbbc11751d73b769d929
2024-06-17 02:59:55 -07:00
Tim Yung fe06cbfbf3 Add missing acts to VirtualizedList-test and migrate to async act (#44997)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44997

Wrap `VirtualizedList-test` uses of `react-test-renderer` in `act` as appropriate, so as to pass under current React and mostly pass under React 19, with further fixes to come.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D58649295

fbshipit-source-id: 5e0fa791d581fbf004a2ca7eaa5c4b4d9a15ddfe
2024-06-16 23:02:19 -07:00
Rob Hogan 8c06a69163 assetRelativePathInSnapshot-test: use act-wrapping abstraction for create
Summary:
Migrate assetRelativePathInSnapshot-test to `act`-wrapping abstraction for `react-test-renderer` `create` in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653908

fbshipit-source-id: 432b172348c445b1684e60cf60b6ab94d62f21e1
2024-06-16 21:38:01 -07:00
Rob Hogan 50e65d4828 FlatList-test: use act-wrapping abstraction for create
Summary:
Migrate FlatList-test to `act`-wrapping abstraction for `react-test-renderer` `create` in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653845

fbshipit-source-id: 426fcef454927cee0eb2c38ef16c82106354e5d9
2024-06-16 21:38:01 -07:00
Rob Hogan cf6df4392f TouchableWithoutFeedback-test: use act-wrapping abstraction for create
Summary:
Migrate TouchableWithoutFeedback-test to `act`-wrapping abstraction for `react-test-renderer` `create` in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653765

fbshipit-source-id: 901ea10ec5dd72f8403a84cfd9f9e8ed55dbe04c
2024-06-16 21:38:01 -07:00
Rob Hogan a6e4e3aad2 ReacNativeTestTools-test: use act-wrapping abstraction for create
Summary:
Migrate ReacNativeTestTools-test to `act`-wrapping abstraction for `react-test-renderer` `create` in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653724

fbshipit-source-id: bd33fcde6d620f6b5400a043b3ef944ddba7607e
2024-06-16 21:38:01 -07:00
Rob Hogan 6d836c5182 TouchableOpacity-test: use act-wrapping abstraction for create
Summary:
Migrate TouchableOpacity-test to `act`-wrapping abstraction for `react-test-renderer` `create` in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653673

fbshipit-source-id: 612ef12bca3011951297b5c17f1606e7cb7eebe7
2024-06-16 21:38:01 -07:00
Rob Hogan a66ba92526 VirtualizedSectionList-test: use act around react-test-renderer create
Summary:
Migrate `VirtualizedSectionList-test` to use `act`-wrapping in prepation for React 19.

Avoid the `react-native/jest/renderer` abstractions as this is a separate package.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653558

fbshipit-source-id: 0e19fff5c3998fb00b71c3d07100a2064682cb4c
2024-06-16 21:38:01 -07:00
Rob Hogan 102546bf04 AnimatedNative-test: use act-wrapping abstraction for create, update, unmount
Summary:
Migrate `AnimatedNative-test` to `act`-wrapping abstractions in preparation for React 19.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: yungsters

Differential Revision: D58653416

fbshipit-source-id: 320bb66b068b172dc3e90e006a58a3b6a0c74920
2024-06-16 21:38:01 -07:00
Rob Hogan 9af481d38b TextInput-test: use act-wrapping abstraction for create
Summary:
Migrate TextInput-test to act-wrapping abstractions for `react-test-renderer` `create`, in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653346

fbshipit-source-id: 3fe191cbb274b651e98e75c0059011943755a5bc
2024-06-16 21:38:01 -07:00
Rob Hogan 53c125ee6e Button-test: use act-wrapping abstraction for create
Summary:
Migrate `Button-test` to async, `act`-wrapping abstractions in preparation for React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653259

fbshipit-source-id: 82e052e5ab328471d74b9f88b05bb887d89c247c
2024-06-16 21:38:01 -07:00
Rob Hogan 9381c6db25 Animated-test: use act around create, update and unmount
Summary:
Use `act`-wrapping abstractions for `create`/`update`/`unmount` in `Animated-test` so that it's React 19-ready.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653231

fbshipit-source-id: 44075dfde9740070279c0d1004674349d63de9cd
2024-06-16 21:38:01 -07:00
Rob Hogan c45896556a ReactNativeTestTools - wrap create in act
Summary:
Wrap `ReactTestRenderer.create` in `act` within `ReactNativeTestTools.expectRendersMatchingSnapshot`, as required for concurrent rendering and `IS_REACT_ACT_ENVIRONMENT` in React 19.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653136

fbshipit-source-id: 9ca0d053bda3e87dd92b762061b839d7bdd571b5
2024-06-16 21:38:01 -07:00
Pieter Vanderwerff b56646fa08 Switch 'number of lines' validation to DEV only (#44961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44961

Switch the "number of lines" warning, which ensures this value is not negative, to only fire in DEV.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58472148

fbshipit-source-id: e52849effe9a6dc3f25288a64deebd4fd7624e4e
2024-06-16 20:30:52 -07:00
Rob Hogan 9435097b16 Migrate SectionList-test to async jest/renderer create abstraction (#44999)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44999

Use `act`-wrapped abstraction for test rendering in preparation for this becoming mandatory.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58651098

fbshipit-source-id: d797c792b1f6ac155f02951a8264cf0631961d83
2024-06-16 16:55:21 -07:00
Rob Hogan b24cf4f54c Introduce update and unmount helpers to react-native/jest/renderer, use in ScrollView-test (#44998)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44998

Add async helpers to the existing `jest/renderer` module to wrap `react-test-renderer`'s `update` and `unmount` in `act`.

Migrate one test `ScrollView-test` as a usage example and to make it compatible with incoming React 19 concurrency requirements.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58650989

fbshipit-source-id: 5eb48722ee7a5487355969e553ba79c3ce361067
2024-06-16 16:55:21 -07:00
Rob Hogan 132e2a305c Wrap jest/renderer create abstraction in act for concurrent rendering (#44994)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44994

For RN monorepo tests, wrap `create` calls through our `jest/renderer` abstraction in `await act`.

This is a no-op under current React but will be required under `react-test-renderer@19` with `IS_REACT_ACT_ENVIRONMENT`.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58650940

fbshipit-source-id: 4013af89dd7c9f447b2dd493989f3a4fdf2b6508
2024-06-16 16:55:21 -07:00
Rob Hogan 84866617de LogBoxInspector-test: Mock out symbolication (#44996)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44996

Mock out some LogBoxData symbolication in LogBoxInspector-test that would otherwise make it sensitive to an async `useEffect` when wrapping in `act`.

This is immaterial to the snapshot under test (changing a state from `PENDING` to `NONE`).

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58651811

fbshipit-source-id: d47100a87d83102bbe183cb7266d66344e75b0b0
2024-06-16 16:55:21 -07:00
Rob Hogan f094990450 Migrate StatusBar-test to jest/renderer create abstraction in preparation for React 19 (#44993)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44993

Use our existing thin abstraction around `react-test-renderer` `create` within `react-native/jest/renderer`, in order to benefit from the introduction of async `act` wrapping in that abstraction.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58650874

fbshipit-source-id: d3d1967fa68568e3ae2d8069478cb79aa7049ed0
2024-06-16 16:55:21 -07:00
Rob Hogan 910e7133bc Asyncify ReactNativeTestTools.expectRendersMatchingSnapshot (#44992)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44992

To allow for async `act` in a subsequent diff, make this utility method async and awaited at all call sites.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58647828

fbshipit-source-id: 3a47c57569814638c216309eed1885dd37521dde
2024-06-16 16:55:21 -07:00
Rob Hogan 1e11257670 Make jest/renderer create helper async in prep for concurrent (#44995)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44995

Use our existing abstraction around `react-test-renderer`'s `create` and make it asynchronous, to allow for wrapping `create` in `act` in a subsequent diff, and using the async API per guidance in https://react.dev/reference/react/act?#await-act-async-actfn .

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58647827

fbshipit-source-id: f81cf382892ef5ba14b452bd32980c98bd7ef03b
2024-06-16 16:55:21 -07:00
Tim Yung ffc0640bf8 RN: Remove react-shallow-renderer Dependency (#44982)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44982

Removes `react-shallow-renderer` dependency from the `react-native` package because it is no longer used.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643454

fbshipit-source-id: f9aa62af2ff0282d6b54b97da6f2870a38881947
2024-06-16 13:51:18 -07:00
Tim Yung e8d235f6e2 RN: Delete Shallow Renderer Mock Tests (#44973)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44973

Changes `expectRendersMatchingSnapshot` to no longer make assertions about shallow rendering, because shallow rendering is now deprecated.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643365

fbshipit-source-id: 03653045a44a176095c53fc0ff27743cc8ea1820
2024-06-16 13:51:18 -07:00
Tim Yung 24295b521a RN: Delete jest/renderer Shallow Render Helpers (#44984)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44984

Deletes the `jest/renderer` shallow render helpers.

The commit stack below this already migrated all references to `shallow` and `shallowRender`.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643063

fbshipit-source-id: fdf0012e06f3fb1326f3f99b78bf7a06d7f84a37
2024-06-16 13:51:18 -07:00
Tim Yung 1c706cd03f RN: Delete Shallow Renderer Cases in ImageBackground-test.js (#44980)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44980

These Jest unit test cases were making assertions about shallow rendering, but that shallow rendering is now deprecated.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643065

fbshipit-source-id: 34a31989f298535546a64c3ccd2888d648c1cdf1
2024-06-16 12:15:49 -07:00
Tim Yung 19dc990aa1 RN: Delete Shallow Renderer Cases in Image-test.js (#44977)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44977

These Jest unit test cases were making assertions about shallow rendering, but that shallow rendering is now deprecated.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643060

fbshipit-source-id: a61dfcf6cd778a8556aec874fd5e42f8e11f2be2
2024-06-16 12:15:49 -07:00
Tim Yung 02dfbeaaeb RN: Delete Shallow Renderer Cases in Modal-test.js (#44970)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44970

These Jest unit test cases were making assertions about shallow rendering, but that shallow rendering is now deprecated.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643058

fbshipit-source-id: 75c95b3ef8f9c481b50d90bf195ba3bd90196f0b
2024-06-16 12:15:49 -07:00
Tim Yung 77b441249a RN: Delete Shallow Renderer Cases in InputAccessoryView-test.js (#44975)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44975

These Jest unit test cases were making assertions about shallow rendering, but that shallow rendering is now deprecated.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643064

fbshipit-source-id: 19cb05df25b4b92ee584ea126d238276f5b214f7
2024-06-16 12:15:49 -07:00
Tim Yung f294bd8223 RN: Migrate LogBoxNotificationContainer-test.js from Shallow Renderer (#44981)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44981

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643062

fbshipit-source-id: 6d7bba78945509bbb6bdab1e6347ba0d90343ec3
2024-06-16 12:15:49 -07:00
Tim Yung 86a48c4118 RN: Migrate LogBoxNotification-test.js from Shallow Renderer (#44971)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44971

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643068

fbshipit-source-id: f3a0331140fbaa9ee19b76da8700e60b3efc525a
2024-06-16 12:15:49 -07:00
Tim Yung 81130f8b0f RN: Migrate LogBoxInspectorStackFrames-test.js from Shallow Renderer (#44976)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44976

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643067

fbshipit-source-id: 2e298e2736227afb9322463daa3db0578638559a
2024-06-16 12:15:49 -07:00
Tim Yung 96cbfb1e66 RN: Migrate LogBoxInspectorStackFrame-test.js from Shallow Renderer (#44969)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44969

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643057

fbshipit-source-id: 0d2943a714ca718841ab4bec5a33f6c9e48fea92
2024-06-16 12:15:49 -07:00
Tim Yung 6dd9fa46ca RN: Migrate LogBoxInspectorSourceMapStatus-test.js from Shallow Renderer (#44986)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44986

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643069

fbshipit-source-id: a2dbba104a7f6af57b6990da3cb0055a5390bc00
2024-06-16 12:15:49 -07:00
Tim Yung 8c0541cb12 RN: Migrate LogBoxInspectorSection-test.js from Shallow Renderer (#44983)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44983

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643056

fbshipit-source-id: 61494765f68f1810b19a33f5e2a6c5d4087ce11c
2024-06-16 12:15:49 -07:00
Tim Yung a83d8d1590 RN: Migrate LogBoxInspectorReactFrames-test.js from Shallow Renderer (#44972)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44972

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643055

fbshipit-source-id: 419fe07643f623e75050487beb9ca306417e43d9
2024-06-16 12:15:49 -07:00
Tim Yung d75a28db62 RN: Migrate LogBoxInspectorHeader-test.js from Shallow Renderer (#44978)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44978

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643059

fbshipit-source-id: 0eb36537fd3a8c69f4861fac14b99755eff97f04
2024-06-16 10:30:39 -07:00
Tim Yung c5acff86bd RN: Migrate LogBoxInspectorFooter-test.js from Shallow Renderer (#44968)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44968

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643066

fbshipit-source-id: 216a036ef8e5cfe9b362c2f367da052ee6c9808b
2024-06-16 10:30:39 -07:00
Tim Yung ba2e4a57e8 RN: Migrate LogBoxInspectorCodeFrame-test.js from Shallow Renderer (#44979)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44979

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643061

fbshipit-source-id: 0c68324d4d92fc8818ac469737eda3679aa773b3
2024-06-16 10:30:39 -07:00
Tim Yung 7dd4811bea RN: Migrate LogBoxInspector-test.js from Shallow Renderer (#44974)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44974

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58641098

fbshipit-source-id: be7592b3fb5c4a66879ad734439faceb4ad5cdde
2024-06-16 10:30:39 -07:00
Tim Yung e05cbd9912 RN: Migrate LogBoxButton-test.js from Shallow Renderer (#44987)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44987

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58641097

fbshipit-source-id: a9d3abee19d58262d36ac250a55780df803c464b
2024-06-16 10:30:39 -07:00
Tim Yung 9eee99fd8c RN: Migrate LogBoxInspectorMessageHeader-test.js from Shallow Renderer (#44967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44967

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58641096

fbshipit-source-id: e9752f21763156ee409ae81a304cada84a346bdb
2024-06-16 10:30:39 -07:00
Tim Yung 00253a2efe RN: Migrate LogBoxInspectorContainer-test.js from Shallow Renderer (#44985)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44985

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58641095

fbshipit-source-id: 90563955876a148a2b867e0ec5128bdd8786f274
2024-06-16 10:30:39 -07:00
Tim Yung 64e6721b23 Do not passthrough logbox errors that already have a component stack (#44888)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44888

In https://github.com/facebook/react/pull/29839 we removed the `Warning: ` prefix. This PR replaces the special cases in LogBox for `Warning: ` to use the presence of a component stack instead. This is what LogBox really cares about anyway, since the reason to let errors pass through to the exception manager is to let DevTools add the component stacks.

Changelog: [General] [Fixed] - Fix logbox reporting for React errors

Reviewed By: rickhanlonii

Differential Revision: D58441017

fbshipit-source-id: 5355cd04ddcd5238dadbfcbd64fe1f43c8cd04dc
2024-06-15 19:24:03 -07:00
Ramanpreet Nara 2f8d4f0c25 Ensure redbox shows up after reloads fail (#44959)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44959

If a react instance create fails, ReactHost [calls handleHostException](https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=784-793%2C956-959%2C966%2C979-980%2C982%2C985-986). This method uses the dev support manager to show the redbox: line 789.

https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=784-793

But, if react instance reload fails, react host does everything in handleHostException, **except** call into dev support manager to show the redbox.

https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=457-466

Hence, the redbox doesn't show.

## Thoughts
These two code-paths do really similar things. I'm thinking about how to unify them.

Changelog: [Android][Fixed] Show RedBox after reloads fail (bridgeless)

Reviewed By: alanleedev

Differential Revision: D58592928

fbshipit-source-id: 37a7adc1845a8b28917fcd9acbaae1484478e4e6
2024-06-14 16:33:55 -07:00
Ramanpreet Nara ce2e4263bd Make soft exceptions easier to spot in logcat (#44958)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44958

Now, all soft exception methods will have raiseSoftException(...)

## Before

```
BridgelessReact: ReactHost{0}.getOrCreateDestroyTask(): handleHostException(message = "Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'RNTesterBundle.js' is packaged correctly for release.")
```

## After
```
BridgelessReact: ReactHost{0}.raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'RNTesterBundle.js' is packaged correctly for release.")
```

Changelog: [Internal]

Reviewed By: alanleedev

Differential Revision: D58593609

fbshipit-source-id: 171a872cd41e4ffe9c2e9654c563a6f3af342ad9
2024-06-14 16:32:34 -07:00
alicata 457d14bd1b Fix onprogress not firing when Content-Length is not available for XMLHttpRequest (#44899)
Summary:
When an XMLHttpRequest is performed, the `onprogress` event it is not invoked when the `Content-Length` header is missing in the response. This is the case when we are calling an endpoint that responds with `transfer-encoding: chunked` (https://tools.ietf.org/html/rfc9112#section-7.1), preventing the user to keep track of the progress while the server is sending chunks. Despite we will never know the total length of the content (because it will not be known due to the RFC specification, so it will be always `-1`), we will now be able to keep track of the loaded data.

Note that in Android, this is the current default behaviour.

To address this issue:
- I removed the condition where the `downloadProgressBlock` was dispatched only when  `response.expectedContentLength` was greater than 0
- I created a new test case for `XMLHttpRequest` in the tester app to download a chunked file

## Changelog:

[IOS] [CHANGED] - fire `onprogress` event for `XMLHttpRequest` even when the `Content-Length` header is missing in the response headers

Pull Request resolved: https://github.com/facebook/react-native/pull/44899

Test Plan:
|before|after|
|----------|:-------------:|
|https://github.com/facebook/react-native/assets/37150312/6da3518f-eed3-4808-a2f8-abe26e5c7487|https://github.com/facebook/react-native/assets/37150312/ed1da300-dcf7-4874-a941-a2289f1cb777

Reviewed By: cortinico

Differential Revision: D58562088

Pulled By: NickGerleman

fbshipit-source-id: 23a1cafa49ddcd25fa0db7d04fae845126771425
2024-06-14 13:58:14 -07:00
zhongwuzw 9d637e4622 Fixes NSDataBigString length calculation (#44900)
Summary:
We assume data[length] is '\0', like Android https://github.com/facebook/react-native/blob/33aa83a0e6f63d3d50d4803074ad9e2243439100/packages/react-native/ReactCommon/cxxreact/JSBigString.h#L81. So we should minus 1 after we called `ensureNullTerminated`. it may crash in hermes engine because hermes should ensure data[length] is `\0`.

## Changelog:

[IOS] [FIXED] - Fixes NSDataBigString length calculation

Pull Request resolved: https://github.com/facebook/react-native/pull/44900

Test Plan:
We can mimic the crash by changes some code :
![image](https://github.com/facebook/react-native/assets/5061845/cc65f232-c37c-452c-bf0d-aeb71b7b2950)

Reviewed By: javache

Differential Revision: D58561775

Pulled By: NickGerleman

fbshipit-source-id: 0f7879a028b84379f4f00c65bcfc6b1a7d66814a
2024-06-14 13:55:58 -07:00
Nicola Corti 2b640bec34 Fix for broken test_helloworld_android on Release (#44952)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44952

The test_helloworld_android Release variant are broken on GHA.
This fixes it as it forces hermesc to be built *before* the app attempts to create a bundle.

Changelog:
[Internal] [Changed] - Fix for broken test_helloworld_android on Release

Reviewed By: cipolleschi, blakef

Differential Revision: D58591480

fbshipit-source-id: 2afc1cfe8c416da6f5919d20098639653798dd1a
2024-06-14 11:11:20 -07:00
Ruslan Lesiutin 09bdbace95 refactor[LogBox]: filter out ANSI color styles (#44924)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44924

# Changelog: [Internal]

For Strict Mode, RDT backend will apply ANSI escape codes to style the message, basically to dim it for 2-nd invocations of logs / warnings / errors in Strict Mode.

With these changes, LogBox will filter out these stylings, so that the message is displayed correctly in the LogBox bubble and in LogBox panel (full screen mode).

Reviewed By: rickhanlonii, yungsters

Differential Revision: D58477316

fbshipit-source-id: 17773f658d2a3bfa7f6a3ccec9fc88a97dd2c0af
2024-06-14 10:42:12 -07:00