Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / tough_animation_cases / overlay_background_color_css_transitions.html
1 <!--
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.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
9 met:
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
15 distribution.
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.
19
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.
31
32 This test is based on code written by Cameron Adams and imported from
33   http://themaninblue.com/experiment/AnimationBenchmark/html
34 -->
35
36 <!doctype html>
37 <head>
38 <title>Benchmark - Overlay background-color Animation using CSS Transitions</title>
39 <style>
40 html {
41     height: 100%;
42 }
43
44 body {
45     width: 100%;
46     height: 100%;
47     overflow: hidden;
48     margin: 0;
49     padding: 0;
50 }
51
52 .overlay {
53     position: absolute;
54     width: 600px;
55     height: 600px;
56     -webkit-transform: translateZ(0);
57     -webkit-transition: background-color 1s linear;
58 }
59 </style>
60 <script src="resources/perftesthelper.js"></script>
61 <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)"];
66
67 var testRunning = true;
68 var overlays = [];
69
70 window.onload = function () {
71     // Create the overlays
72     for (var i = 0; i < maxOverlays; i++) {
73         var overlay = new Overlay();
74         overlay.start();
75         overlays.push(overlay);
76     }
77
78     window.measurementReady = true;
79 }
80
81 function Overlay()
82 {
83     // Create visual element for the overlay
84     var domNode = document.createElement('div');
85     domNode.classList.add('overlay');
86     document.body.appendChild(domNode);
87
88     // Set color of element
89     domNode.style.backgroundColor = colors[Math.floor(PerfTestHelper.random() * colors.length)];
90
91     function destroy()
92     {
93         document.body.removeChild(domNode);
94     }
95
96     function changeBackgroundColor() {
97         if (!testRunning)
98             return;
99         domNode.style.backgroundColor = colors[Math.floor(PerfTestHelper.random() * colors.length)];
100         setTimeout(changeBackgroundColor, 1000);
101     }
102
103     function start() {
104         // Set timeout is used to ensure the transition-property value gets a chance to register on the element.
105         setTimeout(changeBackgroundColor, 0);
106     }
107
108     this.start = start;
109     this.destroy = destroy;
110 }
111 </script>
112 </head>
113 </html>