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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferControlToOffscreen.html

Issue 2294963002: Submit Compositor Frame from OffscreenCanvas on main (Closed)
Patch Set: a test to ensure resizing on transferred offscreencanvas has no effect Created 4 years, 3 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
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 </head> 6 </head>
6 <body> 7 <body>
7 <script> 8 <script>
8
9 description("Test transferControlToOffscreen.");
10 window.jsTestIsAsync = true;
11
12 function createCanvas(width, height) { 9 function createCanvas(width, height) {
13 var canvas = document.createElement("canvas"); 10 var canvas = document.createElement("canvas");
14 canvas.width = width; 11 canvas.width = width;
15 canvas.height = height; 12 canvas.height = height;
16 return canvas; 13 return canvas;
17 } 14 }
18 15
19 // Tests whether transferControlToOffscreen can be run correctly. 16 test(function() {
20 var width = 50; 17 var width = 50;
21 var height = 50; 18 var height = 50;
22 var canvas1 = createCanvas(width, height); 19 var canvas1 = createCanvas(width, height);
23 var offscreenCanvas1; 20 var offscreenCanvas1;
24 try { 21 try {
25 offscreenCanvas1 = canvas1.transferControlToOffscreen(); 22 offscreenCanvas1 = canvas1.transferControlToOffscreen();
26 testPassed("Successfully created layer for offscreencanvas"); 23 assert_equals(offscreenCanvas1.width, width);
27 shouldBe("offscreenCanvas1.width", "width"); 24 assert_equals(offscreenCanvas1.height, height);
28 shouldBe("offscreenCanvas1.height", "height"); 25 } catch (ex) {
29 } catch (ex) { 26 assert_false(ex.message);
30 testFailed(ex.message); 27 }
31 } 28 }, "Tests whether transferControlToOffscreen can be run correctly.");
32 29
33 // Tests whether transferControlToOffscreen throws exception correctly. 30 test(function() {
34 var canvas2 = createCanvas(50, 50); 31 var canvas2 = createCanvas(50, 50);
35 var offscreenCanvas2; 32 var offscreenCanvas2;
36 var ctx = canvas2.getContext("2d"); 33 var ctx = canvas2.getContext("2d");
37 try { 34 assert_throws("InvalidStateError", function() {
38 offscreenCanvas2 = canvas2.transferControlToOffscreen(); 35 offscreenCanvas2 = canvas2.transferControlToOffscreen();
39 testFailed("transferControlToOffscreen from a canvas with context didn't thr ow an exception."); 36 assert_false("transferControlToOffscreen from a canvas with context didn 't throw an exception.");
40 } catch (ex) { 37 }, "transferControlToOffscreen from a canvas with context throws an exceptio n");
41 testPassed("transferControlToOffscreen from a canvas with context throws an exception: " + ex); 38 }, "Tests whether transferControlToOffscreen throws exception correctly.");
42 }
43 39
44 finishJSTest(); 40 test(function() {
41 var canvas3 = createCanvas(10, 10);
42 var offscreenCanvas3 = canvas3.transferControlToOffscreen();
43 assert_equals(offscreenCanvas3.width, 10);
44 assert_equals(offscreenCanvas3.height, 10);
45 offscreenCanvas3.width = 20;
46 offscreenCanvas3.height = 20;
47 assert_equals(offscreenCanvas3.width, 10);
48 assert_equals(offscreenCanvas3.height, 10);
49 }, "Test if resizing on offscreencanvas transferred from html canvas has no effe ct");
50
45 </script> 51 </script>
46 </body> 52 </body>
47 </html> 53 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698