Fix inserting text with QtWebEngine

The insertText event doesn't seem to be available with newer Chromium releases,
which means this broke (probably with Qt 5.7.1).

Fixes #2183
Fixes #2217
This commit is contained in:
Florian Bruhin 2017-02-06 08:05:21 +01:00
parent 5e58764326
commit 348a50ad69
5 changed files with 3 additions and 14 deletions

View File

@ -20,7 +20,6 @@ markers =
qtwebengine_flaky: Tests which are flaky (and currently skipped) with QtWebEngine
qtwebengine_osx_xfail: Tests which fail on OS X with QtWebEngine
js_prompt: Tests needing to display a javascript prompt
issue2183: https://github.com/qutebrowser/qutebrowser/issues/2183
this: Used to mark tests during development
qt_log_level_fail = WARNING
qt_log_ignore =

View File

@ -153,9 +153,8 @@ window._qutebrowser.webelem = (function() {
funcs.insert_text = function(id, text) {
var elem = elements[id];
var event = document.createEvent("TextEvent");
event.initTextEvent("textInput", true, true, null, text);
elem.dispatchEvent(event);
elem.focus();
document.execCommand("insertText", false, text);
};
funcs.element_at_pos = function(x, y) {

View File

@ -130,11 +130,6 @@ def pytest_collection_modifyitems(config, items):
item.add_marker(pytest.mark.skipif(
PYQT_VERSION <= js_prompt_pyqt_version,
reason='JS prompts are not supported with this PyQt version'))
if item.get_marker('issue2183'):
item.add_marker(pytest.mark.xfail(
config.webengine and qtutils.version_check('5.7.1'),
reason='https://github.com/qutebrowser/qutebrowser/issues/'
'2183'))
if deselected:
deselected_items.append(item)

View File

@ -95,7 +95,6 @@ Feature: Opening external editors
And I run :click-element id qute-button
Then the javascript message "text: foobar" should be logged
@issue2183
Scenario: Spawning an editor with existing text
When I set up a fake editor replacing "foo" by "bar"
And I open data/editor.html

View File

@ -247,7 +247,6 @@ Feature: Yanking and pasting.
#### :insert-text
@issue2183
Scenario: Inserting text into an empty text field
When I set general -> log-javascript-console to info
And I open data/paste_primary.html
@ -257,7 +256,6 @@ Feature: Yanking and pasting.
# Compare
Then the javascript message "textarea contents: Hello world" should be logged
@issue2183
Scenario: Inserting text into an empty text field with javascript disabled
When I set general -> log-javascript-console to info
And I set content -> allow-javascript to false
@ -272,7 +270,6 @@ Feature: Yanking and pasting.
# Compare
Then the javascript message "textarea contents: Hello world" should be logged
@issue2183
Scenario: Inserting text into a text field at specific position
When I set general -> log-javascript-console to info
And I open data/paste_primary.html
@ -287,7 +284,7 @@ Feature: Yanking and pasting.
# Compare
Then the javascript message "textarea contents: onHello worlde two three four" should be logged
@qtwebengine_osx_xfail @issue2183
@qtwebengine_osx_xfail
Scenario: Inserting text into a text field with undo
When I set general -> log-javascript-console to info
And I open data/paste_primary.html