2 Copyright (c) 2012 Cameron Adams. All rights reserved.
3 Copyright (c) 2012 Code Aurora Forum. All rights reserved.
4 Copyright (C) 2013 Google Inc. All rights reserved.
5 Copyright (C) 2013 Intel Inc. All rights reserved.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following disclaimer
14 in the documentation and/or other materials provided with the
16 * Neither the name of Code Aurora Forum Inc., Google Inc. nor the
17 names of its contributors may be used to endorse or promote products
18 derived from this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 This test is based on code written by Cameron Adams and imported from
33 http://themaninblue.com/experiment/AnimationBenchmark/html
38 <title>Benchmark - Overlay background-color Animation using CSS Transitions</title>
56 -webkit-transform: translateZ(0);
57 -webkit-transition: background-color 1s linear;
60 <script src="resources/perftesthelper.js"></script>
62 window.measurementReady = false;
63 var maxOverlays = 500;
64 var colors = ["rgba(204, 0, 0, 0.5)", "rgba(255, 204, 0, 0.5)", "rgba(170, 255, 0, 0.5)"
65 , "rgba(0, 153, 204, 0.5)", "rgba(25, 76, 153, 0.5)", "rgba(102, 25, 153, 0.5)"];
67 var testRunning = true;
70 window.onload = function () {
71 // Create the overlays
72 for (var i = 0; i < maxOverlays; i++) {
73 var overlay = new Overlay();
75 overlays.push(overlay);
78 window.measurementReady = true;
83 // Create visual element for the overlay
84 var domNode = document.createElement('div');
85 domNode.classList.add('overlay');
86 document.body.appendChild(domNode);
88 // Set color of element
89 domNode.style.backgroundColor = colors[Math.floor(PerfTestHelper.random() * colors.length)];
93 document.body.removeChild(domNode);
96 function changeBackgroundColor() {
99 domNode.style.backgroundColor = colors[Math.floor(PerfTestHelper.random() * colors.length)];
100 setTimeout(changeBackgroundColor, 1000);
104 // Set timeout is used to ensure the transition-property value gets a chance to register on the element.
105 setTimeout(changeBackgroundColor, 0);
109 this.destroy = destroy;