Commit Graph

98 Commits

Author SHA1 Message Date
Pierre Ossman 545442afc3 Merge branch 'keyboard' of https://github.com/CendioOssman/noVNC 2017-05-04 12:18:55 +02:00
Pierre Ossman d0703d1bde Simplify keyboard event API
No need for an object for three static fields.
2017-05-04 12:13:47 +02:00
Pierre Ossman 94f5cf05f3 Send keyboard events from single place
This makes it easier to handle any needed variations, like different
types of messages.
2017-05-04 12:13:47 +02:00
Samuel Mannehed 0613d18894 Fix panning test for high DPI devices
There is a drag-threshold in the panning code which the tests didn't
account for. This caused the tests to fail when window.devicePixelRatio
was higher than 1.
2017-04-21 15:23:18 +02:00
Pierre Ossman 524d67f283 Remove keysym names from keysymdef.js
They were incomplete and turned off in most cases so they served
little use besides adding complexity.
2017-03-24 11:16:53 +01:00
Solly Ross dfae3209eb Update tests to work with new structure
This updates the tests to work with the new structure, and removes the
old `utils/run_from_console.js` files in favor of just using Karma
directly.  The Karma debug page now displays the normal mocha HTML, so
we can use that instead of the HTML generation functionality of the old
test runner.

Note that PhantomJS does not work at the moment (PhantomJS 1.5 should
make it possible to test on PhantomJS again).
2017-03-21 17:39:07 -04:00
Pierre Ossman 0ee5ca6ebe Fix tests after changing auth negotiation
PhantomJS has a very basic implementation of Uint8Array, so we
need to help it out a bit.
2017-02-13 15:00:32 +01:00
Samuel Mannehed c01b2f0259 Merge pull request #699 from CendioOssman/double
Display double buffering
2016-12-13 12:42:22 +01:00
Pierre Ossman 2ba767a7fe Use double buffering for the display
Do all rendering to a hidden canvas and then copy over the finished
frame to the visible canvas once everything is done. This simplifies
things and solves some bugs as we can retain a copy of the entire
frame buffer.
2016-12-09 09:20:50 +01:00
Pierre Ossman 02329ab19c Don't violate Display abstraction
Use the normal API as much as possible instead of poking around in
internals that might change.
2016-12-09 09:20:50 +01:00
Kyle Russell 1a50f6809f rfb: Allow port to be optionally appended to URI
Supports server configurations that might prefer wss:// connections
on the default port, then proxies them through the web server to the
VNC server.

This proxy configuration is helpful on servers using self-signed
certificates.  Accessing the https://host/vnc_auto.html page and
adding an exception for that host is sufficient to also satisfy the
wss://host/ request, unlike requests to wss://host:port/ which
may require an extra certificate exception.
2016-11-24 06:14:31 -06:00
Samuel Mannehed 67cd2072ab Allow specifying details when calling RFB._fail()
RFB's _fail function logs the error, disconnects the session and sets
disconnect_reason. The disconnect_reason is upon disconnection sent to
the user interface. It is thus not suitable for including error details
that aren't user friendly. The idea is that you will look in the
browser console for a full log with details of the error.
2016-11-10 15:17:37 +01:00
Samuel Mannehed b2e961d48d Ensure proper connection state transitions
Makes the state machine more rubust and clear.
2016-11-10 15:17:31 +01:00
Samuel Mannehed b45905ab86 Handle server-side disconnections
Don't handle socket-close events when connected as errors. You could
for example, in the VNC session run 'vncconfig -disconnect'.
2016-11-10 14:33:29 +01:00
Pierre Ossman 9535539bb2 Process entire WebSocket message at once
setTimeout() causes too much delay to be useful. Also, we
already handle all rects in a message at once, so this shouldn't
be too much of a change.
2016-10-24 14:42:08 +02:00
Samuel Mannehed 3bb12056b1 Remove unnecessary substates of disconnected
The states 'loaded', 'failed' and 'fatal' were all variations of the
'disconnected' state. Removing these states allows us to get rid of
many ugly workarounds and special cases. Error messages to the UI can
now instead be delivered via a new onDisconnected callback.
2016-10-01 01:34:25 +02:00
Samuel Mannehed c2a4d3ef86 Improve the connection state names
Names such as 'disconnect' and 'disconnected' are inconsistent in the
way that one describes an action and the other a state. The state that
was called 'normal' didn't fit in with the others because the other
names describe a connection state. The new names are: 'disconnecting',
'connecting' and 'connected'
2016-10-01 01:30:02 +02:00
Samuel Mannehed c00ee156b9 Separate out init state from page state
This makes the state machine simpler as we don't have to confuse
protocol states with visual states.
2016-10-01 01:30:02 +02:00
Samuel Mannehed 159c50c009 Clean up special state handling for 'failed' 2016-10-01 01:30:02 +02:00
Samuel Mannehed a7127fee73 Don't abuse state change function for messages
This doesn't even work anymore since we fixed it to ignore changes
to the current state. Add a separate callback for notifications
instead.
2016-10-01 01:29:44 +02:00
Samuel Mannehed 4cfd49c8c3 Don't change state to same state
The comment already stated as much, but the code was broken.
2016-10-01 00:02:56 +02:00
Samuel Mannehed 7d714b15f5 Remove special password state
We already have a callback mechanism for this, so let's use that.
Adds an optional parameter 'msg' to the callback.
Fixes vnc_auto.html (#646) which was broken after
4e0c36dda7
2016-10-01 00:02:47 +02:00
Lars Ole Hurlen 49aa5b81c7 Detect RealVNC's RFB 5.0 Protocol Version
The RFB protocol specifies a max version of 3.8, but RealVNC likes to
increment their version when they add new features.  RealVNC 5.3 sends
"005.000" as the version string, since they've extended their
implementation upon RFB v3.8.  We can detect that, and just tell them we
only speak 3.8, instead of barfing on "005.000" as an invalid version.
2016-09-16 17:33:46 -04:00
Solly Ross bd5340c7ee Move input-related files into core/input
This commit moves all the input-related files from `core/`
to `core/input/`, and renames a couple as relevant
(input.js --> input/devices.js, keyboard.js --> input/util.js).
2016-09-16 15:49:52 -04:00
Solly Ross 3949a09534 Don't modify Array prototype
This commit removes our modification of the Array prototype.
It wasn't actually used much in the main code, anyway, and it's a
bad practice to modify built-in prototypes.
2016-09-16 15:49:52 -04:00
Daniel Henrique Barboza 8f06673a25 QEMU RFB extension - rfb.js and input.js changes
In input.js, a new keyboard handler was added to deal exclusively
with the QEMU key event extension. '_onKeyPress()' signature
was changed to allow the same method to treat both cases.

The extension will only be enabled if the browser has support
for the KeyboardEvent.code property.

Changes in rfb.js:

- added a new extension code, QEMUExtendedKeyEvent, value -258.

- handleKeyPress now receives 'keyevent' instead of 'keysym' and
'down'. Both values are retrieved from keyevent as they were
in the previous signature. This method now can send QEMU RFB
extended key messages if the flag was set to 'true'.

- tests/test.rfb.js were changed folowing the onKeyPress() signature
change.

- added a new function to send the QEMU extended key message.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
2016-08-26 17:34:39 -03:00
samhed 76a86ff514 Add support for ContinuousUpdates
Instead of requesting frame buffer updates we can, if the server
supports it, continuously recieve frame buffer updates at a rate
determined by the server.

The server can use fencing messages and measure response times to
determine how often it will continue to send updates.
2016-08-26 11:04:19 +02:00
samhed 3df1326239 Add support for fences
We don't actually use these, but servers may require this for other
features.
2016-06-03 16:37:19 +02:00
samhed 37195e4b5e Lower level check for framebuffer update requests
Try to avoid using helper functions with complex logic when verifying
results as those helper functions are also something we want to verify.

Also add a test for a mix of clean and dirty areas specifically to make
sure that helper function behaves properly.
2016-06-03 16:35:59 +02:00
samhed 89d2837fa8 Always flush socket after each message
Make sure our messages go away right away, rather than having to
remember to call flush from the caller, or causing extra delays by
waiting for the send timer. This should result in a more responsive
system.
2016-06-03 16:32:28 +02:00
samhed cf0236de18 Fix typo in pointer event test 2016-06-03 16:31:12 +02:00
Samuel ae11605141 Split the setDesktopSize function (#618)
In order to follow the surrounding coding-standards, the
setDesktopSize client message is split from the public function which
now is called requestDesktopSize().
2016-06-02 22:37:52 +02:00
Samuel Mannehed 057cfc7cb4 Add missing parenthesis (#600) 2016-04-30 04:26:30 +02:00
Samuel Mannehed 12ae8b3d50 Respect the threshold in the viewdrag test (#600) 2016-04-30 04:08:34 +02:00
Solly Ross 9ff86fb718 Use Typed Arrays for the send queue
This commit converts the send queue to use typed arrays, and converts
message creation functions in 'rfb.js' to create messages directly into
the socket's send queue.  This commit also removes the separate mouse array,
which is no longer needed.
2015-08-06 14:47:03 -04:00
Solly Ross 38781d931e Use Typed Arrays for the Websock receive queue
**This commit removes Base64 (and Flash) support**

This commit converts websock.js to used Typed Arrays for the
receive queue (and tweaks rfb.js to ensure that it continues
to function, since only Firefox implements
`%TypedArray%.prototype.slice`).  Base64 support was removed
to simplify code paths, and pave the way for using Typed Arrays
for the send queue as well.

This provides two advantages: first, we allocate a buffer ahead
of time, meaning the browser doesn't have to do any work dynamically
increasing the receive queue size.  Secondly, we are now able to pass
around Typed Array Views (e.g. `Uint8Array`), which are lightweight, and
don't involve copying.

The downside is that we initially allocate more memory -- we currently
start out with 4 MiB, and then automatically double when it looks like
the amount unused is getting to small.

The commit also explicitly adds a check to the compacting logic that
avoids calling the copy functions if `_rQlen === _rQi`.
2015-08-06 14:47:03 -04:00
Solly Ross 6940936ffc WIP: Switch to Pako for zlib
This commit introduces an alternate implementation of the zlib
decompressor based on Pako (https://github.com/nodeca/pako).
2015-08-06 14:47:03 -04:00
samhed 798340b98d * Change name of ext_desktop_size to the proper ExtendedDesktopSize
* Added better error handling in ExtendedDesktopSize
* Added helper function to share code with DesktopSize
* Update test.rfb.js to only check for error handling if we were the
  ones requesting the resize
2015-03-05 14:56:47 +01:00
samhed 4dec490aae Support automatic resize [Part 4/4]: unit tests
* Added new tests for the setDesktopSize encoding
* Added new tests for the ExtendedDesktopSize encoding
2015-02-10 17:06:55 +01:00
samhed 636be753b2 Support automatic resize [Part 1/4]: display.js
* Split viewportChange into two functions, one for changing size and the other for changing position.
* Modified viewport code to be capable of changing to a bigger size in the context of a
  client-initiated resize.
* Made clearer distinctions between when viewport-clipping or not.
* Added public function for telling when viewport-clipping.
* Updated tests that were using viewportChange.
2015-02-06 16:54:14 +01:00
Jacob Swanner 155d78b399 Unregister event listeners from websock.
Prevents possible memory and event notification leaks when tearing down
connection and reestablishing a new one.
2015-01-08 15:25:55 -05:00
Solly Ross 4865278dee Fixed Erroneous HEXTILE test
The HEXTILE test which tested for a background tile followed
by an empty tile was only wide enough to actually test for one
tile, thus not actually testing the functionality.  It now actually
uses two tiles, thus actually testing the functionality.
2014-11-24 15:19:04 -05:00
Ramon de Klein 40ac6f0ab6 Don't draw "blank" HEXTILE tiles with random data
Previously, if a HEXTILE tiles was received with a subencoding
of 0x00, it would draw a rectangle using data from the render
queue, which would result in random colored blocks when using
the HEXTILE encoding.  This is the result of a miscopy during
the refactoring.  It now has the correct functionality according
to the RFB protocol specification, which is to draw a rectangle
with the last set background color.

Closes #411
2014-11-17 20:01:28 -05:00
Solly Ross fda40d8927 Fix broken tests from changing default screen size
Commit 795fca23dc changed the default
size from 640 to 240.  This broke a couple tests which depended on
the default size being 640.  Those tests have now been fixed.
2014-11-17 14:19:19 -05:00
Solly Ross 3b4fd003c2 Fixed broken mouse test in test.rfb.js
Because we use the XOR (`^`) operator, the button mask must be
set before a MouseUp event happens, otherwise we'll send a pointer
event like it was a MouseDown event.  The button mask was not set
in one of the tests, so the test was failing.
2014-09-19 15:14:34 -04:00
Solly Ross d02a99f0c8 Fixed Typo Causing MouseUp to not Register
There was a typo in one of the instances of the _buttonMask field
(it was written as _buttonMaks), causing MouseUp to never be sent.
This has been rectified, and the unit tests for the mouse handler
have been changed to check for explicitly sending mouseup and
mousedown.

Fixes #393
2014-09-19 14:18:45 -04:00
Solly Ross 2c9623b5a7 Fixed assertion collision issues
When run via karma, all the tests are loaded into the same page.
This was causing a collision in the 'displayed' assertion dealing
with using viewportLoc.

The assertions are now in their own file, pulled in by tests that
need them.  Additionally, several tests which only set fb_width
and fb_height were correct to set viewportLoc as well.

Closes #392

Also-Authored-By: Martin André (github: mandre)
2014-09-19 12:16:06 -04:00
Solly Ross b1dee94788 Cleanup: RFB Client
File: rfb.js (also websock.js)
Tests Added: True

Changes:
- De-Crockford-ified rfb.js
- Added methods to websock.js to skip bytes in the receive queue
2014-09-15 16:46:02 -04:00