Block user interaction when fallback error shows

When this error is shown, something has gone very wrong. It shows when
a bug in the JavaScript causes an uncaught error. In these scenarios we
dont want the user to be able to interact with the GUI or the remote
session, since we can't guarantee that things work.
This commit is contained in:
Samuel Mannehed 2022-10-07 14:34:27 +02:00
parent 58dfb7df45
commit e1f8232bc9
2 changed files with 14 additions and 0 deletions

View File

@ -50,6 +50,16 @@ function handleError(event, err) {
document.getElementById('noVNC_fallback_error') document.getElementById('noVNC_fallback_error')
.classList.add("noVNC_open"); .classList.add("noVNC_open");
// Remove focus from the currently focused element in order to
// prevent keyboard interaction from continuing
document.activeElement.blur();
// Don't let any element be focusable when showing the error
let keyboardFocusable = 'a[href], button, input, textarea, select, details, [tabindex]';
document.querySelectorAll(keyboardFocusable).forEach((elem) => {
elem.setAttribute("tabindex", "-1");
});
} catch (exc) { } catch (exc) {
document.write("noVNC encountered an error."); document.write("noVNC encountered an error.");
} }

View File

@ -287,6 +287,10 @@ select:active {
#noVNC_fallback_error { #noVNC_fallback_error {
z-index: 1000; z-index: 1000;
visibility: hidden; visibility: hidden;
/* Put a white background in front of everything but the error,
and don't let mouse events pass through */
background: rgba(0, 0, 0, 0.8);
pointer-events: all;
} }
#noVNC_fallback_error.noVNC_open { #noVNC_fallback_error.noVNC_open {
visibility: visible; visibility: visible;