OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright 2013 Google Inc. All Rights Reserved. |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 --> |
| 16 |
| 17 <!DOCTYPE html><meta charset="UTF-8"> |
| 18 <body></body> |
| 19 <script src="../bootstrap.js" nochecks></script> |
| 20 <script> |
| 21 "use strict"; |
| 22 |
| 23 var body = document.querySelector("body"); |
| 24 |
| 25 test(function() { |
| 26 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 27 var player = document.timeline.play(anAnimation); |
| 28 assert_false(player._needsHandlerPass); |
| 29 anAnimation.onstart = function() { }; |
| 30 assert_true(player._needsHandlerPass); |
| 31 anAnimation.onstart = undefined; |
| 32 assert_false(player._needsHandlerPass); |
| 33 }, 'player sees handler changes after play called'); |
| 34 |
| 35 test(function() { |
| 36 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 37 anAnimation.onend = function() { }; |
| 38 var player = document.timeline.play(anAnimation); |
| 39 assert_true(player._needsHandlerPass); |
| 40 anAnimation.onend = null; |
| 41 assert_false(player._needsHandlerPass); |
| 42 var player = document.timeline.play(anAnimation); |
| 43 assert_false(player._needsHandlerPass); |
| 44 }, 'player gets appropriate handler state for changes before play is called'); |
| 45 |
| 46 test(function() { |
| 47 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 48 anAnimation.oniteration = function() { }; |
| 49 var player = document.timeline.play(anAnimation); |
| 50 assert_true(player._needsHandlerPass); |
| 51 anAnimation.oncancel = function() { }; |
| 52 assert_true(player._needsHandlerPass); |
| 53 anAnimation.oniteration = null; |
| 54 assert_true(player._needsHandlerPass); |
| 55 anAnimation.oncancel = undefined; |
| 56 assert_false(player._needsHandlerPass); |
| 57 }, 'player needs a handler pass while at least one handler exists in the tree'); |
| 58 |
| 59 test(function() { |
| 60 |
| 61 var aTree = new ParGroup([ |
| 62 new SeqGroup([ |
| 63 new Animation(body, {left: '100px'}, 1), |
| 64 new Animation(body, {left: '100px'}, 1) |
| 65 ]), |
| 66 new Animation(body, {left: '100px'}, 1) |
| 67 ]); |
| 68 aTree.children[1].onend = function() { }; |
| 69 var player = document.timeline.play(aTree); |
| 70 assert_true(player._needsHandlerPass); |
| 71 aTree.children[1].onend = undefined; |
| 72 assert_false(player._needsHandlerPass); |
| 73 aTree.children[0].children[0].onstart = function() { }; |
| 74 assert_true(player._needsHandlerPass); |
| 75 aTree.children[0].children[1].oncancel = function() { }; |
| 76 assert_true(player._needsHandlerPass); |
| 77 aTree.children[0].children[0].onstart = null; |
| 78 assert_true(player._needsHandlerPass); |
| 79 aTree.children[0].children[1].oncancel = undefined; |
| 80 assert_false(player._needsHandlerPass); |
| 81 aTree.oniteration = function() { }; |
| 82 assert_true(player._needsHandlerPass); |
| 83 aTree.oniteration = null; |
| 84 assert_false(player._needsHandlerPass); |
| 85 }, 'needsHandlerPass correctly calculated for non-trivial trees'); |
| 86 |
| 87 test(function() { |
| 88 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 89 anAnimation.onstart = function() { }; |
| 90 var aGroup = new ParGroup([anAnimation]); |
| 91 var player = document.timeline.play(aGroup); |
| 92 assert_true(player._needsHandlerPass); |
| 93 }, 'needsHandlerPass correctly passed from child to parent on construction'); |
| 94 |
| 95 test(function() { |
| 96 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 97 anAnimation.onstart = function() { }; |
| 98 var aGroup = new ParGroup([]); |
| 99 aGroup.append(anAnimation); |
| 100 var player = document.timeline.play(aGroup); |
| 101 assert_true(player._needsHandlerPass); |
| 102 }, 'needsHandlerPass correctly passed from child to parent on addition'); |
| 103 |
| 104 test(function() { |
| 105 var anAnimation = new Animation(body, {left: '100px'}, 1); |
| 106 anAnimation.onstart = function() { }; |
| 107 var aGroup = new ParGroup([]); |
| 108 var player = document.timeline.play(aGroup); |
| 109 aGroup.append(anAnimation); |
| 110 assert_true(player._needsHandlerPass); |
| 111 }, 'needsHandlerPass correctly passed from child to parent on ' + |
| 112 'addition after player creation'); |
| 113 </script> |
OLD | NEW |