-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SlimerJS not compatible with Firefox 60 : key support issues #694
Comments
Poked around a little bit and asked about it at #firefox IRC channel:
As a test, I copied the keycodes from https://searchfox.org/mozilla-central/source/devtools/client/shared/keycodes.js, then changed slQTKeyCodeToDOMCode.jsm:
That seemed to be the only error with FF 60. Copying them is probably not the best way to go but you be the judge. |
Perhaps convertQTKeyCode should simply accept window or the KeyboardEvent as a parameter, made a quick hack to validate that would work. All the calls to it are in webpage.js so obviously questionable whether the function should then remain in slQTKeyCodeToDOMCode.jsm at all, but at least this way you wouldn't need to maintain a separate key code mapping. |
@kaosko Nice work. I just saw this come up and came here to see if anyone had investigated yet. Any chance you'd be willing to share the update you made to |
Like I said, that was just a total hack. I basically made c a var and passed window to the function:
That's certainly not what you want to do in actual code. Several ways to go about it but right off the bat, I might just drop the whole QtKeys hashmap and refactor it all into one big switch/case statement. Had I been super convinced that's the best way, I would have already sent you a pull request. Happy to do it though if you agree that's the way to go. What's the significance of adding that 'k' in the key code? That wasn't too clear to me. |
Hi, Thank you for investigations. I'll will add the keycode.js or perhaps I will pass the window object. There are other issues related to keyEvent. For example they also dropped the nsIDOMWindowsUtils.sendKeyEvent() method, so webpage.sendEvent() does not work anymore. I will fix that.
Well, a switch/case statement in this case will be slower than the actual hashmap IMHO, as keys are indexed in the hashmap..
Nothing. I didn't like numbers as keys in a hashmap, but I admit this is stupid :-) For the record, convertQTKeyCode exists because in PhantomJS, key codes to give to webpage.sendEvent() were in fact QT key codes... |
/cc @masayuki-nakano who can recommend what to use instead of this (since he removed these interfaces) |
Unfortunately, it requires to access window.KeyboardEvent as above comments discussed. So, module needs to receive a window or KeyboardEvent object at least once. FYI: nsIDOMWindowsUtils.sendKeyEvent() was not good API since it was too stateless. I.e., even when some attributes should be overwritten with fixed values, it dispatched keyboard events with odd attribute values or odd keyboard event type. Now, it was replaced with nsITextInputProcessor. Perhaps, this out test API is a good example of how to use it: |
When running unit tests, for me it fails very early on with a syntax error in src/modules/addon-sdk/sdk/url.js about line 131. I can fix this trivially, I think. After that, the sendKeyEvent problem described above, dominates. |
I prepared this branch https://github.com/MarkR42/slimerjs/tree/firefox60 Which works for me in Firefox 60, however, it fails a lot of unit tests because of the sendKeyEvent problems described above. (I do not use sendKeyEvent in my applications) |
versions
Ubuntu 16.04.2 LTS
Steps to reproduce the issue
In application.ini, change
MaxVersion=60.*
Try to take a screenshot of any webpage with slimer.js. Add --debug=true
Actual results:
The last important lines with --debug=true:
JavaScript strict warning: resource://slimerjs/slQTKeyCodeToDOMCode.jsm, line 33: ReferenceError: reference to undefined property "nsIDOMKeyEvent"
Script Error: c is undefined
Stack:
-> resource://slimerjs/slQTKeyCodeToDOMCode.jsm: 36
-> resource://slimerjs/slQTKeyCodeToDOMCode.jsm: 36
-> resource://slimerjs/slimer-sdk/webpage.js: 15
Expected results:
Able to take a screenshot and operate normally.
The text was updated successfully, but these errors were encountered: