Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / content / test / data / gpu / webgl_with_select_element.html
blob43f7d69374b41bd479455d4babfc72a8cbfe8f95
1 <html>
2 <head>
3 <script type="text/javascript">
4 var gl;
5 // For some reason, when running this test in automated fashion, it
6 // triggers the bug reliably if the first frame with back-to-back
7 // events happens a certain number of frames into the test execution.
8 var numFrames = 202;
9 var intensity = 255;
10 var contextWasLost = false;
12 function contextLostHandler(e) {
13 contextWasLost = true;
16 function draw() {
17 if (--intensity == 0) {
18 intensity = 255;
21 gl.clearColor(intensity / 255.0, 0, 0, 1);
22 gl.clear(gl.COLOR_BUFFER_BIT);
24 if (numFrames % 2 == 0) {
25 // Toggle the state of the drop-down every other frame. Every now
26 // and then, dispatch two events back to back. This really seems to
27 // trigger the bug.
28 var maxIteration = 1;
29 if (numFrames % 6 == 0) {
30 maxIteration = 2;
32 for (var ii = 0; ii < maxIteration; ++ii) {
33 var e = document.createEvent('MouseEvent');
34 e.initMouseEvent('mousedown', true, true, window);
35 var s = document.getElementById('dropdown');
36 s.dispatchEvent(e);
40 if (--numFrames > 0) {
41 requestAnimationFrame(draw);
42 } else {
43 if (contextWasLost) {
44 window.domAutomationController.send("FAILED");
45 } else {
46 window.domAutomationController.send("SUCCESS");
51 function onLoad() {
52 window.domAutomationController.send("LOADED");
54 var canvas = document.getElementById("canvas1");
55 if (!canvas)
56 return;
57 canvas.addEventListener("webglcontextlost", contextLostHandler, false);
59 gl = canvas.getContext("webgl");
60 if (!gl)
61 return;
63 requestAnimationFrame(draw);
65 </script>
66 </head>
67 <body onload="onLoad()">
68 <select id="dropdown">
69 <option value="option1">option1</option>
70 <option value="option2">option2</option>
71 <option value="option3">option3</option>
72 <option value="option4">option4</option>
73 </select>
74 <canvas id="canvas1" width="32px" height="32px">
75 </canvas>
76 </body>
77 </html>