@samitouri / QOS-React / commits / a27e4f3361

[Fiber] Make requestIdleCallback() and requestAnimationFrame() shims async (#8591)

* Add a failing test for recursion check * Make requestIdleCallback() and requestAnimationFrame() shims async They no longer need to be sync in tests because we already made DOM renderer sync by default. This fixes a crash when testing incrementalness in DOM renderer itself. * Style fix * Fix lint

Dan Abramov committed Dec 21, 2016 at 14:04 UTC a27e4f3361caf6461ef51a71855903578604ace0
3 files changed +15 -3
scripts/fiber/tests-passing.txt
+1
@@ -541,6 +541,7 @@ src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
541 * findDOMNode should find dom element after expanding a fragment
542 * should bubble events from the portal to the parent
543 * should not onMouseLeave when staying in the portal
544 +* should not crash encountering low-priority tree
545
546 src/renderers/dom/shared/__tests__/CSSProperty-test.js
547 * should generate browser prefixes for its `isUnitlessNumber`
scripts/jest/environment.js
+5 -3
@@ -1,11 +1,13 @@
1 /* eslint-disable */
2 global.__DEV__ = true;
3
4 -// For testing DOM Fiber, we synchronously invoke all the scheduling.
4 +// For testing DOM Fiber.
5 global.requestAnimationFrame = function(callback) {
6 - callback();
6 + setTimeout(callback);
7 };
8
9 global.requestIdleCallback = function(callback) {
10 - callback({ timeRemaining() { return Infinity; } });
10 + setTimeout(() => {
11 + callback({ timeRemaining() { return Infinity; } });
12 + });
13 };
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
+9
@@ -993,5 +993,14 @@ describe('ReactDOMFiber', () => {
993 'leave parent', // Only when we leave the portal does onMouseLeave fire.
994 ]);
995 });
996 +
997 + it('should not crash encountering low-priority tree', () => {
998 + ReactDOM.render(
999 + <div hidden={true}>
1000 + <div />
1001 + </div>,
1002 + container
1003 + );
1004 + });
1005 }
1006 });