PyChromeDevTools
PyChromeDevTools copied to clipboard
Some questions about --remote-allow-origins and how I solved it
I often use PyChromeDevTools to debug Android Webview pages, which is an excellent open source library. Recently, I discovered that due to the upgrade of the Android Webview kernel, PyChromeDevTools cannot connect to Android Webview normally because of the security policy --remote-allow-origins. However, I couldn't specify Android to use this command line parameter to start Webview, and encountered a similar error: https://github.com/marty90/PyChromeDevTools/issues/28.
After a long period of research and attempts, I think PyChromeDevTools needs to be optimized:
In the PyChromeDevTools source code _init_.py, lines 60, 67, and 71,
websocket.create_connection(wsurl)
should be changed to
websocket.create_connection(wsurl, suppress_origin=True)
.
Now let me explain, the modified code blocks the Origin header in the first http connection for WebSocket connection. Chromium does not seem to be restricted by the parameter --remote-allow-origins when the Origin header does not exist.
After this modification, my Android Webview can use PyChromeDevTools to restore normal connection. The above is my experience sharing, I hope it can help people in need:)
Hi,
that's a useful feature, and I added it.
Now, if you use version 1.0.3 you can set suppress_origin
in the ChromeInterface()
constructor to achieve this goal,