-
Couldn't load subscription status.
- Fork 3.4k
[file-packager] Use fetch() for loading file packages.
#22016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
32fbce8
b88154d
b8e2ed9
58fcb8f
3945a0b
c31c0f8
b76122f
9712210
ba19ffc
30d2d8e
0c88d25
0e769ca
b23fffa
c3fadbc
4b05f80
8a027b7
9b415a6
db4a31d
3bf0964
03b301a
8ff77d0
5b37c95
34b1afd
bedece9
6bffc95
e2c4ea8
efaf744
027532e
e360fa8
295b750
27a84da
206bb2b
4168338
f622a0d
e24cc12
489bc06
071b814
ddb958e
c553d28
61dea12
661258b
06404fb
68d3d02
9b00c17
e78ac48
27a1c42
edd3a18
a7747d4
78958aa
572bf74
4386290
e68044e
4fac7e0
1c9d521
aadfaec
6fd7e01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -5541,6 +5541,66 @@ def test_webpack(self): | |||
| shutil.copyfile('webpack/src/hello.wasm', 'webpack/dist/hello.wasm') | ||||
| self.run_browser('webpack/dist/index.html', '/report_result?exit:0') | ||||
|
|
||||
| def test_fetch_polyfill_preload(self): | ||||
| path = 'hello-world.txt' | ||||
seanmorris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| create_file(path, 'hello, world!') | ||||
| create_file('main.cpp', r''' | ||||
seanmorris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| #include <emscripten.h> | ||||
| int main() { | ||||
| FILE *f = fopen("%s", "r"); | ||||
| char buf[100]; | ||||
| fread(buf, 1, 20, f); | ||||
| buf[20] = 0; | ||||
| fclose(f); | ||||
| printf("|%%s|\n", buf); | ||||
| return 0; | ||||
| } | ||||
| ''' % path) | ||||
| create_file('on_window_error_shell.html', r''' | ||||
| <html> | ||||
| <center><canvas id='canvas' width='256' height='256'></canvas></center> | ||||
| <hr><div id='output'></div><hr> | ||||
| <script type='text/javascript'> | ||||
| window.addEventListener('error', event => { | ||||
| const error = String(event.message); | ||||
| console.log({error}); | ||||
| window.disableErrorReporting = true; | ||||
| window.onerror = null; | ||||
| var xhr = new XMLHttpRequest(); | ||||
| xhr.open('GET', 'http://localhost:8888/report_result?' + (error.includes('fetch is not a function') ? 1 : 0), true); | ||||
| xhr.send(); | ||||
| setTimeout(function() { window.close() }, 1000); | ||||
| }); | ||||
| var Module = { | ||||
| print: (function() { | ||||
| var element = document.getElementById('output'); | ||||
| return function(text) { | ||||
| console.log({text}); | ||||
| if(window.disableErrorReporting) return; | ||||
| element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>'; | ||||
| var xhr = new XMLHttpRequest(); | ||||
| xhr.open('GET', 'http://localhost:8888/report_result?' + (text === '|hello, world!|' ? 1 : 0), true); | ||||
| xhr.send(); | ||||
| }; | ||||
| })(), | ||||
| canvas: document.getElementById('canvas') | ||||
| }; | ||||
| </script> | ||||
| {{{ SCRIPT }}} | ||||
| </body> | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than require special shell can you just rely on the fact that default reporting will try bot emscripten/test/browser_reporting.js Line 16 in a6e1f5c
i.e. when you disable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbc100 I'm not able to get the exception out of the browser without the custom shell. It just hangs with the exception listed as uncaught in the browser's console. |
||||
| </html>''') | ||||
|
|
||||
| def test(args, expect_fail): | ||||
| self.compile_btest('main.cpp', args + ['--preload-file', path, '--shell-file', 'on_window_error_shell.html', '-o', 'a.out.html']) | ||||
| js = read_file('a.out.js') | ||||
seanmorris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| if expect_fail: | ||||
| create_file('a.out.js', 'fetch = undefined;\n' + js) | ||||
| return self.run_browser('a.out.html', '/report_result?1') | ||||
| else: | ||||
| return self.run_browser('a.out.html', '/report_result?1') | ||||
seanmorris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
|
|
||||
| def test_fetch_polyfill_shared_lib(self): | ||||
| create_file('library.c', r''' | ||||
| #include <stdio.h> | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.