def test_base(self): w = WebviewWidget() w.evalJS('document.write("foo");') SVG = '<svg xmlns:dc="...">asd</svg>' w.onloadJS('''document.write('{}');'''.format(SVG)) w.setUrl(SOME_URL) svg = self.process_events(lambda: w.svg()) self.assertEqual(svg, SVG) self.assertEqual( w.html(), '<html><head></head><body>foo<svg xmlns:dc="...">asd</svg></body></html>')
def test_base(self): w = WebviewWidget() w.evalJS('document.write("foo");') SVG = '<svg xmlns:dc="...">asd</svg>' w.onloadJS('''document.write('{}');'''.format(SVG)) w.setUrl(SOME_URL) svg = self.process_events(lambda: w.svg()) self.assertEqual(svg, SVG) self.assertEqual( w.html(), '<html><head></head><body>foo<svg xmlns:dc="...">asd</svg></body></html>' )
def test_base(self): w = WebviewWidget() w.evalJS('document.write("foo");') SVG = '<svg xmlns:dc="...">asd</svg>' w.onloadJS('''document.write('{}');'''.format(SVG)) w.setUrl(SOME_URL) svg = None while svg is None: try: svg = w.svg() break except ValueError: qApp.processEvents() self.assertEqual(svg, SVG) self.assertEqual( w.html(), '<html><head></head><body>foo<svg xmlns:dc="...">asd</svg></body></html>')
def test_base(self): w = WebviewWidget() w.evalJS('document.write("foo");') SVG = '<svg xmlns:dc="...">asd</svg>' w.onloadJS('''document.write('{}');'''.format(SVG)) w.setUrl(SOME_URL) svg = self.process_events(lambda: w.svg()) self.assertEqual(svg, SVG) self.process_events(until=lambda: 'foo' in w.html()) html = '<svg xmlns:dc="...">asd</svg>' self.assertEqual( w.html(), '<html><head></head><body>{}</body></html>'.format( # WebKit evaluates first document.write first, whereas # WebEngine evaluates onloadJS first 'foo' + html if HAVE_WEBKIT else html + 'foo'))
def test_base(self): w = WebviewWidget() w.evalJS('document.write("foo");') SVG = '<svg xmlns:dc="...">asd</svg>' w.onloadJS('''document.write('{}');'''.format(SVG)) w.setUrl(SOME_URL) svg = self.process_events(lambda: w.svg()) self.assertEqual(svg, SVG) self.process_events(until=lambda: 'foo' in w.html()) html = '<svg xmlns:dc="...">asd</svg>' self.assertEqual( w.html(), '<html><head></head><body>{}</body></html>'.format( # WebKit evaluates first document.write first, whereas # WebEngine evaluates onloadJS first 'foo' + html if HAVE_WEBKIT else html + 'foo' ))