mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
wombat: - I: function overrides applied by wombat now better appear to be the original new function name same as originals when possible - I: WombatLocation now looks and behaves more like the original Location interface - I: The custom storage class now looks and behaves more like the original Storage - I: SVG image rewriting has been improved: both the href and xlink:href deprecated since SVG2 now rewritten always - I: document.open now handles the case of creation of a new window - I: Request object rewriting of the readonly href property is now correctly handled - I: EventTarget.addEventListener, removeEventListener overrides now preserve the original this argument of the wrapped listener - A: document.close override to ensure wombat is initialized after write or writeln usage - A: reconstruction of <doctype...> in rewriteHTMLComplete IFF it was included in the original string of HTML - A: document.body setter override to ensure rewriting of the new body or frameset - A: Attr.[value, nodeValue, textContent] added setter override to perform URL rewrites - A: SVGElements rewriting of the filter, style, xlink:href, href, and src attributes - A: HTMLTrackElement rewriting of the src attribute of the - A: HTMLQuoteElement and HTMLModElement rewriting of the cite attribute - A: Worklet.addModule: Loads JS module specified by a URL. - A: HTMLHyperlinkElementUtils overrides to the areaelement - A: ShadowRootoverrides to: innerHTML even though inherites from DocumentFragement and Node it still has innerHTML getter setter. - A: ShadowRoot, Element, DocumentFragment append, prepend: adds strings of HTML or a new Node inherited from ParentNode - A: StylePropertyMap override: New way to access and set CSS properties. - A: Response.redirecthttps rewriting of the URL argument. - A: UIEvent, MouseEvent, TouchEvent, KeyboardEvent, WheelEvent, InputEvent, and CompositionEven constructor and init{even-name} overrides in order to ensure that wombats JS Proxy usage does not affect their defined behaviors - A: XSLTProcessor override to ensure its usage is not affected by wombats JS Proxy usage. - A: navigator.unregisterProtocolHandler: Same override as existing navigator.registerProtocolHandler but from the inverse operation - A: PresentationRequest: Constructor takes a URL or an array of URLs. - A: EventSource and WebSocket override in order to ensure that they do not cause live leaks - A: overrides for the child node interface - Fix: autofetch worker creatation of the backing worker when it is operating within an execution context with a null origin tests: - A: 559 tests specific to wombat and client side rewritting pywb: - Fix: a few broken tests due to iana.org requiring a user agent in its requests rewrite: - introduced a new JSWorkerRewriter class in order to support rewriting via wombat workers in the context of all supported worker variants via - ensured rewriter app correctly sets the static prefix ci: - Modified travis.yml to specifically enumerate jobs documentation: - Documented new wombat, wombat proxy moded, wombat workers auto-fetch: - switched to mutation observer when in proxy mode so that the behaviors can operate in tandem with the autofetcher
115 lines
4.0 KiB
Python
115 lines
4.0 KiB
Python
from gevent import monkey; monkey.patch_all(thread=False)
|
|
|
|
import pytest
|
|
import webtest
|
|
|
|
from pywb.warcserver.test.testutils import BaseTestClass, TempDirTests
|
|
from pywb.manager.manager import main, CollectionsManager
|
|
|
|
from pywb.apps.frontendapp import FrontEndApp
|
|
import os
|
|
|
|
|
|
@pytest.fixture(params=['mp_', ''], ids=['frame', 'non-frame'])
|
|
def fmod(request):
|
|
return request.param
|
|
|
|
|
|
@pytest.fixture(params=['mp_', ''], ids=['frame', 'non-frame'])
|
|
def fmod_sl(request):
|
|
return request.param + '/' if request.param else ''
|
|
|
|
|
|
# ============================================================================
|
|
class BaseConfigTest(BaseTestClass):
|
|
lint_app = True
|
|
extra_headers = {
|
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36'
|
|
}
|
|
|
|
@classmethod
|
|
def get_test_app(cls, config_file, custom_config=None):
|
|
config_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), config_file)
|
|
app = FrontEndApp(config_file=config_file, custom_config=custom_config)
|
|
return app, webtest.TestApp(app, lint=cls.lint_app)
|
|
|
|
@classmethod
|
|
def setup_class(cls, config_file, include_non_frame=True, custom_config=None):
|
|
super(BaseConfigTest, cls).setup_class()
|
|
cls.app, cls.testapp = cls.get_test_app(config_file, custom_config)
|
|
|
|
if include_non_frame:
|
|
custom_config = custom_config or {}
|
|
custom_config['framed_replay'] = False
|
|
cls.app_non_frame, cls.testapp_non_frame = cls.get_test_app(config_file,
|
|
custom_config)
|
|
|
|
@classmethod
|
|
def teardown_class(cls):
|
|
if cls.app.recorder:
|
|
cls.app.recorder.writer.close()
|
|
|
|
if cls.app_non_frame.recorder:
|
|
cls.app_non_frame.recorder.writer.close()
|
|
|
|
super(BaseConfigTest, cls).teardown_class()
|
|
|
|
def _assert_basic_html(self, resp):
|
|
assert resp.status_int == 200
|
|
assert resp.content_type == 'text/html'
|
|
assert resp.content_length > 0
|
|
|
|
def _assert_basic_text(self, resp):
|
|
assert resp.status_int == 200
|
|
assert resp.content_type == 'text/plain'
|
|
assert resp.content_length > 0
|
|
|
|
def get(self, url, fmod, *args, **kwargs):
|
|
self.__ensure_headers(kwargs)
|
|
app = self.testapp if fmod else self.testapp_non_frame
|
|
return app.get(url.format(fmod), *args, **kwargs)
|
|
|
|
def post(self, url, fmod, *args, **kwargs):
|
|
self.__ensure_headers(kwargs)
|
|
app = self.testapp if fmod else self.testapp_non_frame
|
|
return app.post(url.format(fmod), *args, **kwargs)
|
|
|
|
def post_json(self, url, fmod, *args, **kwargs):
|
|
self.__ensure_headers(kwargs)
|
|
app = self.testapp if fmod else self.testapp_non_frame
|
|
return app.post_json(url.format(fmod), *args, **kwargs)
|
|
|
|
def head(self, url, fmod, *args, **kwargs):
|
|
self.__ensure_headers(kwargs)
|
|
app = self.testapp if fmod else self.testapp_non_frame
|
|
return app.head(url.format(fmod), *args, **kwargs)
|
|
|
|
def __ensure_headers(self, kwargs):
|
|
if 'headers' in kwargs:
|
|
headers = kwargs.get('headers')
|
|
else:
|
|
headers = kwargs['headers'] = {}
|
|
|
|
if isinstance(headers, dict) and 'User-Agent' not in headers:
|
|
headers['User-Agent'] = self.extra_headers['User-Agent']
|
|
|
|
|
|
#=============================================================================
|
|
class CollsDirMixin(TempDirTests):
|
|
COLLS_DIR = '_test_colls'
|
|
|
|
@classmethod
|
|
def setup_class(cls, *args, **kwargs):
|
|
super(CollsDirMixin, cls).setup_class(*args, **kwargs)
|
|
cls.orig_cwd = os.getcwd()
|
|
cls.root_dir = os.path.realpath(cls.root_dir)
|
|
os.chdir(cls.root_dir)
|
|
cls.orig_collections = CollectionsManager.COLLS_DIR
|
|
CollectionsManager.COLLS_DIR = cls.COLLS_DIR
|
|
|
|
@classmethod
|
|
def teardown_class(cls):
|
|
os.chdir(cls.orig_cwd)
|
|
CollectionsManager.COLLS_DIR = cls.orig_collections
|
|
super(CollsDirMixin, cls).teardown_class()
|