* Partially revert commit that broke using emrun.py outside the tree:
commit 4fc6505151
Author: Sam Clegg <sbc@chromium.org>
Date: Sun Sep 13 19:05:11 2020 -0700
Use shared wrappers for shutils. NFC. (#12200)
We we not being consistent in our use of safe_copy and
safe_move and try_delete.
* Add comment.
* Make emrun.py python 2 compatible again
* flake
Unlike the other browser tests they don't use the test
runner harness and instead launch their own browser.
I was finding that running the test locally in isolation
that browser test harness would interfere with the
browser that emrun was starting.. since they both honor
EMTEST_BROWSER.
We have been error'ing out python3 usage for a while now.
This change finally removes the python2 support so there
is no way back.
And to show we mean it, include an f-string in there
for good measure.
Fixes: #7198
* emrun: use argparse in more conventional way
This is not quite NFC since passing command line arguments
to the page that start with `-` now requires a separator.
This used to work:
./emrun filename.html --foo --bar
Where as now one needs to add `--` to signal the end of emrun's
argument parsing.
So either:
./emrun filename.html -- --foo --bar
or:
./emrun -- filename.html --foo --bar
* error_check
This message means that the browser itself is closing
or has already closed.
Without this change the tests the rely on this all report
exceptions sending the `OK` response. e.g:
```
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49430)
Traceback (most recent call last):
File "/usr/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.8/http/server.py", line 647, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/usr/lib/python3.8/http/server.py", line 427, in handle
self.handle_one_request()
File "/usr/lib/python3.8/http/server.py", line 415, in handle_one_request
method()
File "/home/sbc/dev/wasm/emscripten/emrun.py", line 703, in do_POST
self.wfile.write(b'OK')
File "/usr/lib/python3.8/socketserver.py", line 799, in write
self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
```
Essentially, if the first argument to the `cmd.exe` function `start` has
quotes, it will be interpreted as the title of a new `cmd.exe` window instead
of the command to execute. This can be fixed by specifying `""` as the first
argument.
1. import winreg
winreg is python standard module. It was called `_winreg` in
python2 but `winreg` in python3. Unlike pywin32 it is not
a seprate module and we never need to worry about it being missing.
2. Make pywin32 mandatory in the functions that need it.
There are just a couple of functions that use win32api. This is
a non-standard module, but that that we include bundled in the
emsdk version python for windows.
Here we simply `import win32api` in those locations.
For win_get_file_properties there was exactly one caller that
was already wrapped in a catch all so I also removed a try/catch
from here.
If the second packet arrives before the first, expected_http_seq_num
will be -1, and the second packet will immediately be printed. Then, the
first packet arrives, printing after the second, causing the output to
have shuffled lines.
* emrun: Set COOP,COEP and CORP headers
This enables emrun to serve pages by taking into account
the upcoming restrictions on Content Policy for Firefox 72.
In Firefox 71, we currently need to set these flags to test the
upcoming feature:
browser.tabs.remote.useCORP
browser.tabs.remote.useCrossOriginOpenerPolicy
browser.tabs.remote.useCrossOriginEmbedderPolicy
dom.postMessage.sharedArrayBuffer.withCOOP_COEP
* fixup: remove semicolons
* Update emrun to latest version, with better browser process detection for multiprocess browsers.
* flake
* Fix emrun stdout posting on localhost
* Fix test_zzz_emrun to work on Firefox, and clean up after the browser process when done
* xxx test
* Account also for --profile in EMTEST_BROWSER
* Update comments, also fix failure behavior if no psutil is available
* Improve readability
If the browser process got detached, don't change behavior depending on whether we received messages or not, as that can be racy (depends if the messages managed to reach us in time or not). Instead, do the simple and robust behavior of continuing as if --serve_after_close was passed in.
Should help with #8495 (but unclear if it fixes it or not).
These do not fix all the issues that lead to random test failures, but they do fix at least two:
* Send a sync message before doing window.close. Otherwise, the close and the message may race (e.g., the close may happen before the message is sent from the browser). In that case, we don't get the exit code, and exit with 0, which makes the test fail.
* Be careful with the initial ping ("pageload" message) to the server - the server may not be up yet, and if not, the xhr will throw immediately. Keep trying until that succeeds.
Added --no_private_browsing argument to emrun to allow running tests which require features which are disabled in private browsing modes (for example, indexeddb).
Hello,
This is a sanitization patch for Python sources. Those DeprecationWarnings are already converted to SyntaxWarning in Python 3.8 and will become SyntaxError in Python 4.0.
Signed-off-by: Mickaël Schoentgen contact@tiger-222.fr