Make console available in PAC files
This commit is contained in:
parent
a76329ee84
commit
1799b7926a
@ -54,6 +54,7 @@ Changed
|
||||
- Various small performance improvements for hints and the completion.
|
||||
- The Wayland check for QtWebEngine is now disabled on Qt >= 5.11.2, as those
|
||||
versions should work without any issues.
|
||||
- The JavaScript `console` object is now available in PAC files.
|
||||
|
||||
Fixed
|
||||
~~~~~
|
||||
|
@ -180,6 +180,8 @@ class PACResolver:
|
||||
"""
|
||||
self._engine = QJSEngine()
|
||||
|
||||
self._engine.installExtensions(QJSEngine.ConsoleExtension)
|
||||
|
||||
self._ctx = _PACContext(self._engine)
|
||||
self._engine.globalObject().setProperty(
|
||||
"PAC", self._engine.newQObject(self._ctx))
|
||||
|
@ -205,6 +205,20 @@ def test_secret_url(url, has_secret, from_file):
|
||||
res.resolve(QNetworkProxyQuery(QUrl(url)), from_file=from_file)
|
||||
|
||||
|
||||
def test_logging(qtlog):
|
||||
"""Make sure console.log() works for PAC files."""
|
||||
test_str = """
|
||||
function FindProxyForURL(domain, host) {
|
||||
console.log("logging test");
|
||||
return "DIRECT";
|
||||
}
|
||||
"""
|
||||
res = pac.PACResolver(test_str)
|
||||
res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
|
||||
assert len(qtlog.records) == 1
|
||||
assert qtlog.records[0].message == 'logging test'
|
||||
|
||||
|
||||
def fetcher_test(test_str):
|
||||
class PACHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
|
Loading…
Reference in New Issue
Block a user