Commit Graph

301 Commits

Author SHA1 Message Date
Samuel Mannehed afb621d577 Add missing semicolon 2017-05-13 01:56:35 +02:00
Samuel Mannehed c464f47e96 Remove trailing whitespace 2017-05-13 01:56:24 +02:00
Pierre Ossman 26586b9ddf Remove colour map support
It was broken and unused. Remove it so we can simplify the code.
2017-05-04 15:13:33 +02:00
Pierre Ossman fb7e99e84b Remove browser engine detection
It is out of date and not used anyway.
2017-05-04 14:52:05 +02:00
Pierre Ossman 099eb856cf Skip some keyboard tests on IE and Edge
IE and Edge has some broken behaviour for keyboard events that
prevent the standard tests from running properly.
2017-05-04 13:26:39 +02:00
Pierre Ossman 545442afc3 Merge branch 'keyboard' of https://github.com/CendioOssman/noVNC 2017-05-04 12:18:55 +02:00
Pierre Ossman 9782d4a324 Use KeyboardEvent.key too look up keysyms
And emulate it on browsers where it is missing or incorrect. This
makes the code more future oriented as it primarily uses the standardised
fields.
2017-05-04 12:13:48 +02:00
Pierre Ossman bf43c26319 Clean up AltGraph handling
It doesn't need to be this general as the issue is mostly about
Windows. Also use the same modifier shuffle that RealVNC and
TigerVNC uses to get macOS working well.
2017-05-04 12:13:48 +02:00
Pierre Ossman ae82053366 Simplify pressed key handling
Prefer avoid having the server simulate multiple key presses by
refusing to use multiple keysyms for the same physical key.
2017-05-04 12:13:47 +02:00
Pierre Ossman 9fce233d51 Simplify handling of keypress
Use a dedicated variable to track a two stage key rather than
piggy-backing on the key state array.
2017-05-04 12:13:47 +02:00
Pierre Ossman f7363fd26d Move keyboard handling in to Keyboard class
Replace the multi stage pipeline system with something simpler.
That level of abstraction is not needed.
2017-05-04 12:13:47 +02:00
Pierre Ossman 9e6f71cb75 Remove modifier synchronisation
The fields provided cannot tell us if it is the left or right
version of the key that's pressed, so they are inherently unreliable.
It is also not a huge problem in practice as we'll get in sync on
the next press or release of the modifier.
2017-05-04 12:13:47 +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
Pierre Ossman f714f7deae Improve lookup of special keys
Look up keys that are independent of layout and state first,
followed by keys that are only mild variations in layouts.
This is more robust as there might be multiple physical keys
generating the same symbols, and Keysyms don't map directly to
Unicode in all cases.

At the same time switch over to using the modern, standardised
'code' field for lookup.
2017-05-04 12:13:47 +02:00
Pierre Ossman bfa1b237b9 Improve character keysym lookup
Use the more modern 'key' field, and remove some legacy fallbacks
that are no longer required. This also removes the "stall" mechanism
as it is not needed with current browsers.
2017-05-04 12:13:47 +02:00
Pierre Ossman 80cb8ffddd Use standard DOM identifiers for physical keys 2017-05-04 12:13:45 +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 a5c8a755e8 Hide internal keyboard functions
These may change and are not part of a stable API.

This also reindents the object functions to make sure they can
access private functions.
2017-03-24 11:53:16 +01:00
Pierre Ossman 0a865e15ff Remove character substitution
We can handle any Unicode codepoint now, so stop replacing symbols.
2017-03-24 11:35:36 +01:00
Pierre Ossman 278a5e7fbd Simplify keysymdef.js
Some Unicode to Keysym mappings can be computed and can therefore
be left out of the huge lookup table.
2017-03-24 11:31:38 +01: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 d6c17390f0 Make vnc_playback.html functional once more
This commit makes vnc_playback.html functional once more, and completely
refactors tests/playback.js to make it usable in other scenarios.

In order for vnc_playback.js to properly load playback files now, they
must `export` their variables.
2017-03-21 17:39:07 -04: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
Samuel Mannehed 280676c7e9 Properly encapsulate the scale in Display
Other parts of the code shouldn't have to care about this. Let Display
convert between canvas coordinates and framebuffer coordinates.
2017-02-16 14:00:39 +01: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
Pierre Ossman 0ae5b50a0e Expect console.debug(), not console.log(), in test
We use the more specific function now, even though it is usually an
alias.
2017-02-07 16:44:16 +01:00
Pierre Ossman ec7ba3eeae Remove binary protocol tests
We require standard adherence now, so remove tests that assume
the old system.
2017-02-03 17:16:02 +01:00
Pierre Ossman c4482d2de5 Remove buffer limit tests
We no longer limit writes to the socket.
2017-02-03 17:15:27 +01:00
Solly Ross 6048299a13 Use textContent instead of innerHTML
Previously, setting `innerHTML` was used to display the statuses.  These
could include content communicated from the remote VNC server, allowing
the remove VNC server to inject HTML into the noVNC page.

This commit switches all uses of `innerHTML` to use `textContent`, which
is not vulnerable to the HTML injection.
2017-01-12 14:47:36 -05:00
Samuel Mannehed c01b2f0259 Merge pull request #699 from CendioOssman/double
Display double buffering
2016-12-13 12:42:22 +01:00
Pierre Ossman adf345fdc4 Clean up viewport handling
Make sure the viewport is properly updated when necessary, on respects
given restrictions.
2016-12-09 09:20:50 +01:00
Pierre Ossman 3f781f2aa3 Remove max dimension handling
The viewport handling is now a lot clearer, so simply limit the size
of the viewport in the caller rather than having this extra layer
of checks.
2016-12-09 09:20:50 +01:00
Pierre Ossman e549ae074f Prevent access to sensitive display variables
These should not be directly accessed. Instead use drawing operation
and Display.resize().
2016-12-09 09:20:50 +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
Pierre Ossman 3181a032f8 Add test for Display.flush() 2016-12-09 09:20:50 +01:00
Pierre Ossman 74e390512d Remove blitStringImage() in favour of imageRect()
The latter is more generic and can easily be modified for other
mechanisms in the future.
2016-12-09 09:20:50 +01:00
Pierre Ossman 18e96092c3 Flush out rendering after each performance test
There might be operations pending in the render queue. Make sure
these are fully handled before we consider the test run over.
2016-12-09 09:20:39 +01:00
Pierre Ossman e12e2759b0 Run performance tests at full speed
setTimeout() is subject to delays, possible massive ones. As such it
is rather useless for performance sensitive code. Use the non-standard
setImmediate() API instead, emulating it on postMessage() when it
isn't available.
2016-12-06 16:14:11 +01:00
Pierre Ossman 6ec3af22ca Skip language tests on broken browsers
The hacks needed to run these tests require proper handling of
properties. Unfortunately IE and old versions of Chrome mess up,
so just skip the tests there.
2016-11-29 17:00:24 +01:00
Samuel Mannehed 77bc3a551b Fix translation util tests
We have to temporarily replace window.navigator due to the fact that
its property languages is read-only. The tests for the translation
utilities require different values of this property. The failing tests
were added in merge of PR #718 (in commit
f5bf2d84ef).
2016-11-28 16:14:55 +01:00
Samuel Mannehed ffa819eec1 Remove duplicate line 2016-11-28 16:11:03 +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
Pierre Ossman 3cdc603aa4 Use gettext .po files for translations
This allows the same workflow as most other projects for translations.
2016-11-17 20:42:08 +01: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
Samuel Mannehed 80b7dde665 Comment out skipped test
Forgot to comment out the code in commit
331ae15317
2016-11-10 14:28:40 +01:00
Samuel Mannehed 331ae15317 Skip keysyms.fromUnicode UCS-4 test
The browser requirements are too high for codePointAt at the moment
2016-11-10 14:02:22 +01:00
Samuel Mannehed e9ddbec5b1 Fix keysyms.fromUnicode() tests
Node.js doesn't handle characters high up in the unicode range
properly with charCodeAt(). Adding a new test for UCS-4 codepoints
using codePointAt() to cover this.
2016-11-10 11:57:45 +01:00
Samuel Mannehed b85a13de69 Merge pull request #689 from ossman/keysym
Don't send Unicode as keysym
2016-11-10 09:36:43 +01:00
Pierre Ossman 7632c576f0 Don't grab input when running performance tests 2016-10-25 16:17:07 +02:00
Pierre Ossman f9e26cdb32 Fix performance tests to follow new state API 2016-10-24 17:41:20 +02:00
Pierre Ossman bb6965f2e6 Wait for proper image load event
There is a specific event for when an image has finished loading,
so trigger on that rather than polling. The polling interval of
requestAnimationFrame() can also be very large.
2016-10-24 14:42:13 +02:00
Pierre Ossman 1578fa68ac Hide image handling in display object
The callers don't need to concern themselves with how images are
rendered, so hide the details behind the API. This also avoids
exposing the render queue.
2016-10-24 14:42:13 +02: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 a2495799af Merge pull request #677 from CendioOssman/perf
Support older base64 recordings
2016-10-20 12:47:21 +02:00
Pierre Ossman 115eedf69c Use Unicode keysym range as fallback
Not all Unicode codepoints have an equivalent named Keysym. But
there is a range in the Keysym namespace that can be used to map
any codepoint to.
2016-10-15 14:58:55 +02:00
samhed bea2b3fdfc New way of detecting touch
Moves detection to Util and fixes so that touch is properly detected on
MS Surface and touch emulation in Chrome.
2016-10-14 02:41:06 +02:00
Pierre Ossman d951b40956 Support older base64 recordings 2016-10-05 10:20:17 +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 b4ef49ea36 Remove unecessary event-related code from Util
The event-related wrapper functions in Util existed mainly for
backwards-compat.  However, all currently supported browsers
support the standard functions, so these wrappers are no longer needed.
2016-09-16 15:49:52 -04:00
Solly Ross e4fef7be2d Util shouldn't modify window object
This commits prevents Util from modifying the window object.

- `window.requestAnimFrame` was removed (no polyfill is needed anymore)
- the potential redefinition of `console.log` and friends was removed
  (all supported browsers have `console.xyz` defined anyway)
2016-09-16 15:49:52 -04:00
Solly Ross 9eca6889be Switch to PhantomJS 2.x for testing
This commit switches over to use PhantomJS 2.x, bringing in a whole host
of improvements (including `Function#bind`, so we can remove the
`Function#bind` shim in core/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
Solly Ross 72bdd06ea2 Clean up Util
This commit removes unused code from Util, and moves the script-loading
functionality to WebUtil.
2016-09-16 15:49:52 -04:00
Solly Ross a62b1b352a Clean up unused files in tests
There were quite a few old/irrelevant files in `tests/`.
This commit removes them.
2016-09-16 15:49:52 -04:00
Solly Ross ae510306b5 Enable noVNC to become Browserifiable
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
2016-09-16 15:49:51 -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
Daniel Henrique Barboza 99feba6ba8 QEMU RFB extension - new file xtscancodes.js
This new file contains the XT scancode mapping that
the extension will use in rfb.js file.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
2016-08-26 17:06:42 -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 b1538a0fa4 Fix 'sent' assertion
We were completely mishandling the length of the data. Make sure
we look at the length of the websocket rather than the websock object,
and also compare with the expected length.
2016-06-03 16:31:29 +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
Drew DeVault cf0623fffa Fix failing test
It only makes sense to send data on a websocket if the readyState is
equal to 1.
2016-04-30 02:28:45 +02:00
Solly Ross 4ee55e0126 Fixed vnc_perf.html
This commit updates vnc_perf.html so that it works with the current
version of noVNC.  It also introduces a utility to convert noVNC session
recordings recorded in base64-mode to binary-mode recordings, since noVNC
no longer supports base64-mode.

Fixes #479.
2016-01-06 13:32:05 -05:00
Solly Ross 0252c7f766 Remove remaining references to jsunzip.js
This commit removes remaining references to jsunzip.js,
which is no longer actually used in noVNC.

Closes #436.
2016-01-06 11:10:26 -05:00
Solly Ross 40037b6a29 On-Demand Dynamic Receive Queue Resizing
This commit causes the receive queue to dynamically
resize to fit incoming messages.

Fixes #557
2015-12-22 16:05:33 -05:00
Solly Ross a369a80c24 Fix bug in non-true-color code
There was a bug caused by 38781d931e
which prevented color map look-ups sent by rfb.js from working properly,
since display.js expected a single-item array, and rfb.js sent just them
item value itself (a number) instead.  This fixes that, and tweaks the
corresponding test to match that behavior.
2015-08-24 19:34:30 -04:00
Solly Ross bb180145c6 Tests: Fixed bug in displayed assertion
This `displayed` assertion had a bug that was causing it to not
actually check anything (it was using obj.length instead of
data_cl.length).  This fixes that.
2015-08-24 19:30:44 -04:00
Solly Ross b0b5fc55e1 Fix multi-line assertion messages in test runner
This commit prevents multi-line error messages from being
truncated in the local test runner ('tests/run_from_console.js').
2015-08-06 14:47:03 -04:00
Solly Ross 07f514d887 Allow the use of the PhantomJS remote debugger
This commit adds the '--debugger <port>' option, which triggers
the PhantomJS remote debugger.  The initial output of the terminal
when running the debugger gives more information on how to use
it.
2015-08-06 14:47:03 -04: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
Solly Ross efed2eeafd Fix up vnc_playback.html and playback.js
This commit fixes vnc_playback.html and playback.js
so that they work with the current version of noVNC.
2015-08-06 14:47:03 -04:00
Solly Ross 58ded70d15 Create RFB object on connect
In e543525faa, we switched to creating
a new RFB object on disconnect.  This caused issues, however, since
any errors were only displayed briefly before the new "loaded" text
was displayed instead.

Now, we create the RFB object on connect.  This essentially removes
the usefulness of the "loaded" state, but prevents the aforementioned
problem.

To facilitate this, the code which does detection of cursor URI support
was moved from this Display constructor (which now calls the new
function) into its own function, `Util.browserSupportsCursorURIs()`.

Fixes #467
2015-03-26 17:09:05 -04:00
samhed fdedbafb1d * Don't check specific html elements from the display code (Fixes #446)
* Renamed and reworked fbuClip to clippingDisplay
* Added tests for clippingDisplay
* Use the a noVNC_container which covers the entire page to get the full size
  (Fixes #463)
* Added maxWidth and maxHeight to the canvas which can limit the viewport size
* Only show either the canvas or the logo, hide one when the other is shown
* Always center the canvas (previously it was only centered when not clipping)
* Removed iOS specific "position-fixed" fixes and start calling setBarPosition
  on every resize
* Removed the noVNC_screen_pad
2015-03-09 14:30:56 +01: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
Solly Ross 72747869a7 Support local scaling
This commit adds two new addition scaling options.  Both options do
local scaling.  The first "Local Scaling", does both upscaling and
downscaling.  The second option, "Local Downscaling", only downscales.

This is based on work by @mightypenguin (with an additional bug
reported by @glazik12).
2015-03-03 13:15:49 -05:00
Solly Ross dedf9affbf Merge branch 'bug/fix-input-html'
Closes #434
2015-02-17 13:36:56 -05:00
Jesper Dam (jalfd) 1188993c0f Update tests/input.html to include keysym.js instead of keysymdef.js 2015-02-17 13:36:22 -05: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 b11bb5c385 Add support for Relative Paths in the Test Runner
This patch adds support for using relative paths
with the '-r' or '--relative' methods.  This can
be useful if you want to output HTML (with the
'--output-html' option) and use it in a webpage.

Additionally, the '-o' was removed from the documentation
of '--output-html', since it hasn't worked for that in a
while ('-o' means open in browser instead).
2014-09-22 21:42:32 -04: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 53762c31fe Fixed Cursor URI Support Detection
There was a bug in cursor URI support detection due to the way
set_defaults now works -- the code was checking for `null`, whereas
when not set, options default to `undefined` unless otherwise
specified.  The code now checks for either `null` or `undefined`.
Tests have been added to ensure that this works properly.
2014-09-19 14:51:15 -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 e4e9a9b97f Merge pull request #391 from mandre/fix_invalid_property
Fix invalid updateState property on RFB preventing noVNC to load
2014-09-19 12:35:27 -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
Martin André 77bd04f833 Fix invalid updateState property of RFB
It was changed to `onUpdateState` in
b1dee94788.
2014-09-17 16:56:13 +09:00
Solly Ross e6af0f60b0 Add support for Travis CI and SauceLabs Testing
This adds support for Travis CI and SauceLabs
testing.  Testing on SauceLabs in done via
the Karma test runner.  Note that encrypted
Sauce username and access key values need
to be inserted into .travis.yml as global
environment variables.  Additionally, the
local test runner (which is still useful
for debugging tests and code) was updated
to reflect that the 'node_modules' folder
now gets placed in the root directory.
2014-09-15 16:46:02 -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
Solly Ross 1e13775bd5 Cleanup: Display Helper
File: display.js
Tests Added: True (preliminary)

Changes:
- De-crockford-ified the file

NOTE: the tests included for display.js cover basic functionality, but
are by no means nearly as comprehensive as the ones presented for
rfb.js.
2014-09-15 16:46:02 -04:00
Solly Ross 2cccf7530c Cleanup: WebSocket Helper
File: websock.js
Tests Added: True
Changes:
- Cleaned up JSHint errors
- Converted to normal JS constructor pattern with "private" fields and
  methods now simply being prepended by underscores
- Added a "bind" polyfill for use in PhantomJS 1.x in util.js
- Added FakeWebSocket to fill in for actual WebSocket objects when
  testing
- Made exception handler actually log exception name and message,
  to console, in addition to stack trace
2014-09-15 16:46:02 -04:00
Solly Ross ee7d4c61c6 Cleanup: Webutil code
File: webutil.js
Tests Added: False
Changes:
- Fixed JSHint Errors (global "use strict", spaces)
- added some newline characters when appropriate for readability
- moved variable declarations to the places they were actually used
  for readability
2014-09-15 16:46:02 -04:00
Solly Ross 31f169e86f Cleanup: Keyboard code
File: keyboard.js
Tests Added: False (already present)
Changes:
- Fixed JSHint Errors
- Moved functions outside loops
- Added proper include directives to tests
2014-09-15 16:46:02 -04:00
Solly Ross d21cd6c164 Cleanup: Util code
File: util.js
Tests Added: True (partial -- for logging and array push methods)
Changes:
- Fixed JSHint Errors (indentation, semicolons, global "use strict")
- Made browser detection methods more readable
- added some newline characters when appropriate for readability
- throw Errors not strings!
- Removed conf_defaults, and added make_properties and set_defaults
  instead (see below)

The removal of conf_defaults and switch to make_properties and
set_defaults is to facilitate the switch over to normal Javascript
constructors instead of Crockford-style constructors.  Now, methods
are added to the objects prototype (and thus make properties is called
outside the constructor).
2014-09-15 16:46:02 -04:00
Solly Ross f8e9b9f1bf Cleanup and Test: base64.js
This is the first commit in a series of commits
which improve the readability of some of the code
and add tests.

File: base64.js
Tests Added: True
Changes:
- Improved indentation
- Fixed JSHint errors
- Moved loop variables to be declared in the loop for better readability
  (N.B. Javascript does not have block scoping, so the variables are
  still technically available outside the loop -- it just makes the code
  clearer to place them inside the loop, since they are only used there)
2014-09-15 16:46:02 -04:00
Solly Ross 91127741be Support running all tests from the root directory
Previously, if you did not specify a tests file,
you had to be in the 'tests' directory for the
"run all tests" functionality to work.  Now it
will work in any directory.
2014-09-15 16:44:36 -04:00
Solly Ross 9b731d3a58 Fix race condition in test runner
Previously, there would be a case where if your tests took
too long to run, the casper test runner would only report
on certain tests.  This has been fixed.
2014-06-03 17:42:28 -04:00
Solly Ross 93af721a27 Output error events from provider in test runner
Now, 'error' events from the test runner are output to stderr.
Additionally, when debug is enabled, debug output is logged to
stderr instead of stdout (as was the case previously).
2014-06-03 16:58:37 -04:00
Solly Ross 7187bc121f Fixed typo in run_from_console.js 2014-06-03 13:15:02 -04:00
Solly Ross d906dfc953 Add support for injecting test helper files
Now, the phrase `requires test modules: ` may be place in a comment
in a file to require modules local to the test directory, similarly
to the way the `require local modules: ` line may be used to inject
files in the 'include' directory.  This is useful for when common
fakes need to be injected into a test.
2014-06-03 11:17:33 -04:00
Solly Ross 4a4643c05d Support automatically opening test HTML in browser
When using the '-g' option with run_from_console.js, you can
now pass the '-o' option to automatically open the generated
HTML file in your default browser.  This relies on the 'open'
NPM module.
2014-06-03 11:17:29 -04:00
Jesper Dam f6a1d98a3a Fix issue #326: correct handling of shift key
When shortcut modifiers (modifier keys such as CTRL, which do not participate in
composing character input) are pressed, we try to suppress the keypress
event, as browsers do not reliably generate it. This means that
subsequent key events are decoded only based on the keydown event.

Due to a type error (comparing a string to a number), shift was
mistakenly treated as a shortcut modifier, preventing text input which
relied on shift, such as _ and %, from being generated.
2014-01-06 13:59:25 +01:00
Solly Ross 85e8991664 Support 'requires' Line in Test Runner
If the files passed to the '-t' option are all '.js' files (or
the 'run all tests' option is used) and the '-i' option is not
passed, all tests will be search for the string
'require local modules: '.  Only the first instance of this string
will be used.  Following the colon should be a list of either local
modules (i.e. files in the '../include/' folder relative to the
test runner's directory, without the '.js' extension) or paths
to other Javascript files.  The list of modules and/or files should
be comma-separated.  These files will then be included in the generated
HTML file for the appropriate tests as if the '-i' option had been used.
2013-12-17 18:00:57 -05:00
Solly Ross d823e8956e Support Running All Tests
Now, if the '-t' option is passed but no tests are listed,
all tests in the same directory as the launcher will be run.
A file is considered a test if it matches the RegEx
/^test\.(\w|\.|-)+\.js$/ (for those who cannot read PCRE,
that's roughly 'test.*.js').
2013-12-17 18:00:45 -05:00
Solly Ross 8eb88937cc Support Skipped Tests and Fix JSHint Issues
The test runner now will not break when Mocha skips tests,
and will properly report them.  Additionally, several JSHint
warnings were fixed, and a `--debug` option was added to see
output from the provider.
2013-12-17 17:56:18 -05:00
jalf 466a09f0f3 Keyboard Handling [8/8]: Introduce substituteCodepoint() to replace code points which don't have a keysym with ones that do
For now, the only code points this is done for are {s, S, t, T} with comma below (used in Romanian),
 which are replaced by {s, S, t, T} Cedilla.
2013-12-05 12:31:50 -05:00
jalf 2ea40fdf9a Keyboard Handling [6/8]: Update everything to include the new keyboard handling scripts 2013-12-05 12:31:48 -05:00
jalf 9ceef041c6 Keyboard Handling [4/8]: Update input.html to work with new keyboard handling
Plug new keyboard handling into input.js (which breaks everything else), and update input.html to work with this
2013-12-05 12:25:30 -05:00
jalf f00b6fb69a Keyboard Handling [3/8]: Add unit tests for new keyboard handling
Relies on the libraries chai and mocha (available via npm from Node.JS).

Add anything installed via npm to the .gitignore file.
2013-12-05 12:25:30 -05:00
Solly Ross 1e570156f9 Add support for Outputting Autogenerated Test HTML
This commit introduces two flags, '-g' and '-o' to
the `run_from_console.js`.  Both flags do not run
the tests.  Instead, deal with the autogenerated
HTML.  The former outputs the paths to the autogenerated
HTML temp files, and then pauses the program until Ctrl-C
is pressed (or SIGINT is sent).  The latter outputs the
generated HTML for each files to STDIN with the names
of the tests to which they belong.
2013-12-04 15:44:55 -05:00
Solly Ross 2af865923c Support Running Mocha Tests from the Console
Previously, the only way to run the Mocha tests
(in 'test.*.js') is to write a web page to wrap
them (or use a provided one), and then load that
file in a browser.

This commit introduces a series of files to allow
you to run the Mocha tests from the command line
instead.

Normally, Mocha tests can be run from
the command line anyway.  However, since this
project was designed to work in web browsers
and not node, the code doesn't contain the
proper `require` calls, nor does it contain the
proper `module.exports` declarations.  Additionally,
some of the code is dependent on having a browser
environment.

To overcome these issues, a headless browser environment
is used.  The command file introduced in the commit,
`run_from_console.js`, can use one of two environments:
ZombieJS, a pure-javascript headless browser simulator, or
SpookyJS/CasperJS/PhantomJS, an actually WebKit-based
environment.

Because the environment-dependent code is separated
out in to different files ('run_from_console.zombie.js'
and 'run_from_console.casper.js'), the program can be
safely used if only one of the supported environments
is installed.

Additionally, the command will automatically generate
HTML and inject the required tests if there is no
pre-existing HTML file (although you can still use
pre-existing HTML files if you want to).

The required NPM modules for the base program are:

- commander
- ansi
- mocha (must be installed locally for the HTML files to use)
- chai (must be installed locally for the HTML files to use)
- temp

For Zombie, you need:

- zombie
- q

For Casper, you need:

- casperjs (must be installed locally in order to work properly)
- phantomjs
- phantom
- spooky

The command itself can be invoked as

   $ node run_from_console.js -t html_files

or

   $ node run_from_console.js -t js_test_files -i js_required_files

In both cases, the 'files' options should be a comma-separated list of
files.  The first case runs pre-existing HTML files.  The second case
generates HTML files to run the specified Mocha tests, and injects
the requirements specified as well.

Additionally, there are extra arguments that apply to both forms:
'-a' can be used to print all test results, not just the failures,
'-c' may be used to force color to be enabled (when outputting to
a pipe, such as when `less -R` is in use), and '-e' is used to
set the environment.  Use the '-h' or '--help' options to see
a detailed description of all options, and their long-form versions.
2013-12-04 01:08:44 -05:00
Joel Martin 35785a9081 Add binary/base64 data mode to perf/playback tests. 2012-10-17 11:58:13 -05:00
Joel Martin 6f4b1e4071 Refactor dynamic script loading. Add util.js:load_scripts()
Related to issue/pulls:
https://github.com/kanaka/noVNC/issues/194
https://github.com/kanaka/noVNC/pull/201
https://github.com/kanaka/noVNC/pull/202

In IE9, the window.onload event can fire before dynamically loaded
scripts have finished loading. This can result in either WebSocket (in
the case of vnc_auto.html) or RFB (in the case of vnc.html) not being
defined at the point when window.onload is called.

- Move the load_scripts routine from vnc.js to util.js (so that
  websockify can use it too). Also, refactor to work when load_scripts
  is called by a script that itself uses load_scripts. When the whole
  chain of dynamically loaded scripts is finished then call
  window.onscriptsload. Use this mechanism in all the places that
  depend on dynamic loading of scripts: vnc.html, vnc_auto.html,
  websock.js, tests/vnc_playback.html, and tests/vnc_perf.html.

- Use the new window.onscriptsload handler instead of window.onload.

- Remove include/start.js and do the script loading and startup event
  handling in include/ui.js instead.
2012-10-17 11:58:12 -05:00
Joel Martin 1d728ace69 Change noVNC license to from LGPLv3 to MPL 2.0
The MPL 2.0 license is a "file-level" copyleft license vs the
"project-level" nature of the L/GPL. The intention of noVNC has
always been that it should be easy to incorporate into existing
projects and sites whether free/open or proprietary/commercial. The MPL
2.0 is designed for this sort of combination project but still
requires that any distributed modifications to noVNC source files must
also be published under the same license.

In addition, the MPL 2.0 allows the code to be used in L/GPL projects
(the secondary license clause). This means that any projects that are
already incorporating noVNC should not be impacted by this change and
in fact it should clarify the licensing situation (the exact
application of the L/GPL to web applications and interpreted code is
somewhat ambiguous).

The HTML, CSS, image and font files continue to be under more
permissive licenses (see LICENSE.txt). The included websockify python
code remains under a LGPLv3 license although the include/websock.js
file from the websockify component is now under MPL 2.0 as well.

Permission was received from other noVNC authors to make this change to their
code license on the following dates:

    - Chris Gordon (UI): Jun 24, 2012
    - Antoine Mercadal (DOM,*util.js): Oct 10, 2012
    - William Lightning (UltraVNC repeater): Oct 10, 2012
    - Mike Tinglof (tight encoding): Oct 15, 2012
2012-10-15 13:35:00 -05:00
Joel Martin e79917c3db Merge remote branch 'origin/issue-70'
Conflicts:
	include/display.js
	include/rfb.js

This merges in the fix for https://github.com/kanaka/noVNC/issues/70

This changes noVNC to use the preferred color ordering that most VNC
server prefer and that VMWare VNC requires. It's possible this may
break some VNC servers out there in which case we might have to do
something a bit more subtle such as having alternate render functions
for little and big endian color ordering.
2012-01-12 17:17:11 -06:00
Joel Martin 1310606305 Make tests/vnc_perf.html work again. 2011-09-25 22:02:13 -05:00
Joel Martin a5df24b488 Viewport clip/drag for mobile/touchscreen devices.
API changes (forward compatible):

- Display: add 'viewport' conf option to turn on and off viewport
  mode.
- RFB: add 'viewportDrag' option to enable/disable viewport dragging
  mode.

Other:

- Add clip mode setting to default UI. For touch devices, clipping is
  forced on.
- Use CSS media queries to adjust visual elements based on screen
  size. Especially disconnected logo size/position and button text size.
- Catch page unload while connected and give a confirm dialog.
- Change mouse button selector to a single button that changes between
  ' ', 'L', 'M', 'R' when clicked (empty means mouse is just being
  moved and doesn't send clicks).
- include/ui.js:setViewClip() routine sets the clipping of the
  viewport to the current size of the viewport area (if clipping is
  enabled).
- include/ui.js:setViewDrag() toggles/enables/disables viewport
  dragging mode.
- Add several images for the UI and for Apple devices:
    - images/clipboard.png: clipboard menu icon
    - images/connect.png: connect menu icon
    - images/disconnect.png: disconnect button icon
    - images/keyboard.png: show keyboard button
    - images/move.png: viewport drag/move toggle button
    - images/settings.png: settings menu icon
    - images/screen_320x460.png: iOS app/desktop link start image
    - images/screen_57x57.png: iOS app icon
    - images/screen_700x700.png: full size noVNC image
2011-09-22 10:36:23 -05:00
Joel Martin 608e0f52ee Some CSS style and DOM id/class cleanup. 2011-09-14 09:24:30 -05:00