From f17fe571df857c3580aee2750f278078c9de211c Mon Sep 17 00:00:00 2001 From: Mantary Date: Thu, 28 Jun 2018 16:41:06 +0900 Subject: [PATCH 1/2] Use keydown instead of keypress on Firefox (cherry pick from 2be873e3c708) This puts issue: #3383, PR: #3413 (Use keydown instead of keypress on Firefox) directly on top of bacc37cf9b3a, which is the last commit before fe08d2a1db5b merged #3268 (getLineHTMLForExport - Fixes #2486 but breaks plugins). This is necessary for showing that: - bacc37cf9b3a was passing client side tests on firefox Visit `http:///tests/frontend/` using firefox. - 2be873e3c708 forgot to update the client side tests. You cannot test it since that commit was mad on top of other changes, hence this graft - in this commit there are 20 failures with firefox: passes: 82 failures: 20 duration: 261.84s --- src/static/js/ace2_inner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 90cefa50..d7ec4326 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3708,8 +3708,8 @@ function Ace2Inner(){ return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice } var specialHandled = false; - var isTypeForSpecialKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); - var isTypeForCmdKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForSpecialKey = ((browser.msie || browser.safari || browser.chrome || browser.firefox) ? (type == "keydown") : (type == "keypress")); + var isTypeForCmdKey = ((browser.msie || browser.safari || browser.chrome || browser.firefox) ? (type == "keydown") : (type == "keypress")); var stopped = false; inCallStackIfNecessary("handleKeyEvent", function() From 4580537537817fb6f1f4d50927979eab987bdd2a Mon Sep 17 00:00:00 2001 From: muxator Date: Fri, 20 Jul 2018 23:58:47 +0200 Subject: [PATCH 2/2] tests: fix frontend tests on firefox These changes make the frontend tests send keydown instead of keypress in firefox, in accordance with #3413 (Use keydown instead of keypress on Firefox). The percentage of passing frontend in Firefox 61 on this revision is 100%. --- tests/frontend/specs/bold.js | 2 +- tests/frontend/specs/indentation.js | 4 ++-- tests/frontend/specs/italic.js | 2 +- tests/frontend/specs/ordered_list.js | 2 +- tests/frontend/specs/scroll.js | 2 +- tests/frontend/specs/select_formatting_buttons.js | 2 +- tests/frontend/specs/undo.js | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js index b54466e4..888eb660 100644 --- a/tests/frontend/specs/bold.js +++ b/tests/frontend/specs/bold.js @@ -44,7 +44,7 @@ describe("bold button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/indentation.js b/tests/frontend/specs/indentation.js index 9294cefb..dd12fc31 100644 --- a/tests/frontend/specs/indentation.js +++ b/tests/frontend/specs/indentation.js @@ -15,7 +15,7 @@ describe("indentation button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; @@ -325,7 +325,7 @@ describe("indentation button", function(){ function pressEnter(){ var inner$ = helper.padInner$; - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/italic.js b/tests/frontend/specs/italic.js index bf7f2bc6..cecbc180 100644 --- a/tests/frontend/specs/italic.js +++ b/tests/frontend/specs/italic.js @@ -44,7 +44,7 @@ describe("italic some text", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/ordered_list.js b/tests/frontend/specs/ordered_list.js index 57196fef..e7509e88 100644 --- a/tests/frontend/specs/ordered_list.js +++ b/tests/frontend/specs/ordered_list.js @@ -111,7 +111,7 @@ describe("assign ordered list", function(){ var triggerCtrlShiftShortcut = function(shortcutChar) { var inner$ = helper.padInner$; - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE) { // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE) { // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/scroll.js b/tests/frontend/specs/scroll.js index 096b06b6..94756b85 100644 --- a/tests/frontend/specs/scroll.js +++ b/tests/frontend/specs/scroll.js @@ -513,7 +513,7 @@ describe('scroll when focus line is out of viewport', function () { var pressKey = function(keyCode, shiftIsPressed){ var inner$ = helper.padInner$; var evtType; - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE evtType = 'keypress'; }else{ evtType = 'keydown'; diff --git a/tests/frontend/specs/select_formatting_buttons.js b/tests/frontend/specs/select_formatting_buttons.js index 5fb97600..b6ec6d0c 100644 --- a/tests/frontend/specs/select_formatting_buttons.js +++ b/tests/frontend/specs/select_formatting_buttons.js @@ -88,7 +88,7 @@ describe("select formatting buttons when selection has style applied", function( //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.modernIE){ // if it's IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/undo.js b/tests/frontend/specs/undo.js index b8b7c785..3644734f 100644 --- a/tests/frontend/specs/undo.js +++ b/tests/frontend/specs/undo.js @@ -44,11 +44,11 @@ describe("undo button", function(){ var modifiedValue = $firstTextElement.text(); // get the modified value expect(modifiedValue).not.to.be(originalValue); // expect the value to change - if(inner$(window)[0].bowser.firefox){ // if it's a mozilla browser - var evtType = "keypress"; - }else{ - var evtType = "keydown"; - } + /* + * ACHTUNG: this is the only place in the test codebase in which a keydown + * is sent for IE. Everywhere else IE uses keypress. + */ + var evtType = "keydown"; var e = inner$.Event(evtType); e.ctrlKey = true; // Control key