Skip to content

www.chinese-tools.com - Keyboard handling works differently than on Chrome #19663

Open

Description

@birtles

URL: https://www.chinese-tools.com/tools/ime.html

Browser / Version: Firefox 64.0
Operating System: Linux
Tested Another Browser: Yes

Problem type: Something else
Description: Keyboard handling works differently
Steps to Reproduce:

  1. Type 'z' 'h' in the big white text box (it will be automatically focused)
  2. Press backspace twice
  3. Type 'z'

Notice that no 'z' appears in the upper right until you press 'z' a second time.

In Chrome, 'z' appears in the upper right.
Screenshot Description

Browser Configuration
  • mixed active content blocked: false
  • buildID: 20181011220118
  • tracking content blocked: false
  • hasTouchScreen: false
  • gfx.webrender.blob-images: true
  • gfx.webrender.all: false
  • mixed passive content blocked: false
  • layers.acceleration.force-enabled: false
  • gfx.webrender.enabled: false
  • image.mem.shared: true
  • channel: nightly

From webcompat.com with ❤️

Activity

  1. added this to the needstriage milestone on Oct 12, 2018
  2. birtles commented on Oct 12, 2018

    @birtles
    Author

    I'm mostly reporting this in case it overlaps with any of the key handling changes we are trying to make in Nightly at the moment.

  3. changed the title [-]www.chinese-tools.com - see bug description[/-] [+]www.chinese-tools.com - Keyboard handling works differently than on Chrome[/+] on Oct 15, 2018
  4. softvision-sergiulogigan commented on Oct 15, 2018

    @softvision-sergiulogigan

    I can confirm this, @birtles Thanks!

    I was able to reproduce on Windows 10 and Firefox nightly 64.
    Moving to Needsdiagnosis.

  5. added
    severity-important
    on Oct 16, 2018
  6. karlcow commented on Oct 17, 2018

    @karlcow
    Member

    reproducible on macos too.

    function ImeKeyPress(e) {
      if(!e) e=window.event;
      var key = e.which ? e.which : e.keyCode;
    
    	// pass keypress without processing it
    	if(passNextKeyPress) {
    		return (true);
    	}
    
      if (browser==2 || browser==3) {
        if (CancelKey) {
          CancelKey = false;
          return (false);
        }
      }
    
      if (e.ctrlKey) { return (true); }
    
      //==A-Z
      if ( key>=65 && key<=90 ) {
        if (IME.FullShape.checked) {
          SendStr(FullShape_BigAZ[key-65]);
          return (false);
        }
        return (true);
      }
    
      //==a-z
      if (key>=97 && key<=122) {
        if (IME.EnglishMode.checked) {
          if (IME.FullShape.checked) {
            SendStr( FullShape_SmallAZ[key-97] );
            return (false);
          }
          return (true);
        } else {
          s=IME.Comp.value;
          if (s.length<MAX) {
            IME.Comp.value+=AsciiStr[key-97];
            IME.Cand.value="";
            Grep(IME.Comp.value);
          }
          return (false);
        }
      }
    
      if (browser==2) {
        switch (key) {
        case 47: case 63:
          if (!IME.EnglishMode.checked || IME.FullShape.checked) {
            return (false);
          }
          break;
        }
      }
    
      return (true);
    }
  7. karlcow commented on Oct 17, 2018

    @karlcow
    Member

    browser is determined by

    function BodyOnLoad() {
      browser = 
        (navigator.appName.indexOf('Microsoft') != -1) ? 1 :
        (navigator.appName.indexOf('Netscape')  != -1) ? 2 :
        (navigator.appName.indexOf('Opera')     != -1) ? 3 :
        4;
      if(browser == 2 && navigator.userAgent.indexOf('Safari') != -1) browser =
    5;
    
      IME = {
        InputArea: document.getElementById("InputArea"),
        Comp:      document.getElementById("Comp"),
        Cand:      document.getElementById("Cand"),
    
        EnglishMode: document.getElementById("EnglishMode"),
        FullShape:   document.getElementById("FullShape"),
        AutoUp:      document.getElementById("AutoUp")
      }
      IME.InputArea.focus();
      
    }
  8. karlcow commented on Oct 17, 2018

    @karlcow
    Member

    So there is a detection about window.event
    This will be https://bugzilla.mozilla.org/show_bug.cgi?id=1479964

    But I think there's more to it.
    The full source is https://www.chinese-tools.com/jdd/public/ime/ime.js

    Here another area of the case which is changing behavior with regards to browser UA sniffing.

    function SendStr(s) {
      if (s=="") { return }
    
      switch (browser) {
      case 1: // IE
        var r=document.selection.createRange();
        r.text=s;
        r.select();
        break;
      case 2: // Gecko
        /*
           -simulate keypress
           *simulate scroll
           -change outputString
           -use createRange, setStart, setEnd
        */
    
        var obj = IME.InputArea;
        var selectionStart = obj.selectionStart;
        var selectionEnd = obj.selectionEnd;
        var oldScrollTop = obj.scrollTop;
        var oldScrollHeight = obj.scrollHeight;
        var oldLen = obj.value.length;
    
        obj.value = obj.value.substring(0, selectionStart) + s + obj.value.substring(selectionEnd);
        obj.selectionStart = obj.selectionEnd = selectionStart + s.length;
        if (obj.value.length == oldLen) {
          obj.scrollTop = obj.scrollHeight;
        } else if (obj.scrollHeight > oldScrollHeight) {
          obj.scrollTop = oldScrollTop + obj.scrollHeight - oldScrollHeight;
        } else {
          obj.scrollTop = oldScrollTop;
        }
        
        break;
      default:
        IME.InputArea.value += s;
      }
    }
  9. karlcow commented on Oct 17, 2018

    @karlcow
    Member

    if I fake the UA to be chrome, the site is not working at all. On the other hand if set the UA to be the iPad UA. Everything is working as expected.

  10. wisniewskit commented on Mar 7, 2019

    @wisniewskit
    Member

    Building what @karlcow found above, this is where they sniff the UA:

    function BodyOnLoad() {
      browser = 
        (navigator.appName.indexOf('Microsoft') != -1) ? 1 :
        (navigator.appName.indexOf('Netscape')  != -1) ? 2 :
        (navigator.appName.indexOf('Opera')     != -1) ? 3 :
        4;
      if(browser == 2 && navigator.userAgent.indexOf('Safari') != -1) browser =
    5;
    

    If I add "Safari" to the UA-string, then things start working correctly.

    However, mozregression tells me that it broke a looong time ago in Firefox 25 in this range, making this the likely cause.

    So for the site, the easiest fix is just to treat Firefox as they do Safari. If they want to be cute and support Firefox 24 and lower for fun, they can just add this line to the above checks (which is probably the easiest fix anyway):

    if (browser == 2 && [].find) browser = 5; // Gecko 25 changed key-handling and added Array.find
    

    But something tells me the site won't be being updated anymore. If that's the case, then perhaps a site-specific over-ride might be worthwhile (just adding Safari to the userAgent should suffice). For now, I'm going to leave this as needscontact just in case we can find a contact who is willing to update the site.

  11. self-assigned this
    on Mar 7, 2019
  12. added
    type-event-handling
    type-js
    on Mar 7, 2019
  13. added
    engine-gecko
    on Apr 30, 2019
  14. added
    os-linux
    on Nov 5, 2019
  15. softvision-oana-arbuzov commented on Nov 5, 2019

    @softvision-oana-arbuzov
    Member

    The issue is still reproducible on my side.

    Tested with:
    Browser / Version: Firefox Nightly 72.0a1 (2019-11-04)
    Operating System: Windows 10 Pro

  16. softvision-oana-arbuzov commented on Jul 29, 2022

    @softvision-oana-arbuzov
    Member

    This is still an issue.
    image

    Tested with:
    Browser / Version: Firefox Nightly 105.0a1 (2022-07-28)
    Operating System: Windows 10 Pro

    [inv_30/2022]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    browser-firefoxengine-geckoos-linuxpriority-normalseverity-importanttype-event-handlingtype-js

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions