|
103 | 103 | * |
104 | 104 | * Whenever the control flow creates a new task queue, it will automatically |
105 | 105 | * begin executing tasks in the next available turn of the event loop. This |
106 | | - * execution is scheduled using a "micro-task" timer, such as a (native) |
107 | | - * `ManagedPromise.then()` callback. |
| 106 | + * execution is [scheduled as a microtask][MicrotasksArticle] like e.g. a |
| 107 | + * (native) `Promise.then()` callback. |
108 | 108 | * |
109 | 109 | * setTimeout(() => console.log('a')); |
110 | | - * ManagedPromise.resolve().then(() => console.log('b')); // A native promise. |
| 110 | + * Promise.resolve().then(() => console.log('b')); // A native promise. |
111 | 111 | * flow.execute(() => console.log('c')); |
112 | | - * ManagedPromise.resolve().then(() => console.log('d')); |
| 112 | + * Promise.resolve().then(() => console.log('d')); |
113 | 113 | * setTimeout(() => console.log('fin')); |
114 | 114 | * // b |
115 | 115 | * // c |
|
118 | 118 | * // fin |
119 | 119 | * |
120 | 120 | * In the example above, b/c/d is logged before a/fin because native promises |
121 | | - * and this module use "micro-task" timers, which have a higher priority than |
122 | | - * "macro-tasks" like `setTimeout`. |
| 121 | + * and this module use "microtask" timers, which have a higher priority than |
| 122 | + * "macrotasks" like `setTimeout`. |
123 | 123 | * |
124 | 124 | * ## Task Execution |
125 | 125 | * |
126 | 126 | * Upon creating a task queue, and whenever an exisiting queue completes a task, |
127 | | - * the control flow will schedule a micro-task timer to process any scheduled |
| 127 | + * the control flow will schedule a microtask timer to process any scheduled |
128 | 128 | * tasks. This ensures no task is ever started within the same turn of the |
129 | 129 | * JavaScript event loop in which it was scheduled, nor is a task ever started |
130 | 130 | * within the same turn that another finishes. |
|
161 | 161 | * ## ManagedPromise Integration |
162 | 162 | * |
163 | 163 | * In addition to the {@link ControlFlow} class, the promise module also exports |
164 | | - * a [ManagedPromise/A+] {@linkplain ManagedPromise implementation} that is deeply |
| 164 | + * a [Promise/A+] {@linkplain ManagedPromise implementation} that is deeply |
165 | 165 | * integrated with the ControlFlow. First and foremost, each promise |
166 | 166 | * {@linkplain ManagedPromise#then() callback} is scheduled with the |
167 | 167 | * control flow as a task. As a result, each callback is invoked in its own turn |
|
467 | 467 | * |
468 | 468 | * ES6 promises do not require users to handle a promise rejections. This can |
469 | 469 | * result in subtle bugs as the rejections are silently "swallowed" by the |
470 | | - * ManagedPromise class. |
| 470 | + * Promise class. |
471 | 471 | * |
472 | | - * ManagedPromise.reject(Error('boom')); |
| 472 | + * Promise.reject(Error('boom')); |
473 | 473 | * // ... *crickets* ... |
474 | 474 | * |
475 | 475 | * Selenium's promise module, on the other hand, requires that every rejection |
476 | 476 | * be explicitly handled. When a {@linkplain ManagedPromise ManagedPromise} is |
477 | 477 | * rejected and no callbacks are defined on that promise, it is considered an |
478 | | - * _unhandled rejection_ and reproted to the active task queue. If the rejection |
| 478 | + * _unhandled rejection_ and reported to the active task queue. If the rejection |
479 | 479 | * remains unhandled after a single turn of the [event loop][JSEL] (scheduled |
480 | | - * with a micro-task), it will propagate up the stack. |
| 480 | + * with a microtask), it will propagate up the stack. |
481 | 481 | * |
482 | 482 | * ## Error Propagation |
483 | 483 | * |
|
582 | 582 | * |
583 | 583 | * Bottom line: you __*must*__ handle rejected promises. |
584 | 584 | * |
585 | | - * # ManagedPromise/A+ Compatibility |
| 585 | + * # Promise/A+ Compatibility |
586 | 586 | * |
587 | | - * This `promise` module is compliant with the [ManagedPromise/A+][] specification |
| 587 | + * This `promise` module is compliant with the [Promise/A+] specification |
588 | 588 | * except for sections `2.2.6.1` and `2.2.6.2`: |
589 | 589 | * |
590 | 590 | * > |
|
598 | 598 | * Specifically, the conformance tests contains the following scenario (for |
599 | 599 | * brevity, only the fulfillment version is shown): |
600 | 600 | * |
601 | | - * var p1 = ManagedPromise.resolve(); |
| 601 | + * var p1 = Promise.resolve(); |
602 | 602 | * p1.then(function() { |
603 | 603 | * console.log('A'); |
604 | 604 | * p1.then(() => console.log('B')); |
|
623 | 623 | * |
624 | 624 | * [JSEL]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop |
625 | 625 | * [GF]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function* |
626 | | - * [ManagedPromise/A+]: https://promisesaplus.com/ |
| 626 | + * [Promise/A+]: https://promisesaplus.com/ |
| 627 | + * [MicrotasksArticle]: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/ |
627 | 628 | */ |
628 | 629 |
|
629 | 630 | 'use strict'; |
@@ -667,7 +668,7 @@ function getUid(obj) { |
667 | 668 |
|
668 | 669 |
|
669 | 670 | /** |
670 | | - * Runs the given function after a micro-task yield. |
| 671 | + * Runs the given function after a microtask yield. |
671 | 672 | * @param {function()} fn The function to run. |
672 | 673 | */ |
673 | 674 | function asyncRun(fn) { |
@@ -2622,7 +2623,7 @@ class MicroTask { |
2622 | 2623 | } |
2623 | 2624 |
|
2624 | 2625 | /** |
2625 | | - * Runs the given function after a micro-task yield. |
| 2626 | + * Runs the given function after a microtask yield. |
2626 | 2627 | * @param {function()} fn The function to run. |
2627 | 2628 | */ |
2628 | 2629 | static run(fn) { |
|
0 commit comments