mirror of
https://github.com/allankoechke/pywebview.git
synced 2026-11-30 10:58:50 +00:00
* Update change_url.md * Update api.md * Update installation.md * Add Google Analytics * Fix installation * 2.4 info * [Docs] add information about window.pywebview availability * Update debuggig info about QTWebEngine * [Docs] Add information about app architecture * Update cef.md * [CEF] Fix JS logic not persisting after navigating to another page * #169 Frameless window (#313) * Merge PR #177: [Cocoa] Implement frameless windows * [All] Add skeleton for `frameless` parameter * [Cocoa] Add `frameless` kwarg to remove the window frame. - Implement a DragBar class to enable dragging the webview - Make the drag bar stick to the top and autoresize to the width of the view. * [WinForms] Implement frameless window + easy drag * Merge PR #177: [Cocoa] Implement frameless windows * [All] Add skeleton for `frameless` parameter * [Cocoa] Add `frameless` kwarg to remove the window frame. - Implement a DragBar class to enable dragging the webview - Make the drag bar stick to the top and autoresize to the width of the view. * [WinForms] Implement frameless window + easy drag * [GTK] partial implementation of frameless window * [QT] Partial implementation of frameless window * [QT] implement easy drag * [Cocoa] Hide standard buttons and make the entire window draggable * [GTK] implement easy move * Add frameless tests * Remove unused parameter * [Cocoa] Implement free drag * Revert WebBrowserInterops * Code cleanup * Update interop DLLs * Fix interop dll * Update docs; Fix tests * Add example * Update examples * [CEF]: Implement support for pyinstaller one-file mode * [CEF] Fix typo * [All] Change api_call timeout to 15 seconds * Update setup.py * [QT] Simplify QT installation * New API Cocoa implementation Revamped tests and examples * Fix web engine force setting * Rename destroy_window to destroy * Update documentation * Add documentation for 2.4 * Refactor project structure * [GTK] New API support * Rename confirm_quit to confirm_close Split lifecycle events to shown and loaded * [GTK] Implement new API Fix tests * [QT] New API implementation * Remove multiprocessing * [Windows/CEF] New API implementation * Implement CSRF token [All] Implement get_element * Update Flask app example * Rename get_element to get_elements. Bug fixes. * [GTK] Implement propert JS-Python bridge for WebKit2 >2.2 * Update documentation * [Windows/CEF] New API implementation * Add token test * [Winforms] Fix js api initialization * [Cocoa] Fix events * Debug: print webkit version * [GTK] Check for old webkit * [GTK] Fix event issues * Catch notimlementederror in tests * Update travis conf with qt from pip * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * [Windows] Preliminary implementation of EdgeHTML based on PR from @HeavenVolkoff * [docs] Add information about EdgeHTML * EdgeHTML WIP * Remove windows.web import * EdgeHTML improvements. Fix MSHTML evaluate_js * [Docs] Add information about renderer limitations * [EdgeHTML] Fix bugs and tests * Remove window from windows list after it is destroyed * Fix window object deletion after window is closed via GUI * [Docs] Add information about renderer codes * Refactor and fix JS API Remove multiprocessing example [MSHTML] Add console.log debug support * [Travis] Change conf * [WinForms] Fix fullscreen * Fix dll installation * [Windows] Fix DLL bundling * Update changelog * [CEF]: Fix JS API * Update changelog * Built-in HTTP server implementation * Add http server test * Add http server testcd * Add http server testcd * [EdgeHTML] allow localhost urls * Add video example * Bug fixing * [Cocoa] Remove media prefs * Update .travis.yml * Update .travis.yml * Update .travis.yml * [Travis] Disable QT 5.12 builds * Update html_load.md
89 lines
2.2 KiB
Python
Executable File
89 lines
2.2 KiB
Python
Executable File
import threading
|
|
import time
|
|
import os
|
|
import sys
|
|
import logging
|
|
import traceback
|
|
import pytest
|
|
from multiprocessing import Process, Queue
|
|
|
|
logger = logging.getLogger('pywebview')
|
|
|
|
|
|
def run_test(webview, window, thread_func=None, param=None, start_args={}, no_destroy=False, destroy_delay=0):
|
|
__tracebackhide__ = True
|
|
try:
|
|
queue = Queue()
|
|
|
|
time.sleep(2)
|
|
_create_window(webview, window, thread_func, queue, param, start_args, no_destroy, destroy_delay)
|
|
except Exception as e:
|
|
pytest.fail(e)
|
|
|
|
|
|
def assert_js(window, func_name, expected_result):
|
|
execute_func = 'window.pywebview.api.{0}()'.format(func_name)
|
|
check_func = 'window.pywebview._returnValues["{0}"].value'.format(func_name)
|
|
|
|
window.evaluate_js(execute_func)
|
|
|
|
result = window.evaluate_js(check_func)
|
|
counter, MAX = 0, 50
|
|
|
|
while result is None:
|
|
if counter == MAX:
|
|
raise AssertionError('assert_js timeout')
|
|
else:
|
|
counter += 1
|
|
time.sleep(0.1)
|
|
result = window.evaluate_js(check_func)
|
|
|
|
assert expected_result == result
|
|
|
|
|
|
def _create_window(webview, window, thread_func, queue, thread_param, start_args, no_destroy, destroy_delay):
|
|
|
|
def thread():
|
|
try:
|
|
if thread_func:
|
|
thread_func(window)
|
|
|
|
destroy_event.set()
|
|
except Exception as e:
|
|
logger.exception(e, exc_info=True)
|
|
queue.put(traceback.format_exc())
|
|
destroy_event.set()
|
|
|
|
if not no_destroy:
|
|
args = (thread_param,) if thread_param else ()
|
|
destroy_event = _destroy_window(webview, window, destroy_delay)
|
|
|
|
t = threading.Thread(target=thread)
|
|
t.start()
|
|
webview.start(**start_args)
|
|
|
|
|
|
def get_test_name():
|
|
return os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]
|
|
|
|
|
|
def _destroy_window(webview, window, delay):
|
|
def stop():
|
|
event.wait()
|
|
time.sleep(delay)
|
|
window.destroy()
|
|
|
|
if sys.platform == 'darwin':
|
|
from .util_cocoa import mouseMoveRelative
|
|
time.sleep(1)
|
|
mouseMoveRelative(1, 1)
|
|
|
|
event = threading.Event()
|
|
event.clear()
|
|
t = threading.Thread(target=stop)
|
|
t.start()
|
|
|
|
return event
|
|
|
|
|