Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/test/data/webui/test_api.js

Issue 2927663003: Fix Test.disableAnimationsAndTransitions to work with new /deep/ (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698