Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/181174
Change subject: ve.ce: Remove hacks from Surface#onDocumentKeyPress, add
related IME test
......................................................................
ve.ce: Remove hacks from Surface#onDocumentKeyPress, add related IME test
We had a hack in place to filter out non-character keys, to prevent
unexpected content deletion (caused by pawning) when selection is not
collapsed and the user presses, for example, the Home key (Firefox
fires 'keypress' for it). Pawning is gone since 40101e42 and this
seems no longer needed.
Added an IME test for the described situation.
Bug: T69367
Change-Id: I277b92b9d11bfda01a92f3e615ca674feb920a1a
---
M build/modules.json
M src/ce/ve.ce.Surface.js
A tests/ce/imetests/home-firefox-win-none.js
M tests/index.html
4 files changed, 60 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/74/181174/1
diff --git a/build/modules.json b/build/modules.json
index 5596e02..dc9b3e9 100644
--- a/build/modules.json
+++ b/build/modules.json
@@ -474,6 +474,7 @@
"tests/ce/imetests/backspace-chromium-ubuntu-none.js",
"tests/ce/imetests/backspace-firefox-ubuntu-none.js",
"tests/ce/imetests/backspace-ie-win-none.js",
+ "tests/ce/imetests/home-firefox-win-none.js",
"tests/ce/imetests/input-chrome-win-chinese-traditional-handwriting.js",
"tests/ce/imetests/input-chrome-win-greek.js",
"tests/ce/imetests/input-chrome-win-polish.js",
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index ea0c317..0046dac 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1203,26 +1203,8 @@
/**
* Handle document key press events.
- *
- * @method
- * @param {jQuery.Event} e Key press event
*/
-ve.ce.Surface.prototype.onDocumentKeyPress = function ( e ) {
- // Filter out non-character keys. Doing this prevents:
- // * Unexpected content deletion when selection is not collapsed and
the user presses, for
- // example, the Home key (Firefox fires 'keypress' for it)
- // TODO: Should be covered with Selenium tests.
- if (
- // Catches most keys that don't produce output (charCode === 0,
thus no character)
- e.which === 0 || e.charCode === 0 ||
- // Opera 12 doesn't always adhere to that convention
- e.keyCode === OO.ui.Keys.TAB || e.keyCode === OO.ui.Keys.ESCAPE
||
- // Ignore all keypresses with Ctrl / Cmd modifier keys
- ve.ce.isShortcutKey( e )
- ) {
- return;
- }
-
+ve.ce.Surface.prototype.onDocumentKeyPress = function () {
this.handleInsertion();
};
diff --git a/tests/ce/imetests/home-firefox-win-none.js
b/tests/ce/imetests/home-firefox-win-none.js
new file mode 100644
index 0000000..899a63c
--- /dev/null
+++ b/tests/ce/imetests/home-firefox-win-none.js
@@ -0,0 +1,57 @@
+/*!
+ * VisualEditor IME "Home" key test for Firefox on Windows.
+ *
+ * @copyright 2011-2014 VisualEditor Team and others; see
http://ve.mit-license.org
+ */
+
+ve.ce.imetests.push( [ 'home-firefox-win-none', [
+ {"imeIdentifier":"none","userAgent":"Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","startDom":""},
+
{"seq":0,"time":12.242,"action":"sendEvent","args":["keydown",{"keyCode":65}]},
+
{"seq":1,"time":12.261,"action":"sendEvent","args":["keypress",{"keyCode":0}]},
+ {"seq":2,"time":12.264,"action":"changeText","args":["a"]},
+ {"seq":3,"time":12.264,"action":"changeSel","args":[1,1]},
+ {"seq":4,"time":12.264,"action":"sendEvent","args":["input",{}]},
+ {"seq":5,"time":12.292,"action":"endLoop","args":[]},
+
{"seq":6,"time":12.304,"action":"sendEvent","args":["keydown",{"keyCode":83}]},
+
{"seq":7,"time":12.308,"action":"sendEvent","args":["keypress",{"keyCode":0}]},
+ {"seq":8,"time":12.314,"action":"changeText","args":["as"]},
+ {"seq":9,"time":12.314,"action":"changeSel","args":[2,2]},
+ {"seq":10,"time":12.314,"action":"sendEvent","args":["input",{}]},
+ {"seq":11,"time":12.345,"action":"endLoop","args":[]},
+
{"seq":12,"time":12.431,"action":"sendEvent","args":["keyup",{"keyCode":65}]},
+ {"seq":13,"time":12.434,"action":"endLoop","args":[]},
+
{"seq":14,"time":12.447,"action":"sendEvent","args":["keydown",{"keyCode":68}]},
+
{"seq":15,"time":12.45,"action":"sendEvent","args":["keypress",{"keyCode":0}]},
+ {"seq":16,"time":12.452,"action":"changeText","args":["asd"]},
+ {"seq":17,"time":12.452,"action":"changeSel","args":[3,3]},
+ {"seq":18,"time":12.452,"action":"sendEvent","args":["input",{}]},
+ {"seq":19,"time":12.473,"action":"endLoop","args":[]},
+
{"seq":20,"time":12.487,"action":"sendEvent","args":["keyup",{"keyCode":83}]},
+ {"seq":21,"time":12.503,"action":"endLoop","args":[]},
+
{"seq":22,"time":12.573,"action":"sendEvent","args":["keyup",{"keyCode":68}]},
+ {"seq":23,"time":12.577,"action":"endLoop","args":[]},
+
{"seq":24,"time":15.106,"action":"sendEvent","args":["keydown",{"keyCode":37}]},
+
{"seq":25,"time":15.11,"action":"sendEvent","args":["keypress",{"keyCode":37}]},
+ {"seq":26,"time":15.113,"action":"changeSel","args":[2,2]},
+ {"seq":27,"time":15.113,"action":"endLoop","args":[]},
+
{"seq":28,"time":15.186,"action":"sendEvent","args":["keyup",{"keyCode":37}]},
+ {"seq":29,"time":15.19,"action":"endLoop","args":[]},
+
{"seq":30,"time":15.624,"action":"sendEvent","args":["keydown",{"keyCode":16}]},
+ {"seq":31,"time":15.63,"action":"endLoop","args":[]},
+
{"seq":32,"time":16.124,"action":"sendEvent","args":["keydown",{"keyCode":16}]},
+ {"seq":33,"time":16.129,"action":"endLoop","args":[]},
+
{"seq":34,"time":16.155,"action":"sendEvent","args":["keydown",{"keyCode":37}]},
+
{"seq":35,"time":16.16,"action":"sendEvent","args":["keypress",{"keyCode":37}]},
+ {"seq":36,"time":16.179,"action":"changeSel","args":[2,1]},
+ {"seq":37,"time":16.179,"action":"endLoop","args":[]},
+
{"seq":38,"time":16.223,"action":"sendEvent","args":["keyup",{"keyCode":37}]},
+ {"seq":39,"time":16.227,"action":"endLoop","args":[]},
+
{"seq":40,"time":16.443,"action":"sendEvent","args":["keyup",{"keyCode":16}]},
+ {"seq":41,"time":16.45,"action":"endLoop","args":[]},
+
{"seq":42,"time":18.332,"action":"sendEvent","args":["keydown",{"keyCode":36}]},
+
{"seq":43,"time":18.338,"action":"sendEvent","args":["keypress",{"keyCode":36}]},
+ {"seq":44,"time":18.346,"action":"changeSel","args":[0,0]},
+ {"seq":45,"time":18.346,"action":"endLoop","args":[]},
+
{"seq":46,"time":18.461,"action":"sendEvent","args":["keyup",{"keyCode":36}]},
+ {"seq":47,"time":18.466,"action":"endLoop","args":[]}
+] ] );
diff --git a/tests/index.html b/tests/index.html
index 05abd24..23a589a 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -370,6 +370,7 @@
<script
src="../tests/ce/imetests/backspace-chromium-ubuntu-none.js"></script>
<script
src="../tests/ce/imetests/backspace-firefox-ubuntu-none.js"></script>
<script
src="../tests/ce/imetests/backspace-ie-win-none.js"></script>
+ <script
src="../tests/ce/imetests/home-firefox-win-none.js"></script>
<script
src="../tests/ce/imetests/input-chrome-win-chinese-traditional-handwriting.js"></script>
<script
src="../tests/ce/imetests/input-chrome-win-greek.js"></script>
<script
src="../tests/ce/imetests/input-chrome-win-polish.js"></script>
--
To view, visit https://gerrit.wikimedia.org/r/181174
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I277b92b9d11bfda01a92f3e615ca674feb920a1a
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits