How to use isAlreadyFailedLegacyErrorBoundary method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

ReactFiberUnwindWork.js

Source: ReactFiberUnwindWork.js Github

copy
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 */
8
9import {createCapturedValue} from './ReactCapturedValue';
10import {ensureUpdateQueues} from './ReactFiberUpdateQueue';
11
12import {
13  ClassComponent,
14  HostRoot,
15  HostComponent,
16  HostPortal,
17  ContextProvider,
18} from 'shared/ReactTypeOfWork';
19import {
20  NoEffect,
21  DidCapture,
22  Incomplete,
23  ShouldCapture,
24} from 'shared/ReactTypeOfSideEffect';
25
26import {enableGetDerivedStateFromCatch} from 'shared/ReactFeatureFlags';
27
28import {
29  popContextProvider as popLegacyContextProvider,
30  popTopLevelContextObject as popTopLevelLegacyContextObject,
31} from './ReactFiberContext';
32import {popProvider} from './ReactFiberNewContext';
33
34export default function(
35  hostContext: HostContext<C, CX>,
36  scheduleWork: (
37    fiber: Fiber,
38    startTime: ExpirationTime,
39    expirationTime: ExpirationTime,
40  ) => void,
41  isAlreadyFailedLegacyErrorBoundary: (instance: mixed) => boolean,
42) {
43  const {popHostContainer, popHostContext} = hostContext;
44
45  function throwException(
46    returnFiber: Fiber,
47    sourceFiber: Fiber,
48    rawValue: mixed,
49  ) {
50    // The source fiber did not complete.
51    sourceFiber.effectTag |= Incomplete;
52    // Its effect list is no longer valid.
53    sourceFiber.firstEffect = sourceFiber.lastEffect = null;
54
55    const value = createCapturedValue(rawValue, sourceFiber);
56
57    let workInProgress = returnFiber;
58    do {
59      switch (workInProgress.tag) {
60        case HostRoot: {
61          // Uncaught error
62          const errorInfo = value;
63          ensureUpdateQueues(workInProgress);
64          const updateQueue: UpdateQueue = (workInProgress.updateQueue: any);
65          updateQueue.capturedValues = [errorInfo];
66          workInProgress.effectTag |= ShouldCapture;
67          return;
68        }
69        case ClassComponent:
70          // Capture and retry
71          const ctor = workInProgress.type;
72          const instance = workInProgress.stateNode;
73          if (
74            (workInProgress.effectTag & DidCapture) === NoEffect &&
75            ((typeof ctor.getDerivedStateFromCatch === 'function' &&
76              enableGetDerivedStateFromCatch) ||
77              (instance !== null &&
78                typeof instance.componentDidCatch === 'function' &&
79                !isAlreadyFailedLegacyErrorBoundary(instance)))
80          ) {
81            ensureUpdateQueues(workInProgress);
82            const updateQueue: UpdateQueue = (workInProgress.updateQueue: any);
83            const capturedValues = updateQueue.capturedValues;
84            if (capturedValues === null) {
85              updateQueue.capturedValues = [value];
86            } else {
87              capturedValues.push(value);
88            }
89            workInProgress.effectTag |= ShouldCapture;
90            return;
91          }
92          break;
93        default:
94          break;
95      }
96      workInProgress = workInProgress.return;
97    } while (workInProgress !== null);
98  }
99
100  function unwindWork(workInProgress) {
101    switch (workInProgress.tag) {
102      case ClassComponent: {
103        popLegacyContextProvider(workInProgress);
104        const effectTag = workInProgress.effectTag;
105        if (effectTag & ShouldCapture) {
106          workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture;
107          return workInProgress;
108        }
109        return null;
110      }
111      case HostRoot: {
112        popHostContainer(workInProgress);
113        popTopLevelLegacyContextObject(workInProgress);
114        const effectTag = workInProgress.effectTag;
115        if (effectTag & ShouldCapture) {
116          workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture;
117          return workInProgress;
118        }
119        return null;
120      }
121      case HostComponent: {
122        popHostContext(workInProgress);
123        return null;
124      }
125      case HostPortal:
126        popHostContainer(workInProgress);
127        return null;
128      case ContextProvider:
129        popProvider(workInProgress);
130        return null;
131      default:
132        return null;
133    }
134  }
135  return {
136    throwException,
137    unwindWork,
138  };
139}
140
Full Screen

ReactFiberScheduler.js

Source: ReactFiberScheduler.js Github

copy
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10import {enableNewScheduler} from 'shared/ReactFeatureFlags';
11
12import {
13  requestCurrentTime as requestCurrentTime_old,
14  computeExpirationForFiber as computeExpirationForFiber_old,
15  captureCommitPhaseError as captureCommitPhaseError_old,
16  onUncaughtError as onUncaughtError_old,
17  renderDidSuspend as renderDidSuspend_old,
18  renderDidError as renderDidError_old,
19  pingSuspendedRoot as pingSuspendedRoot_old,
20  retryTimedOutBoundary as retryTimedOutBoundary_old,
21  resolveRetryThenable as resolveRetryThenable_old,
22  markLegacyErrorBoundaryAsFailed as markLegacyErrorBoundaryAsFailed_old,
23  isAlreadyFailedLegacyErrorBoundary as isAlreadyFailedLegacyErrorBoundary_old,
24  scheduleWork as scheduleWork_old,
25  flushRoot as flushRoot_old,
26  batchedUpdates as batchedUpdates_old,
27  unbatchedUpdates as unbatchedUpdates_old,
28  flushSync as flushSync_old,
29  flushControlled as flushControlled_old,
30  deferredUpdates as deferredUpdates_old,
31  syncUpdates as syncUpdates_old,
32  interactiveUpdates as interactiveUpdates_old,
33  flushInteractiveUpdates as flushInteractiveUpdates_old,
34  computeUniqueAsyncExpiration as computeUniqueAsyncExpiration_old,
35  flushPassiveEffects as flushPassiveEffects_old,
36  warnIfNotCurrentlyActingUpdatesInDev as warnIfNotCurrentlyActingUpdatesInDev_old,
37  inferStartTimeFromExpirationTime as inferStartTimeFromExpirationTime_old,
38} from './ReactFiberScheduler.old';
39
40import {
41  requestCurrentTime as requestCurrentTime_new,
42  computeExpirationForFiber as computeExpirationForFiber_new,
43  captureCommitPhaseError as captureCommitPhaseError_new,
44  onUncaughtError as onUncaughtError_new,
45  renderDidSuspend as renderDidSuspend_new,
46  renderDidError as renderDidError_new,
47  pingSuspendedRoot as pingSuspendedRoot_new,
48  retryTimedOutBoundary as retryTimedOutBoundary_new,
49  resolveRetryThenable as resolveRetryThenable_new,
50  markLegacyErrorBoundaryAsFailed as markLegacyErrorBoundaryAsFailed_new,
51  isAlreadyFailedLegacyErrorBoundary as isAlreadyFailedLegacyErrorBoundary_new,
52  scheduleWork as scheduleWork_new,
53  flushRoot as flushRoot_new,
54  batchedUpdates as batchedUpdates_new,
55  unbatchedUpdates as unbatchedUpdates_new,
56  flushSync as flushSync_new,
57  flushControlled as flushControlled_new,
58  deferredUpdates as deferredUpdates_new,
59  syncUpdates as syncUpdates_new,
60  interactiveUpdates as interactiveUpdates_new,
61  flushInteractiveUpdates as flushInteractiveUpdates_new,
62  computeUniqueAsyncExpiration as computeUniqueAsyncExpiration_new,
63  flushPassiveEffects as flushPassiveEffects_new,
64  warnIfNotCurrentlyActingUpdatesInDev as warnIfNotCurrentlyActingUpdatesInDev_new,
65  inferStartTimeFromExpirationTime as inferStartTimeFromExpirationTime_new,
66} from './ReactFiberScheduler.new';
67
68// enableNewScheduler 都为 false,所以我们只看 old 的代码
69export const requestCurrentTime = enableNewScheduler
70  ? requestCurrentTime_new
71  : requestCurrentTime_old;
72export const computeExpirationForFiber = enableNewScheduler
73  ? computeExpirationForFiber_new
74  : computeExpirationForFiber_old;
75export const captureCommitPhaseError = enableNewScheduler
76  ? captureCommitPhaseError_new
77  : captureCommitPhaseError_old;
78export const onUncaughtError = enableNewScheduler
79  ? onUncaughtError_new
80  : onUncaughtError_old;
81export const renderDidSuspend = enableNewScheduler
82  ? renderDidSuspend_new
83  : renderDidSuspend_old;
84export const renderDidError = enableNewScheduler
85  ? renderDidError_new
86  : renderDidError_old;
87export const pingSuspendedRoot = enableNewScheduler
88  ? pingSuspendedRoot_new
89  : pingSuspendedRoot_old;
90export const retryTimedOutBoundary = enableNewScheduler
91  ? retryTimedOutBoundary_new
92  : retryTimedOutBoundary_old;
93export const resolveRetryThenable = enableNewScheduler
94  ? resolveRetryThenable_new
95  : resolveRetryThenable_old;
96export const markLegacyErrorBoundaryAsFailed = enableNewScheduler
97  ? markLegacyErrorBoundaryAsFailed_new
98  : markLegacyErrorBoundaryAsFailed_old;
99export const isAlreadyFailedLegacyErrorBoundary = enableNewScheduler
100  ? isAlreadyFailedLegacyErrorBoundary_new
101  : isAlreadyFailedLegacyErrorBoundary_old;
102export const scheduleWork = enableNewScheduler
103  ? scheduleWork_new
104  : scheduleWork_old;
105export const flushRoot = enableNewScheduler ? flushRoot_new : flushRoot_old;
106export const batchedUpdates = enableNewScheduler
107  ? batchedUpdates_new
108  : batchedUpdates_old;
109export const unbatchedUpdates = enableNewScheduler
110  ? unbatchedUpdates_new
111  : unbatchedUpdates_old;
112export const flushSync = enableNewScheduler ? flushSync_new : flushSync_old;
113export const flushControlled = enableNewScheduler
114  ? flushControlled_new
115  : flushControlled_old;
116export const deferredUpdates = enableNewScheduler
117  ? deferredUpdates_new
118  : deferredUpdates_old;
119export const syncUpdates = enableNewScheduler
120  ? syncUpdates_new
121  : syncUpdates_old;
122export const interactiveUpdates = enableNewScheduler
123  ? interactiveUpdates_new
124  : interactiveUpdates_old;
125export const flushInteractiveUpdates = enableNewScheduler
126  ? flushInteractiveUpdates_new
127  : flushInteractiveUpdates_old;
128export const computeUniqueAsyncExpiration = enableNewScheduler
129  ? computeUniqueAsyncExpiration_new
130  : computeUniqueAsyncExpiration_old;
131export const flushPassiveEffects = enableNewScheduler
132  ? flushPassiveEffects_new
133  : flushPassiveEffects_old;
134export const warnIfNotCurrentlyActingUpdatesInDev = enableNewScheduler
135  ? warnIfNotCurrentlyActingUpdatesInDev_new
136  : warnIfNotCurrentlyActingUpdatesInDev_old;
137export const inferStartTimeFromExpirationTime = enableNewScheduler
138  ? inferStartTimeFromExpirationTime_new
139  : inferStartTimeFromExpirationTime_old;
140
141export type Thenable = {
142  then(resolve: () => mixed, reject?: () => mixed): void | Thenable,
143};
144
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)