Skip to content

Commit 948af47

Browse files
authoredDec 6, 2019
Disable deprecated find event target behavior (#9946)
* Default DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 * Add note about DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 * Add more details to the changelog * Slightly improve formatting * Update tests to use DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 mode * Fix OffscreenCanvas lookup when compiling without pthreads enabled * Fix test_other
1 parent 6fd4a4a commit 948af47

17 files changed

+61
-101
lines changed
 

‎ChangeLog.md

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ See docs/process.md for how version tagging works.
1717

1818
Current Trunk
1919
-------------
20+
- Default `DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR` to 1. See #9895.
21+
With this change the old deprecated HTML5 API event target lookup behavior is
22+
disabled. There is no "Module.canvas" object, no magic "null" default handling,
23+
and DOM element 'target' parameters are taken to refer to CSS selectors, instead
24+
of referring to DOM IDs. For more information see:
25+
https://groups.google.com/forum/#!msg/emscripten-discuss/xScZ_LRIByk/_gEy67utDgAJ
2026

2127
v1.39.4: 12/03/2019
2228
-------------------

‎emcc.py

-4
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,6 @@ def check(input_file):
11181118
shared.Settings.WASM_OBJECT_FILES = 0
11191119

11201120
if shared.Settings.STRICT:
1121-
shared.Settings.DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1
11221121
shared.Settings.STRICT_JS = 1
11231122
shared.Settings.AUTO_JS_LIBRARIES = 0
11241123
shared.Settings.AUTO_ARCHIVE_INDEXES = 0
@@ -1531,9 +1530,6 @@ def is_supported_link_flag(f):
15311530
# used and this special directive can be dropped.
15321531
shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$warnOnce']
15331532

1534-
# Always use the new HTML5 API event target lookup rules
1535-
shared.Settings.DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1
1536-
15371533
# Require explicit -lfoo.js flags to link with JS libraries.
15381534
shared.Settings.AUTO_JS_LIBRARIES = 0
15391535

‎src/library_html5.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,6 @@ var LibraryJSEvents = {
280280
var domElement = __specialEventTargets[target] || (typeof document !== 'undefined' ? document.querySelector(__maybeCStringToJsString(target)) : undefined);
281281
#else
282282
var domElement = __specialEventTargets[target] || document.querySelector(__maybeCStringToJsString(target));
283-
#endif
284-
#if ASSERTIONS
285-
// TODO: Remove this check in the future, or move it to some kind of debugging mode, because it may be perfectly fine behavior
286-
// for one to query an event target to test if any DOM element with given CSS selector exists. However for a migration period
287-
// from old lookup over to new, it is very useful to get diagnostics messages related to a lookup failing.
288-
if (!domElement) err('No DOM element was found with CSS selector "' + __maybeCStringToJsString(target) + '"');
289283
#endif
290284
return domElement;
291285
},
@@ -295,15 +289,26 @@ var LibraryJSEvents = {
295289
_findCanvasEventTarget: function(target) {
296290
target = __maybeCStringToJsString(target);
297291

298-
// First look up if there exists an OffscreenCanvas with the given name.
299-
var offscreenCanvas;
300-
// TODO: Once Module['canvas'] is removed, clean up the following line:
301-
if (target == '#canvas') offscreenCanvas = GL.offscreenCanvases['canvas'];
302-
if (!offscreenCanvas) offscreenCanvas = GL.offscreenCanvases[target] || (target == 'canvas' && Object.keys(GL.offscreenCanvases)[0]); // First looks up by DOM ID ("#myCanvasElement"), second looks up by DOM element name (first found element of type <canvas>)
303-
if (offscreenCanvas) return offscreenCanvas;
304-
292+
// When compiling with OffscreenCanvas support and looking up a canvas to target,
293+
// we first look up if the target Canvas has been transferred to OffscreenCanvas use.
294+
// These transfers are represented/tracked by GL.offscreenCanvases object, which contain
295+
// the OffscreenCanvas element for each regular Canvas element that has been transferred.
296+
297+
// Note that each pthread/worker have their own set of GL.offscreenCanvases. That is,
298+
// when an OffscreenCanvas is transferred from a pthread/main thread to another pthread,
299+
// it will move in the GL.offscreenCanvases array between threads. Hence GL.offscreenCanvases
300+
// represents the set of OffscreenCanvases owned by the current calling thread.
301+
302+
// First check out the list of OffscreenCanvases by CSS selector ID ('#myCanvasID')
303+
return GL.offscreenCanvases[target.substr(1)] // Remove '#' prefix
304+
// If not found, if one is querying by using DOM tag name selector 'canvas', grab the first
305+
// OffscreenCanvas that we can find.
306+
|| (target == 'canvas' && Object.keys(GL.offscreenCanvases)[0])
307+
// If that is not found either, query via the regular DOM selector.
305308
#if USE_PTHREADS
306-
return (typeof document !== 'undefined') ? document.querySelector(target) : null;
309+
|| (typeof document !== 'undefined' && document.querySelector(target));
310+
#else
311+
|| document.querySelector(target);
307312
#endif
308313
},
309314
#else

‎src/settings.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ var LINKABLE = 0;
853853
// Set the environment variable EMCC_STRICT=1 or pass -s STRICT=1 to test that a
854854
// codebase builds nicely in forward compatible manner.
855855
// Changes enabled by this:
856-
// * DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR is enabled.
857856
// * The C define EMSCRIPTEN is not defined (__EMSCRIPTEN__ always is, and
858857
// is the correct thing to use).
859858
// * STRICT_JS is enabled.
@@ -1634,7 +1633,7 @@ var SUPPORT_LONGJMP = 1;
16341633
// If set to 1, disables old deprecated HTML5 API event target lookup behavior. When enabled,
16351634
// there is no "Module.canvas" object, no magic "null" default handling, and DOM element
16361635
// 'target' parameters are taken to refer to CSS selectors, instead of referring to DOM IDs.
1637-
var DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 0;
1636+
var DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR = 1;
16381637

16391638
// Specifies whether the generated .html file is run through html-minifier. The set of
16401639
// optimization passes run by html-minifier depends on debug and optimization levels. In

‎tests/canvas_size_proxy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int main()
1212
{
1313
int result = 0;
1414
double w, h;
15-
emscripten_get_element_css_size(NULL, &w, &h);
15+
emscripten_get_element_css_size("#canvas", &w, &h);
1616
if (isnan(w) || isnan(h))
1717
{
1818
result = 1;

‎tests/emscripten_set_canvas_element_size.c

+9-59
Original file line numberDiff line numberDiff line change
@@ -17,88 +17,38 @@ int main(int argc, char **argv)
1717
// For testing purposes, rename the canvas on the page to some arbitrary ID.
1818
EM_ASM(document.getElementById('canvas').id = 'myCanvasId');
1919

20-
// Accessing #canvas should resize Module['canvas']
21-
EMSCRIPTEN_RESULT r = emscripten_set_canvas_element_size("#canvas", 100, 200);
20+
// Test emscripten_set_canvas_element_size()
21+
EMSCRIPTEN_RESULT r = emscripten_set_canvas_element_size("#myCanvasId", 100, 200);
2222
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
2323

2424
int w, h;
25-
r = emscripten_get_canvas_element_size("#canvas", &w, &h);
25+
r = emscripten_get_canvas_element_size("#myCanvasId", &w, &h);
2626
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
2727
assert(w == 100);
2828
assert(h == 200);
2929
w = h = 0;
3030

31-
// Check that we see the change via 'NULL'
32-
r = emscripten_get_canvas_element_size(NULL, &w, &h);
33-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
34-
assert(w == 100);
35-
assert(h == 200);
36-
w = h = 0;
37-
38-
// Check that we see the change via 'mycanvasId'
39-
r = emscripten_get_canvas_element_size("myCanvasId", &w, &h);
40-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
41-
assert(w == 100);
42-
assert(h == 200);
43-
4431
// The following line will not work with OffscreenCanvas, that is covered in another test
45-
int jsAgreesWithSize = EM_ASM_INT({return Module['canvas'].width == 100 && Module['canvas'].height == 200});
32+
int jsAgreesWithSize = EM_ASM_INT({return document.querySelector('#myCanvasId').width == 100 && document.querySelector('#myCanvasId').height == 200});
4633
assert(jsAgreesWithSize);
4734

48-
// Accessing NULL should also resize Module['canvas']
49-
r = emscripten_set_canvas_element_size(NULL, 101, 201);
50-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
51-
52-
// Check that we see the change on the canvas (via the established #canvas)
53-
r = emscripten_get_canvas_element_size("#canvas", &w, &h);
54-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
55-
assert(w == 101);
56-
assert(h == 201);
57-
w = h = 0;
58-
59-
// Check that we see the change via 'NULL'
60-
r = emscripten_get_canvas_element_size(NULL, &w, &h);
61-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
62-
assert(w == 101);
63-
assert(h == 201);
64-
w = h = 0;
65-
66-
// Check that we see the change via 'mycanvasId'
67-
r = emscripten_get_canvas_element_size("myCanvasId", &w, &h);
68-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
69-
assert(w == 101);
70-
assert(h == 201);
71-
7235
// Accessing by specific ID should resize canvas by that ID
73-
r = emscripten_set_canvas_element_size("myCanvasId", 102, 202);
74-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
75-
76-
// Check that we see the change on the canvas (via the established #canvas)
77-
r = emscripten_get_canvas_element_size("#canvas", &w, &h);
36+
r = emscripten_set_canvas_element_size("#myCanvasId", 102, 202);
7837
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
79-
assert(w == 102);
80-
assert(h == 202);
8138

82-
// Check that we see the change on the canvas (via the established #canvas)
83-
r = emscripten_get_canvas_element_size("#canvas", &w, &h);
39+
// Check that we see the change on the canvas when querying with ID
40+
r = emscripten_get_canvas_element_size("#myCanvasId", &w, &h);
8441
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
8542
assert(w == 102);
8643
assert(h == 202);
87-
w = h = 0;
8844

89-
// Check that we see the change via 'NULL'
90-
r = emscripten_get_canvas_element_size(NULL, &w, &h);
45+
// Check that we see the change on the canvas when querying with DOM element type
46+
r = emscripten_get_canvas_element_size("canvas", &w, &h);
9147
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
9248
assert(w == 102);
9349
assert(h == 202);
9450
w = h = 0;
9551

96-
// Check that we see the change via 'mycanvasId'
97-
r = emscripten_get_canvas_element_size("myCanvasId", &w, &h);
98-
assert(r == EMSCRIPTEN_RESULT_SUCCESS);
99-
assert(w == 102);
100-
assert(h == 202);
101-
10252
#ifdef REPORT_RESULT
10353
REPORT_RESULT(1);
10454
#endif

‎tests/keydown_preventdefault_proxy.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ int main(int argc, char **argv)
5252
{
5353
printf("main argc:%d\n", argc);
5454

55-
emscripten_set_keydown_callback("#document", 0, 1, keydown_callback);
56-
emscripten_set_keypress_callback("#document", 0, 1, keypress_callback);
57-
emscripten_set_keyup_callback("#document", 0, 1, keyup_callback);
55+
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, 0, 1, keydown_callback);
56+
emscripten_set_keypress_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, 0, 1, keypress_callback);
57+
emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, 0, 1, keyup_callback);
5858

5959
return 0;
6060
}

‎tests/other/metadce/hello_world_fastcomp_O3_MAIN_MODULE.sent

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ __inet_pton4_raw
437437
__inet_pton6
438438
__inet_pton6_raw
439439
__isLeapYear
440+
__maybeCStringToJsString
440441
__memory_base
441442
__polyfill_set_immediate
442443
__pthread_cleanup_pop

‎tests/test_browser.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -2563,13 +2563,13 @@ def test_doublestart_bug(self):
25632563
def test_html5(self):
25642564
for opts in [[], ['-O2', '-g1', '--closure', '1'], ['-s', 'USE_PTHREADS=1', '-s', 'PROXY_TO_PTHREAD=1']]:
25652565
print(opts)
2566-
self.btest(path_from_root('tests', 'test_html5.c'), args=['-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1'] + opts, expected='0')
2566+
self.btest(path_from_root('tests', 'test_html5.c'), args=[] + opts, expected='0')
25672567

25682568
@requires_threads
25692569
def test_html5_gamepad(self):
25702570
for opts in [[], ['-O2', '-g1', '--closure', '1'], ['-s', 'USE_PTHREADS=1', '-s', 'PROXY_TO_PTHREAD=1']]:
25712571
print(opts)
2572-
self.btest(path_from_root('tests', 'test_gamepad.c'), args=['-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1'] + opts, expected='0')
2572+
self.btest(path_from_root('tests', 'test_gamepad.c'), args=[] + opts, expected='0')
25732573

25742574
@requires_graphics_hardware
25752575
def test_html5_webgl_create_context_no_antialias(self):
@@ -2587,14 +2587,15 @@ def test_html5_webgl_create_context(self):
25872587

25882588
@requires_graphics_hardware
25892589
# Verify bug https://github.com/emscripten-core/emscripten/issues/4556: creating a WebGL context to Module.canvas without an ID explicitly assigned to it.
2590+
# (this only makes sense in the old deprecated -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 mode)
25902591
def test_html5_webgl_create_context2(self):
2591-
self.btest(path_from_root('tests', 'webgl_create_context2.cpp'), args=['--shell-file', path_from_root('tests', 'webgl_create_context2_shell.html'), '-lGL'], expected='0')
2592+
self.btest(path_from_root('tests', 'webgl_create_context2.cpp'), args=['--shell-file', path_from_root('tests', 'webgl_create_context2_shell.html'), '-lGL', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0'], expected='0')
25922593

25932594
@requires_graphics_hardware
25942595
def test_html5_webgl_destroy_context(self):
25952596
for opts in [[], ['-O2', '-g1'], ['-s', 'FULL_ES2=1']]:
25962597
print(opts)
2597-
self.btest(path_from_root('tests', 'webgl_destroy_context.cpp'), args=opts + ['-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1', '--shell-file', path_from_root('tests/webgl_destroy_context_shell.html'), '-lGL'], expected='0')
2598+
self.btest(path_from_root('tests', 'webgl_destroy_context.cpp'), args=opts + ['--shell-file', path_from_root('tests/webgl_destroy_context_shell.html'), '-lGL'], expected='0')
25982599

25992600
@no_chrome('see #7373')
26002601
@requires_graphics_hardware
@@ -2665,7 +2666,7 @@ def test_sdl_touch(self):
26652666
def test_html5_mouse(self):
26662667
for opts in [[], ['-O2', '-g1', '--closure', '1']]:
26672668
print(opts)
2668-
self.btest(path_from_root('tests', 'test_html5_mouse.c'), args=opts + ['-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1', '-DAUTOMATE_SUCCESS=1'], expected='0')
2669+
self.btest(path_from_root('tests', 'test_html5_mouse.c'), args=opts + ['-DAUTOMATE_SUCCESS=1'], expected='0')
26692670

26702671
def test_sdl_mousewheel(self):
26712672
for opts in [[], ['-O2', '-g1', '--closure', '1']]:
@@ -4233,7 +4234,7 @@ def test_small_js_flags(self):
42334234
@requires_offscreen_canvas
42344235
def test_webgl_offscreen_canvas_in_pthread(self):
42354236
for args in [[], ['-DTEST_CHAINED_WEBGL_CONTEXT_PASSING']]:
4236-
self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1'])
4237+
self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL'])
42374238

42384239
# Tests that it is possible to render WebGL content on a <canvas> on the main thread, after it has once been used to render WebGL content in a pthread first
42394240
# -DTEST_MAIN_THREAD_EXPLICIT_COMMIT: Test the same (WebGL on main thread after pthread), but by using explicit .commit() to swap on the main thread instead of implicit "swap when rAF ends" logic
@@ -4242,12 +4243,12 @@ def test_webgl_offscreen_canvas_in_pthread(self):
42424243
def test_webgl_offscreen_canvas_in_mainthread_after_pthread(self):
42434244
self.skipTest('This test is disabled because current OffscreenCanvas does not allow transfering it after a rendering context has been created for it.')
42444245
for args in [[], ['-DTEST_MAIN_THREAD_EXPLICIT_COMMIT']]:
4245-
self.btest('gl_in_mainthread_after_pthread.cpp', expected='0', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1'])
4246+
self.btest('gl_in_mainthread_after_pthread.cpp', expected='0', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL'])
42464247

42474248
@requires_threads
42484249
@requires_offscreen_canvas
42494250
def test_webgl_offscreen_canvas_only_in_pthread(self):
4250-
self.btest('gl_only_in_pthread.cpp', expected='0', args=['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=1', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1', '-s', 'OFFSCREEN_FRAMEBUFFER=1'])
4251+
self.btest('gl_only_in_pthread.cpp', expected='0', args=['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=1', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'OFFSCREEN_FRAMEBUFFER=1'])
42514252

42524253
# Tests that rendering from client side memory without default-enabling extensions works.
42534254
@requires_graphics_hardware
@@ -4300,7 +4301,7 @@ def test_webgl_array_of_structs_uniform(self):
43004301
@requires_offscreen_canvas
43014302
def test_webgl_offscreen_canvas_in_proxied_pthread(self):
43024303
for asyncify in [0, 1]:
4303-
cmd = ['-s', 'USE_PTHREADS=1', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'GL_DEBUG=1', '-s', 'PROXY_TO_PTHREAD=1', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1']
4304+
cmd = ['-s', 'USE_PTHREADS=1', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'GL_DEBUG=1', '-s', 'PROXY_TO_PTHREAD=1']
43044305
if asyncify:
43054306
if not self.is_wasm_backend():
43064307
continue
@@ -4316,7 +4317,7 @@ def test_webgl_resize_offscreencanvas_from_main_thread(self):
43164317
for args1 in [[], ['-s', 'PROXY_TO_PTHREAD=1']]:
43174318
for args2 in [[], ['-DTEST_SYNC_BLOCKING_LOOP=1']]:
43184319
for args3 in [[], ['-s', 'OFFSCREENCANVAS_SUPPORT=1', '-s', 'OFFSCREEN_FRAMEBUFFER=1']]:
4319-
cmd = args1 + args2 + args3 + ['-s', 'USE_PTHREADS=1', '-lGL', '-s', 'GL_DEBUG=1', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1']
4320+
cmd = args1 + args2 + args3 + ['-s', 'USE_PTHREADS=1', '-lGL', '-s', 'GL_DEBUG=1']
43204321
print(str(cmd))
43214322
self.btest('resize_offscreencanvas_from_main_thread.cpp', expected='1', args=cmd)
43224323

‎tests/test_other.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8231,7 +8231,7 @@ def test_metadce_hello(self, *args):
82318231
4, [], [], 8, 0, 0, 0), # noqa; totally empty!
82328232
# we don't metadce with linkable code! other modules may want stuff
82338233
# don't compare the # of functions in a main module, which changes a lot
8234-
'main_module_1': (['-O3', '-s', 'MAIN_MODULE=1'], 1605, [], [], 226403, None, 108, None), # noqa
8234+
'main_module_1': (['-O3', '-s', 'MAIN_MODULE=1'], 1606, [], [], 226403, None, 108, None), # noqa
82358235
'main_module_2': (['-O3', '-s', 'MAIN_MODULE=2'], 13, [], [], 10017, 13, 9, 20), # noqa
82368236
})
82378237
@no_wasm_backend()

‎tests/webgl2_objects.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main()
3636
attrs.majorVersion = 2;
3737
attrs.minorVersion = 0;
3838

39-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( 0, &attrs );
39+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( "#canvas", &attrs );
4040
if (!context)
4141
{
4242
printf("Skipped: WebGL 2 is not supported.\n");

‎tests/webgl2_pbo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main()
3737
attrs.majorVersion = 2;
3838
attrs.minorVersion = 0;
3939

40-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( 0, &attrs );
40+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( "#canvas", &attrs );
4141
if (!context)
4242
{
4343
printf("Skipped: WebGL 2 is not supported.\n");

‎tests/webgl2_ubos.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main()
3535
attrs.majorVersion = 2;
3636
attrs.minorVersion = 0;
3737

38-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( 0, &attrs );
38+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( "#canvas", &attrs );
3939
if (!context)
4040
{
4141
printf("Skipped: WebGL 2 is not supported.\n");

‎tests/webgl_create_context.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int main()
107107
);
108108

109109
assert(emscripten_webgl_get_current_context() == 0);
110-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("customCanvas", &attrs);
110+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#customCanvas", &attrs);
111111
assert(context > 0); // Must have received a valid context.
112112
EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
113113
assert(res == EMSCRIPTEN_RESULT_SUCCESS);

‎tests/webgl_create_context2.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ int main()
1414
{
1515
EmscriptenWebGLContextAttributes attrs;
1616
emscripten_webgl_init_context_attributes(&attrs);
17+
// Test that creating a context with #canvas target when -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0
18+
// will create a canvas against Module.canvas
1719
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#canvas", &attrs);
1820
assert(context > 0); // Must have received a valid context.
1921
EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);

‎tests/webgl_shader_source_length.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main()
3333
EmscriptenWebGLContextAttributes attrs;
3434
emscripten_webgl_init_context_attributes(&attrs);
3535

36-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( 0, &attrs );
36+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( "#canvas", &attrs );
3737
if (!context)
3838
{
3939
printf("Skipped: WebGL is not supported.\n");

‎tests/webgl_with_closure.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ int main()
7676
attrs.majorVersion = 2;
7777
attrs.minorVersion = 0;
7878

79-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( 0, &attrs );
79+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context( "#canvas", &attrs );
8080
if (!context)
8181
{
8282
attrs.majorVersion = 1;
83-
context = emscripten_webgl_create_context( 0, &attrs );
83+
context = emscripten_webgl_create_context( "#canvas", &attrs );
8484
if (context) printf("Skipping test: WebGL 2.0 is not available.\n");
8585
else printf("Test failed: WebGL is not available!\n");
8686
#ifdef REPORT_RESULT

0 commit comments

Comments
 (0)
Please sign in to comment.