| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| function make_canvas(type) |
| { |
| if (type == "html") |
| return document.createElement("canvas"); |
| return new OffscreenCanvas(10, 10); |
| } |
| |
| function test_back_ref(contextType, canvasType) |
| { |
| var canvas = make_canvas(canvasType); |
| var ctx = canvas.getContext(contextType); |
| assert_equals(ctx.canvas, canvas, "Back reference to canvas should work."); |
| var anotherCanvas = make_canvas(canvasType); |
| ctx.canvas = anotherCanvas; |
| assert_not_equals(ctx.canvas, anotherCanvas, "Canvas attribute is read only."); |
| } |
| |
| generate_tests(test_back_ref, [ |
| ["2d context on html canvas", "2d", "html"], |
| ["webgl context on html canvas", "webgl", "html"], |
| ["bitmaprenderer context on html canvas", "bitmaprenderer", "html"], |
| ["2d context on offscreen canvas", "2d", "offscreen"], |
| ["webgl context on offscreen canvas", "webgl", "offscreen"], |
| ]); |
| </script> |