| <!doctype html> |
| <title>Scheduling API: Global Task Queues</title> |
| <link rel="author" title="Scott Haseley" href="mailto:shaseley@chromium.org"> |
| <link rel="help" href="https://github.com/WICG/main-thread-scheduling"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| |
| <script> |
| 'use strict'; |
| |
| async_test(t => { |
| function* priorityGenerator() { |
| let priorities = [ |
| "user-blocking", "user-visible", "background" |
| ]; |
| for (let i = 0; i < priorities.length; i++) |
| yield priorities[i]; |
| } |
| |
| function testPriority(priority) { |
| let task = scheduler.postTask(t.step_func(() => { |
| nextTaskQueue(); |
| }), { priority: priority }); |
| } |
| |
| let nextPriority = priorityGenerator(); |
| |
| function nextTaskQueue() { |
| let next = nextPriority.next(); |
| if (next.done) { |
| t.done(); |
| return; |
| } |
| testPriority(next.value); |
| } |
| |
| // Schedule a task to kick things off. |
| scheduler.postTask(t.step_func(() => { |
| nextTaskQueue(); |
| })); |
| }, 'Basic functionality for scheduler.postTask() without using a task signal'); |
| |
| </script> |