| <!doctype html> |
| <title>Scheduling API: Move Delayed Tasks</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'; |
| |
| let taskCount = 0; |
| let taskToMove; |
| |
| async_test(t => { |
| let now = performance.now(); |
| |
| let tc = new TaskController('background'); |
| |
| scheduler.postTask(t.step_func(() => { |
| assert_equals(++taskCount, 1); |
| tc.setPriority('user-blocking'); |
| }), { priority: 'user-blocking', delay: 10 }); |
| |
| scheduler.postTask(t.step_func_done(() => { |
| assert_equals(++taskCount, 2); |
| |
| let elapsed = performance.now() - now; |
| assert_greater_than_equal(elapsed, 20); |
| }), { signal: tc.signal, delay: 20 }); |
| |
| }, "Tests delay when changing a delayed task's priority"); |
| |
| </script> |