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

Side by Side Diff: LayoutTests/fast/canvas/webgl/draw-webgl-to-canvas-2d.html

Issue 655133003: Fix a broken WebGL layout test by using testRunner.displayAsyncThen(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use requestAnimationFrame instead of setTimeout Created 6 years, 2 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 | LayoutTests/fast/canvas/webgl/draw-webgl-to-canvas-2d-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <span id="description" style="color: white"> 4 <span id="description" style="color: white">
5 This test checks for drawing webgl to canvas 2d. The test process is as follows: 5 This test checks for drawing webgl to canvas 2d. The test process is as follows:
6 1. draw a green rect on a webgl context. 6 1. draw a green rect on a webgl context.
7 2. draw a red rect on a canvas 2d context, and check a pixel (should be red). 7 2. draw a red rect on a canvas 2d context, and check a pixel (should be red).
8 3. draw the webgl contents on the canvas 2d context, and check a pixel (should b e green). 8 3. draw the webgl contents on the canvas 2d context, and check a pixel (should b e green).
9 4. wait for few frames. 9 4. wait for few frames.
10 5. draw a red rect on the canvas 2d context, and check a pixel (should be red). 10 5. draw a red rect on the canvas 2d context, and check a pixel (should be red).
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } else { 79 } else {
80 shouldBe("imgdata[0]", "0"); 80 shouldBe("imgdata[0]", "0");
81 shouldBe("imgdata[1]", "255"); 81 shouldBe("imgdata[1]", "255");
82 shouldBe("imgdata[2]", "0"); 82 shouldBe("imgdata[2]", "0");
83 } 83 }
84 84
85 if (isDrawingBufferUndefined && window.testRunner) 85 if (isDrawingBufferUndefined && window.testRunner)
86 testRunner.notifyDone(); 86 testRunner.notifyDone();
87 } 87 }
88 88
89 window.onload = function () { 89 function asyncTest() {
90 debug("Check for drawing webgl to canvas 2d several frames after drawing web gl contents.")
91 debug("1) when drawingBuffer is preserved.")
92 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false);
93 debug("2) when drawingBuffer is not preserved. It leads to undefined behavio r.")
94 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, true);
95 }
96
97 function startTestAfterFirstPaint() {
90 // create both canvas 2d and webgl contexts. 98 // create both canvas 2d and webgl contexts.
91 createContexts(); 99 createContexts();
92 // prepare webgl contents. 100 // prepare webgl contents.
93 renderWebGL(preserve_gl); 101 renderWebGL(preserve_gl);
94 renderWebGL(nonpreserve_gl); 102 renderWebGL(nonpreserve_gl);
95 103
96 debug("Check for drawing webgl to canvas 2d on the same frame.") 104 debug("Check for drawing webgl to canvas 2d on the same frame.")
97 debug("1) when drawingBuffer is preserved.") 105 debug("1) when drawingBuffer is preserved.")
98 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); 106 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false);
99 debug("2) when drawingBuffer is not preserved.") 107 debug("2) when drawingBuffer is not preserved.")
100 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, false); 108 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, false);
101 109
102 setTimeout(function () { 110 if (window.testRunner) {
103 debug("Check for drawing webgl to canvas 2d several frames after drawing webgl contents.") 111 testRunner.waitUntilDone();
104 debug("1) when drawingBuffer is preserved.") 112 testRunner.displayAsyncThen(asyncTest);
105 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); 113 } else {
106 debug("2) when drawingBuffer is not preserved. It leads to undefined beh avior.") 114 window.requestAnimationFrame(asyncTest);
107 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, true); 115 }
108 }, 50); 116 }
117
118 window.onload = function () {
119 window.requestAnimationFrame(startTestAfterFirstPaint);
109 } 120 }
110 121
111 </script> 122 </script>
112 </body> 123 </body>
113 </html> 124 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/webgl/draw-webgl-to-canvas-2d-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698