Commit Graph

516 Commits

Author SHA1 Message Date
Pierre Ossman 0b5e968e14 Better resize rate limiting
Be more aggressive with resizing, limiting it to once ever 100 ms
instead of after a 500 ms idle period. This gives a more responsive user
experience.
2025-02-05 16:59:22 +01:00
Pierre Ossman c82178348a Include SetDesktopSize responses in tests
There might be subtle changes in behaviour, so we should mimic what a
real server does.
2025-02-05 16:53:12 +01:00
Pierre Ossman 70446bf742 Make resizeSession setting test more realistic
We shouldn't expect a resize request to be sent if the container didn't
change size first.
2025-02-05 16:53:12 +01:00
Pierre Ossman bbbef2d9fa Add helper for ExtendedDesktopSize in tests 2025-02-05 16:53:12 +01:00
Pierre Ossman 83a5e9e9db Also test Ctrl+AltGr, as that is what browsers use
Modern browsers now send the odd sequence of Ctrl+AltGr, rather than the
raw Ctrl+Alt, or the fully adjusted just AltGr.

Make sure we have a test for this scenario and don't break it.
2025-01-15 12:43:44 +01:00
Adam Halim e081d1415a Add support for forward and back mouse buttons
This commit implements the extendedMouseButtons pseudo-encoding, which
makes it possible to use the forward and back mouse buttons.
2025-01-15 09:11:48 +01:00
Adam Halim e8602f23ab Move sendFbuMsg() to broader scope
This is needed if we want to use this function elsewhere in our tests.
2025-01-14 16:27:14 +01:00
Adam Halim 6383fa6384 Flush mouseMove when initiating viewport dragging
We want to flush pending mouse moves before we initiate viewport
dragging.

Before this commit, there were scenarios where the _mouseButtonMask
would track a released button as being down.
2025-01-14 12:32:51 +01:00
Adam Halim d1548c12ec Don't send mouse events when dragging viewport
We don't want to send any mouse events to the server when dragging the
viewport. Instead, we treat them as a client-only operation.
2025-01-14 12:14:59 +01:00
Adam Halim b9230cf23e Use MouseEvent.buttons for button state tracking
Instead of keeping track of button states ourselves by looking at
MouseEvent.button, we can use the MouseEvent.buttons which already
contains the state of all buttons.
2025-01-14 12:14:59 +01:00
Adam Halim f9eb476f6d Add tests for dragging with gestures
There were no test for viewport dragging using gesture previously, so
let's add some.

Note that there currently are some viewport dragging behaviours that we
don't want to have, so some tests have commented out what our desired
behaviour should be.
2025-01-14 12:14:59 +01:00
Adam Halim ea057d0793 Move gesture event help functions to broader scope
This is needed if we want to test gestures with dragging.
2025-01-14 12:14:59 +01:00
Adam Halim 31d6a77af6 Check for correct button events in dragging tests
Previously, these unit tests did not check which events were sent to the
server, only how many events were sent. This commit adds checks to see
that the expected button events are sent.
2025-01-14 12:14:59 +01:00
Adam Halim dce8ab395b Dispatch mouse events in dragging unit tests
This makes our tests reflect the real world better, as we now send real
mouse events instead of calling private methods directly.
2025-01-14 12:14:59 +01:00
Adam Halim db22ec6ee6 Split button click with dragging test 2025-01-14 10:38:39 +01:00
Adam Halim de9d6888db Add unit test for wheel + buttons pressed 2025-01-14 10:38:39 +01:00
Adam Halim 7a4d1a8274 Move mouse event help functions to broader scope
These functions can be used elsewhere in the tests. We want to use these
in the dragging tests in the future instead of directly calling private
methods.
2025-01-14 10:38:39 +01:00
Samuel Mannehed e6e03a226f Fix resizes back to initial remote session size
Since the expected client size wasn't updated when the browser window
resized, noVNC didn't resize the canvas properly when going back to
the exact same dimensions.

Fixes issue #1903
2024-12-27 14:48:11 +01:00
Pierre Ossman 7f5b51acf3 Consistently use "sentence case" style
Try to be more consistent in how we capitalize things. Both the "Title
Case" and "Sentence case" styles are popular, so either would work.
Google and Mozilla both prefer "Sentence case", so let's follow them.
2024-11-27 14:40:40 +01:00
Pierre Ossman 89e0591aab Use common H.264 check in tests
Avoid duplicating this logic in multiple places.
2024-11-21 13:19:44 +01:00
Pierre Ossman 43326eb67b Fix handling of VideoDecoder.isConfigSupported()
It returns an object with details, not just a simple boolean.
2024-11-20 10:46:52 +01:00
Pierre Ossman 047531e886 Merge branch 'webcodec-h264' of https://github.com/any1/noVNC 2024-08-29 16:59:25 +02:00
Pierre Ossman 50e4685bff Fix tests for large WebSocket sends
These failed to test that the data was correctly split as they only
checked the first chunk transmitted.

Use random values to avoid the risk of aligning our test data with the
split boundaries and hence allowing false positives.
2024-08-29 16:51:51 +02:00
Pierre Ossman ffb4c0bf56 Let fake WebSocket handle large sends
Dynamically grow the recorded send buffer if the test needs to send a
lot of data.
2024-08-29 16:51:16 +02:00
Andri Yngvason c1bba972f4 Add unit tests for H.264 decoder 2024-08-19 22:08:32 +00:00
Mark Peek c6c8e5e513 Add Zlib encoding 2024-08-16 09:12:43 -07:00
Pierre Ossman 06f14a5cd3 Add test for AltGr abort on blur 2024-08-05 16:31:59 +02:00
Pierre Ossman 1b2fe3321b Manually load sinon and chai
karma-sinon-chai is not compatible with Chai 5+, and Karma is no longer
being updated.

Load sinon and chai manually instead, until we can have a long term plan
in place.
2024-08-05 15:49:39 +02:00
Pierre Ossman bc31e4e8a2 Stop creating sinon sandbox early
sinon might not be loaded at this point, which can cause tests to fail.

We could create the sandbox in one of the hooks instead, but let's
remove the sandbox completely to stay consistent with our other tests.
2024-08-05 15:45:41 +02:00
Pierre Ossman d80e3bfa2f Add unit tests for Tight gradient filter 2024-05-16 16:53:49 +02:00
Samuel Mannehed 10ee10ce56 Cleanup "no-console" eslint rules
Removes unexpected exceptions and clarifies where we want to avoid
console calls.
2024-04-30 15:26:50 +02:00
Samuel Mannehed 8d1b665808 Migrate deprecated eslint config to to new format
The .eslintrc and .eslintignore formats are deprecated. The new format
uses a single eslint.config.js (or .mjs) file at the top.
2024-04-30 15:26:50 +02:00
Kostiantyn Syrykh 9a1b1f0d06 Clipboard: handle multiple CR+LF 2024-03-25 17:35:28 +02:00
Pierre Ossman ab2fd41693 Handle broken Oculus browser keyboard events
It sets KeyboardEvent.key to "Unidentified" for all non-character keys,
which means we must ignore it and use the legacy handling to figure out
the key pressed.
2024-01-23 12:51:35 +01:00
Pierre Ossman 85a465288b Merge branch 'qemu_ledstate_pseudo_encoding' of https://github.com/otthou/noVNC 2023-09-29 14:18:02 +02:00
Otto van Houten a0b7c0dac5 Add QEMU Led Pseudo encoding support
Previously, num-lock and caps-lock syncing was performed on a best effort basis by qemu.
Now, the syncing is performed by no-vnc instead. This allows the led state syncing to work
in cases where it previously couldn't, since no-vnc has with this extension knowledge of both
the remote and local capslock and numlock status, which QEMU doesn't have.
2023-09-29 13:58:55 +02:00
Pierre Ossman bf12c24f4c Fix bad indentation 2023-09-07 15:35:20 +02:00
Pierre Ossman 370f21b117 Correctly handle legacy security rejections
The code comment of this code was entirely incorrect, but the commit
message for 5671072 when it was added was correct. I.e. there is a
result, but not a reason.

Adjust the unit tests to make sure this doesn't regress again.
2023-09-07 14:59:36 +02:00
Pierre Ossman 72f6810797 Correctly handle "none" auth on old servers
There is no security result for the "none" authentication until RFB 3.8.
This got broken by mistake in 5671072.
2023-09-07 14:38:04 +02:00
Pierre Ossman e81602d705 Fix zlib level change in clipboard tests
The compression level got changed in 01bb36d4, but the tests weren't
updated to follow this change.
2023-08-29 17:38:44 +02:00
Samuel Mannehed a30f609de4 Don't crash if we can't use localStorage
Our settings are not a fatal requirement, we can fall back on the
default values if they can't be accessed. A scenario where we've seen
this happen is when cookies are disabled in the browser. It seems
localStorage is disabled along with cookies in these settings.

So, lets log a message about the failure and otherwise silently
continue in this case.

Fixes issue #1577.
2023-07-13 14:35:07 +02:00
Pierre Ossman ccef89f556 Implicitly flush Websock if needed
Callers shouldn't have to deal with the internal buffering limits of
Websock, so implicitly flush the buffer if more room is needed.
2023-06-04 22:32:43 +02:00
Pierre Ossman f8b65f9fe1 Add Websock send queue helpers
Callers shouldn't be poking around directly in to the send queue, but
should use accessor functions like for the read queue.
2023-06-04 22:32:43 +02:00
Pierre Ossman 7356d4e60b Move WebSocket queue index reset to receive
It's more robust to do this just before we need the space, rather than
assume when the queue will be read and adjust things right after.
2023-06-04 22:32:43 +02:00
Pierre Ossman 3fc0cb0cb7 Remove Base64 WebSocket remnants
There is no encoding/decoding in modern WebSockets, so let's clean up
some of the old crud that no longer serves a purpose.
2023-06-04 22:32:43 +02:00
Pierre Ossman b146de6d69 Avoid internal variables in recv queue tests
Makes for more robust and realistic tests.
2023-06-04 22:32:43 +02:00
Pierre Ossman b298bf9e90 Don't split large WebSocket data in tests
It takes too much time and can make the tests fail.
2023-06-04 22:32:43 +02:00
Pierre Ossman 2a7db6f647 Make ExtendedDesktopSize tests more realistic
Send real messages and avoid poking around in internals, as we weren't
testing things correctly that way.
2023-06-04 19:12:02 +02:00
Pierre Ossman d0203a5995 Always return copy of data from socket
We don't know how long the caller will hang on to this data, so we need
to be safe by default and assume it will kept indefinitely. That means
we can't return a reference to the internal buffer, as that will get
overwritten with future messages.

We want to avoid unnecessary copying in performance critical code,
though. So allow code to explicitly ask for a shared buffer, assuming
they know the data needs to be consumed immediately.
2023-06-04 19:12:02 +02:00
Pierre Ossman e01dd27be4 Remove Websock implicit read length
Callers should be properly aware of how much data they need, as they
need to call rQwait() first to ensure the data is present.
2023-06-04 19:00:33 +02:00