testing/web-platform/tests/html/webappapis/animation-frames/cancel-pending.html
author Brian Birtles <birtles@gmail.com>
Wed, 06 Mar 2019 10:34:30 +0000
changeset 464601 52a879d4e479200bddbe0bf3ee6b4c28e7d220de
parent 464267 e7d92d3120c423087b25c70bdcd4c3696ae078a5
permissions -rw-r--r--
Bug 1528894 [wpt PR 15455] - [html] Add test that cancelAnimationFrame cancels a pending animation frame callback, a=testonly Automatic update from web-platform-tests HTML: cancelAnimationFrame cancels a pending animation frame callback For https://github.com/whatwg/html/pull/4375. -- wpt-commits: bbbe615d3f5b7b44ed49b4b369f19d4c5dd32e53 wpt-pr: 15455

<!doctype html>
<title>cancelAnimationFrame cancels a pending animation frame callback</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#run-the-animation-frame-callbacks">
<div id="log"></div>
<script>
async_test(t => {
  let didCall = false;

  function callbackOne() {
    cancelAnimationFrame(twoHandle);
    requestAnimationFrame(t.step_func(() => {
      assert_false(didCall, 'Should NOT have called the second callback');
      t.done();
    }));
  }

  function callbackTwo() {
    didCall = true;
  }

  requestAnimationFrame(callbackOne);
  const twoHandle = requestAnimationFrame(callbackTwo);
}, 'cancelAnimationFrame cancels a pending animation frame callback');
</script>