OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
7 */ | 7 */ |
8 | 8 |
9 // See assert.js for where this is used. | 9 // See assert.js for where this is used. |
10 this.traceAssertionsForTesting = true; | 10 this.traceAssertionsForTesting = true; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 * @constructor | 46 * @constructor |
47 */ | 47 */ |
48 function Test() {}; | 48 function Test() {}; |
49 | 49 |
50 /** | 50 /** |
51 * Make all transitions and animations take 0ms. NOTE: this will completely | 51 * Make all transitions and animations take 0ms. NOTE: this will completely |
52 * disable webkitTransitionEnd events. If your code relies on them firing, it | 52 * disable webkitTransitionEnd events. If your code relies on them firing, it |
53 * will break. animationend events should still work. | 53 * will break. animationend events should still work. |
54 */ | 54 */ |
55 Test.disableAnimationsAndTransitions = function() { | 55 Test.disableAnimationsAndTransitions = function() { |
56 var noAnimationStyle = document.createElement('style'); | 56 let all = document.body.querySelectorAll('*, * /deep/ *'); |
57 noAnimationStyle.id = 'no-animation'; | 57 const ZERO_MS_IMPORTANT = '0ms !important'; |
58 noAnimationStyle.textContent = | 58 for (let i = 0, l = all.length; i < l; ++i) { |
59 '*, * /deep/ * {' + | 59 let style = all[i].style; |
60 ' -webkit-transition-duration: 0ms !important;' + | 60 style.animationDelay = ZERO_MS_IMPORTANT; |
61 ' -webkit-transition-delay: 0ms !important;' + | 61 style.animationDuration = ZERO_MS_IMPORTANT; |
62 ' animation-duration: 0ms !important;' + | 62 style.transitionDelay = ZERO_MS_IMPORTANT; |
63 ' animation-delay: 0ms !important;' + | 63 style.transitionDuration = ZERO_MS_IMPORTANT; |
64 '}'; | 64 } |
65 document.querySelector('head').appendChild(noAnimationStyle); | |
66 | 65 |
67 var realElementAnimate = Element.prototype.animate; | 66 var realElementAnimate = Element.prototype.animate; |
68 Element.prototype.animate = function(keyframes, opt_options) { | 67 Element.prototype.animate = function(keyframes, opt_options) { |
69 if (typeof opt_options == 'object') | 68 if (typeof opt_options == 'object') |
70 opt_options.duration = 0; | 69 opt_options.duration = 0; |
71 else | 70 else |
72 opt_options = 0; | 71 opt_options = 0; |
73 return realElementAnimate.call(this, keyframes, opt_options); | 72 return realElementAnimate.call(this, keyframes, opt_options); |
74 }; | 73 }; |
75 if (document.timeline && document.timeline.play) { | 74 if (document.timeline && document.timeline.play) { |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 exports.runTest = runTest; | 1752 exports.runTest = runTest; |
1754 exports.runTestFunction = runTestFunction; | 1753 exports.runTestFunction = runTestFunction; |
1755 exports.DUMMY_URL = DUMMY_URL; | 1754 exports.DUMMY_URL = DUMMY_URL; |
1756 exports.TEST = TEST; | 1755 exports.TEST = TEST; |
1757 exports.TEST_F = TEST_F; | 1756 exports.TEST_F = TEST_F; |
1758 exports.RUNTIME_TEST_F = TEST_F; | 1757 exports.RUNTIME_TEST_F = TEST_F; |
1759 exports.GEN = GEN; | 1758 exports.GEN = GEN; |
1760 exports.GEN_INCLUDE = GEN_INCLUDE; | 1759 exports.GEN_INCLUDE = GEN_INCLUDE; |
1761 exports.WhenTestDone = WhenTestDone; | 1760 exports.WhenTestDone = WhenTestDone; |
1762 })(this); | 1761 })(this); |
OLD | NEW |