offscreencanvas.transfercontrol.to.offscreen.html (1493B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/html/canvas/resources/canvas-tests.js"></script> 5 <link rel="help" href="https://html.spec.whatwg.org/#dom-canvas-transfercontroltooffscreen"> 6 <script> 7 8 test(function() { 9 var placeholder = document.createElement('canvas'); 10 placeholder.width = 100; 11 placeholder.height = 50; 12 var offscreenCanvas = placeholder.transferControlToOffscreen(); 13 assert_equals(offscreenCanvas.width, 100); 14 assert_equals(offscreenCanvas.height, 50); 15 }, "Test that an OffscreenCanvas generated by transferControlToOffscreen gets correct width and height"); 16 17 test(function() { 18 var placeholder = document.createElement('canvas'); 19 placeholder.width = 100; 20 placeholder.height = 50; 21 var offscreenCanvas = placeholder.transferControlToOffscreen(); 22 assert_throws_dom("InvalidStateError", function() { placeholder.getContext('2d'); }); 23 }, "Test that calling getContext on a placeholder canvas that has already transferred its control throws an exception"); 24 25 test(function() { 26 var placeholder = document.createElement('canvas'); 27 placeholder.width = 100; 28 placeholder.height = 50; 29 var offscreenCanvas = placeholder.transferControlToOffscreen(); 30 assert_throws_dom("InvalidStateError", function() { placeholder.transferControlToOffscreen(); }); 31 }, "Test that calling transferControlToOffscreen twice throws an exception"); 32 33 </script>