you see the same above and below afterwards it's correct.
+
-------------------------------------------------
+
Actual:
+
+
@@ -98,7 +113,10 @@
Tests:
const {
unstable_scheduleCallback: scheduleCallback,
unstable_cancelCallback: cancelCallback,
- unstable_now: now
+ unstable_now: now,
+ unstable_getFirstCallbackNode: getFirstCallbackNode,
+ unstable_pauseExecution: pauseExecution,
+ unstable_continueExecution: continueExecution,
} = Scheduler;
function displayTestResult(testNumber) {
const expectationNode = document.getElementById('test-' + testNumber + '-expected');
@@ -215,6 +233,16 @@
Tests:
[
// ... TODO
],
+ [],
+ [],
+ // Test 8
+ [
+ 'Queue size: 0.',
+ 'Pausing... press continue to resume.',
+ 'Queue size: 2.',
+ 'Finishing...',
+ 'Done!',
+ ],
];
function runTestOne() {
// Test 1
@@ -496,6 +524,51 @@
Tests:
}
scheduleCallback(incrementCounterAndScheduleNextCallback);
}
+
+function runTestEight() {
+ // Test 8
+ // Pauses execution, dumps the queue, and continues execution
+ clearTestResult(8);
+
+ function countNodesInStack(firstCallbackNode) {
+ var node = firstCallbackNode;
+ var count = 0;
+ if (node !== null) {
+ do {
+ count = count + 1;
+ node = node.next;
+ } while (node !== firstCallbackNode);
+ }
+ return count;
+ }
+
+ scheduleCallback(() => {
+
+ // size should be 0
+ updateTestResult(8, `Queue size: ${countNodesInStack(getFirstCallbackNode())}.`);
+ updateTestResult(8, 'Pausing... press continue to resume.');
+ pauseExecution();
+
+ scheduleCallback(function () {
+ updateTestResult(8, 'Finishing...');
+ displayTestResult(8);
+ })
+ scheduleCallback(function () {
+ updateTestResult(8, 'Done!');
+ displayTestResult(8);
+ checkTestResult(8);
+ })
+
+ // new size should be 2 now
+ updateTestResult(8, `Queue size: ${countNodesInStack(getFirstCallbackNode())}.`);
+ displayTestResult(8);
+ });
+}
+
+function continueTestEight() {
+ continueExecution();
+}
+