mirror of
https://github.com/allankoechke/pywebview.git
synced 2026-12-01 01:18:35 +00:00
* [GTK] WIP WebKit2 upgrade * [GTK] Implement getting js value via url change * [GTK] Remove inspect-web-view signal handler WebKit2 automatically shows the web inspector. * [GTK] add a js_result lock * [GTK] Implement document.title based JSON communication bridge
31 lines
576 B
Python
Executable File
31 lines
576 B
Python
Executable File
import webview
|
|
from .util import run_test, assert_js
|
|
|
|
|
|
def test_js_bridge():
|
|
run_test(main_func, js_bridge)
|
|
|
|
|
|
class Api:
|
|
def get_int(self, params):
|
|
return 5
|
|
|
|
def get_float(self, params):
|
|
return 3.141
|
|
|
|
def get_string(self, params):
|
|
return 'test'
|
|
|
|
|
|
def main_func():
|
|
api = Api()
|
|
webview.create_window('JSBridge test', js_api=api)
|
|
|
|
|
|
def js_bridge():
|
|
webview.load_html('<html><body>TEST</body></html>')
|
|
assert_js(webview, 'get_int', 5)
|
|
assert_js(webview, 'get_float', 3.141)
|
|
assert_js(webview, 'get_string', 'test')
|
|
|