How to use markRootFinishedAtTime 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.

ReactFiberRoot.js

Source: ReactFiberRoot.js Github

copy
1import { NoWork } from './ReactFiberExpirationTime.js'
2
3export function FiberRootNode(containerInfo, tag) {
4  this.tag = tag
5  this.current = null
6  this.containerInfo = containerInfo
7  this.pendingChildren = null
8  this.pingCache = null
9  this.finishedExpirationTime = NoWork
10  this.finishedWork = null
11  this.context = null
12  this.pendingContext = null
13  this.callbackNode = null
14
15  this.firstPendingTime = NoWork
16
17  this.lastPingedTime = NoWork
18  this.lastExpiredTime = NoWork
19}
20
21export function markRootFinishedAtTime(
22  root,
23  finishedExpirationTime,
24  remainingExpirationTime
25) {
26  // Update the range of pending times
27  root.firstPendingTime = remainingExpirationTime
28}
29
30export function markRootUpdatedAtTime(root, expirationTime) {
31  // Update the range of pending times
32  const firstPendingTime = root.firstPendingTime
33  if (expirationTime > firstPendingTime) {
34    root.firstPendingTime = expirationTime
35  }
36}
37
Full Screen

finishSyncRender.js

Source: finishSyncRender.js Github

copy
1function commitRootImpl(root, renderPriorityLevel) {
2    do {
3        flushPassiveEffects();
4    } while (rootWithPendingPassiveEffects !== null);
5    flushRenderPhaseStrictModeWarningsInDEV();
6
7    const finishedWork = root.finishedWork;
8    const expirationTime = root.finishedExpirationTime;
9    if (finishedWork === null) {
10        return null;
11    }
12    root.finishedWork = null;
13    root.finishedExpirationTime = NoWork;
14
15    root.callbackNode = null;
16    root.callbackExpirationTime = NoWork;
17    root.callbackPriority = NoPriority;
18    root.nextKnownPendingLevel = NoWork;
19
20    startCommitTimer();
21
22    const remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(
23        finishedWork,
24    );
25    markRootFinishedAtTime(
26        root,
27        expirationTime,
28        remainingExpirationTimeBeforeCommit,
29    );
30
31    if (root === workInProgressRoot) {
32        workInProgressRoot = null;
33        workInProgress = null;
34        renderExpirationTime = NoWork;
35    }
36
37    let firstEffect;
38    if (finishedWork.effectTag > PerformedWork) {
39        if (finishedWork.lastEffect !== null) {
40            finishedWork.lastEffect.nextEffect = finishedWork;
41            firstEffect = finishedWork.firstEffect;
42        } else {
43            firstEffect = finishedWork;
44        }
45    } else {
46        firstEffect = finishedWork.firstEffect;
47    }
48
49    if (firstEffect !== null) {
50        const prevExecutionContext = executionContext;
51        executionContext |= CommitContext;
52        const prevInteractions = pushInteractions(root);
53
54        ReactCurrentOwner.current = null;
55
56        startCommitSnapshotEffectsTimer();
57        prepareForCommit(root.containerInfo);
58        nextEffect = firstEffect;
59        do {
60            try {
61                commitBeforeMutationEffects();
62            } catch (error) {
63                invariant(nextEffect !== null, 'Should be working on an effect.');
64                captureCommitPhaseError(nextEffect, error);
65                nextEffect = nextEffect.nextEffect;
66            }
67        } while (nextEffect !== null);
68        stopCommitSnapshotEffectsTimer();
69
70        if (enableProfilerTimer) {
71            recordCommitTime();
72        }
73
74        startCommitHostEffectsTimer();
75        nextEffect = firstEffect;
76        do {
77            if (__DEV__) {
78                invokeGuardedCallback(
79                    null,
80                    commitMutationEffects,
81                    null,
82                    root,
83                    renderPriorityLevel,
84                );
85                if (hasCaughtError()) {
86                    invariant(nextEffect !== null, 'Should be working on an effect.');
87                    const error = clearCaughtError();
88                    captureCommitPhaseError(nextEffect, error);
89                    nextEffect = nextEffect.nextEffect;
90                }
91            } else {
92                try {
93                    commitMutationEffects(root, renderPriorityLevel);
94                } catch (error) {
95                    invariant(nextEffect !== null, 'Should be working on an effect.');
96                    captureCommitPhaseError(nextEffect, error);
97                    nextEffect = nextEffect.nextEffect;
98                }
99            }
100        } while (nextEffect !== null);
101        stopCommitHostEffectsTimer();
102        resetAfterCommit(root.containerInfo);
103
104        // The work-in-progress tree is now the current tree. This must come after
105        // the mutation phase, so that the previous tree is still current during
106        // componentWillUnmount, but before the layout phase, so that the finished
107        // work is current during componentDidMount/Update.
108        root.current = finishedWork;
109
110        // The next phase is the layout phase, where we call effects that read
111        // the host tree after it's been mutated. The idiomatic use case for this is
112        // layout, but class component lifecycles also fire here for legacy reasons.
113        startCommitLifeCyclesTimer();
114        nextEffect = firstEffect;
115        do {
116            if (__DEV__) {
117                invokeGuardedCallback(
118                    null,
119                    commitLayoutEffects,
120                    null,
121                    root,
122                    expirationTime,
123                );
124                if (hasCaughtError()) {
125                    invariant(nextEffect !== null, 'Should be working on an effect.');
126                    const error = clearCaughtError();
127                    captureCommitPhaseError(nextEffect, error);
128                    nextEffect = nextEffect.nextEffect;
129                }
130            } else {
131                try {
132                    commitLayoutEffects(root, expirationTime);
133                } catch (error) {
134                    invariant(nextEffect !== null, 'Should be working on an effect.');
135                    captureCommitPhaseError(nextEffect, error);
136                    nextEffect = nextEffect.nextEffect;
137                }
138            }
139        } while (nextEffect !== null);
140        stopCommitLifeCyclesTimer();
141
142        nextEffect = null;
143
144        // Tell Scheduler to yield at the end of the frame, so the browser has an
145        // opportunity to paint.
146        requestPaint();
147
148        if (enableSchedulerTracing) {
149            popInteractions(((prevInteractions: any): Set < Interaction > ));
150        }
151        executionContext = prevExecutionContext;
152    } else {
153        // No effects.
154        root.current = finishedWork;
155        // Measure these anyway so the flamegraph explicitly shows that there were
156        // no effects.
157        // TODO: Maybe there's a better way to report this.
158        startCommitSnapshotEffectsTimer();
159        stopCommitSnapshotEffectsTimer();
160        if (enableProfilerTimer) {
161            recordCommitTime();
162        }
163        startCommitHostEffectsTimer();
164        stopCommitHostEffectsTimer();
165        startCommitLifeCyclesTimer();
166        stopCommitLifeCyclesTimer();
167    }
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)