Skip to content

Commit 650d7b6

Browse files
committed
Simplify <canvas> creation in browser.test_html5_webgl_create_context test, avoid using cloneNode() but directly createElement('canvas'). Fixes the test on Windows.
1 parent 347e06c commit 650d7b6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tests/webgl_create_context.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,14 @@ int main()
8787
attrs.antialias = antialias;
8888
printf("Requesting depth: %d, stencil: %d, antialias: %d\n", depth, stencil, antialias);
8989

90-
if (!first)
91-
{
92-
EM_ASM(var canvas2 = Module.canvas.cloneNode();
93-
Module.canvas.parentElement.appendChild(canvas2);
94-
// Module.canvas.parentElement.removeChild(canvas);
95-
Module.canvas = canvas2;
96-
);
97-
}
98-
first = false;
90+
EM_ASM(
91+
var canvas2 = document.createElement('canvas');
92+
Module.canvas.parentElement.appendChild(canvas2);
93+
canvas2.id = 'customCanvas';
94+
);
9995

10096
assert(emscripten_webgl_get_current_context() == 0);
101-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(0, &attrs);
97+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("customCanvas", &attrs);
10298
assert(context > 0); // Must have received a valid context.
10399
EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
104100
assert(res == EMSCRIPTEN_RESULT_SUCCESS);
@@ -144,6 +140,11 @@ int main()
144140
res = emscripten_webgl_destroy_context(context);
145141
assert(res == 0);
146142
assert(emscripten_webgl_get_current_context() == 0);
143+
144+
EM_ASM(
145+
var canvas2 = document.getElementById('customCanvas');
146+
canvas2.parentElement.removeChild(canvas2);
147+
);
147148
}
148149

149150
// result will be reported when mainLoop completes

0 commit comments

Comments
 (0)