Skip to content

Commit 9e13042

Browse files
Console: upgrade noVNC from v1.2.0 to v1.4.0 (#7281)
* noVNC: apply noVNC-v1.2.0-v1.4.0.patch 1. Create the patch by commands git clone -b v1.2.0 https://github.com/novnc/noVNC.git . git checkout v1.4.0 git diff v1.2.0 >noVNC-v1.2.0-v1.4.0.patch 2. Apply the patch by cd systemvm/agent/noVNC patch -p1 <noVNC-v1.2.0-v1.4.0.patch * noVNC: apply noVNC-v1.2.0-v1.4.0.patch part2 fix conflicts * noVNC: svg to png * noVNC: remove systemvm/agent/noVNC/tests/ * noVNC: remove systemvm/agent/noVNC/.github/
1 parent 30998d0 commit 9e13042

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4066
-1626
lines changed

systemvm/agent/noVNC/app/error-handler.js

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,74 @@
66
* See README.md for usage and integration instructions.
77
*/
88

9-
// NB: this should *not* be included as a module until we have
10-
// native support in the browsers, so that our error handler
11-
// can catch script-loading errors.
9+
// Fallback for all uncought errors
10+
function handleError(event, err) {
11+
try {
12+
const msg = document.getElementById('noVNC_fallback_errormsg');
1213

13-
// No ES6 can be used in this file since it's used for the translation
14-
/* eslint-disable prefer-arrow-callback */
14+
// Work around Firefox bug:
15+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1685038
16+
if (event.message === "ResizeObserver loop completed with undelivered notifications.") {
17+
return false;
18+
}
1519

16-
(function _scope() {
17-
"use strict";
20+
// Only show the initial error
21+
if (msg.hasChildNodes()) {
22+
return false;
23+
}
1824

19-
// Fallback for all uncought errors
20-
function handleError(event, err) {
21-
try {
22-
const msg = document.getElementById('noVNC_fallback_errormsg');
25+
let div = document.createElement("div");
26+
div.classList.add('noVNC_message');
27+
div.appendChild(document.createTextNode(event.message));
28+
msg.appendChild(div);
2329

24-
// Only show the initial error
25-
if (msg.hasChildNodes()) {
26-
return false;
30+
if (event.filename) {
31+
div = document.createElement("div");
32+
div.className = 'noVNC_location';
33+
let text = event.filename;
34+
if (event.lineno !== undefined) {
35+
text += ":" + event.lineno;
36+
if (event.colno !== undefined) {
37+
text += ":" + event.colno;
38+
}
2739
}
40+
div.appendChild(document.createTextNode(text));
41+
msg.appendChild(div);
42+
}
2843

29-
let div = document.createElement("div");
30-
div.classList.add('noVNC_message');
31-
div.appendChild(document.createTextNode(event.message));
44+
if (err && err.stack) {
45+
div = document.createElement("div");
46+
div.className = 'noVNC_stack';
47+
div.appendChild(document.createTextNode(err.stack));
3248
msg.appendChild(div);
49+
}
3350

34-
if (event.filename) {
35-
div = document.createElement("div");
36-
div.className = 'noVNC_location';
37-
let text = event.filename;
38-
if (event.lineno !== undefined) {
39-
text += ":" + event.lineno;
40-
if (event.colno !== undefined) {
41-
text += ":" + event.colno;
42-
}
43-
}
44-
div.appendChild(document.createTextNode(text));
45-
msg.appendChild(div);
46-
}
51+
document.getElementById('noVNC_fallback_error')
52+
.classList.add("noVNC_open");
4753

48-
if (err && err.stack) {
49-
div = document.createElement("div");
50-
div.className = 'noVNC_stack';
51-
div.appendChild(document.createTextNode(err.stack));
52-
msg.appendChild(div);
53-
}
54+
} catch (exc) {
55+
document.write("noVNC encountered an error.");
56+
}
5457

55-
document.getElementById('noVNC_fallback_error')
56-
.classList.add("noVNC_open");
57-
} catch (exc) {
58-
document.write("noVNC encountered an error.");
59-
}
60-
// Don't return true since this would prevent the error
61-
// from being printed to the browser console.
62-
return false;
58+
// Try to disable keyboard interaction, best effort
59+
try {
60+
// Remove focus from the currently focused element in order to
61+
// prevent keyboard interaction from continuing
62+
if (document.activeElement) { document.activeElement.blur(); }
63+
64+
// Don't let any element be focusable when showing the error
65+
let keyboardFocusable = 'a[href], button, input, textarea, select, details, [tabindex]';
66+
document.querySelectorAll(keyboardFocusable).forEach((elem) => {
67+
elem.setAttribute("tabindex", "-1");
68+
});
69+
} catch (exc) {
70+
// Do nothing
6371
}
64-
window.addEventListener('error', function onerror(evt) { handleError(evt, evt.error); });
65-
window.addEventListener('unhandledrejection', function onreject(evt) { handleError(evt.reason, evt.reason); });
66-
})();
72+
73+
// Don't return true since this would prevent the error
74+
// from being printed to the browser console.
75+
return false;
76+
}
77+
78+
window.addEventListener('error', evt => handleError(evt, evt.error));
79+
window.addEventListener('unhandledrejection', evt => handleError(evt.reason, evt.reason));
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
ICONS := \
2-
novnc-16x16.png \
3-
novnc-24x24.png \
4-
novnc-32x32.png \
5-
novnc-48x48.png \
6-
novnc-64x64.png
7-
8-
ANDROID_LAUNCHER := \
9-
novnc-48x48.png \
10-
novnc-72x72.png \
11-
novnc-96x96.png \
12-
novnc-144x144.png \
13-
novnc-192x192.png
14-
15-
IPHONE_LAUNCHER := \
16-
novnc-60x60.png \
17-
novnc-120x120.png
18-
19-
IPAD_LAUNCHER := \
20-
novnc-76x76.png \
21-
novnc-152x152.png
22-
23-
ALL_ICONS := $(ICONS) $(ANDROID_LAUNCHER) $(IPHONE_LAUNCHER) $(IPAD_LAUNCHER)
1+
BROWSER_SIZES := 16 24 32 48 64
2+
#ANDROID_SIZES := 72 96 144 192
3+
# FIXME: The ICO is limited to 8 icons due to a Chrome bug:
4+
# https://bugs.chromium.org/p/chromium/issues/detail?id=1381393
5+
ANDROID_SIZES := 96 144 192
6+
WEB_ICON_SIZES := $(BROWSER_SIZES) $(ANDROID_SIZES)
7+
8+
#IOS_1X_SIZES := 20 29 40 76 # No such devices exist anymore
9+
IOS_2X_SIZES := 40 58 80 120 152 167
10+
IOS_3X_SIZES := 60 87 120 180
11+
ALL_IOS_SIZES := $(IOS_1X_SIZES) $(IOS_2X_SIZES) $(IOS_3X_SIZES)
12+
13+
ALL_ICONS := \
14+
$(ALL_IOS_SIZES:%=novnc-ios-%.png) \
15+
novnc.ico
2416

2517
all: $(ALL_ICONS)
2618

27-
novnc-16x16.png: novnc-icon-sm.svg
28-
convert -density 90 \
29-
-background transparent "$<" "$@"
30-
novnc-24x24.png: novnc-icon-sm.svg
31-
convert -density 135 \
32-
-background transparent "$<" "$@"
33-
novnc-32x32.png: novnc-icon-sm.svg
34-
convert -density 180 \
35-
-background transparent "$<" "$@"
19+
# Our testing shows that the ICO file need to be sorted in largest to
20+
# smallest to get the apporpriate behviour
21+
WEB_ICON_SIZES_REVERSE := $(shell echo $(WEB_ICON_SIZES) | tr ' ' '\n' | sort -nr | tr '\n' ' ')
22+
WEB_BASE_ICONS := $(WEB_ICON_SIZES_REVERSE:%=novnc-%.png)
23+
.INTERMEDIATE: $(WEB_BASE_ICONS)
3624

25+
novnc.ico: $(WEB_BASE_ICONS)
26+
convert $(WEB_BASE_ICONS) "$@"
27+
28+
# General conversion
3729
novnc-%.png: novnc-icon.svg
38-
convert -density $$[`echo $* | cut -d x -f 1` * 90 / 48] \
39-
-background transparent "$<" "$@"
30+
convert -depth 8 -background transparent \
31+
-size $*x$* "$(lastword $^)" "$@"
32+
33+
# iOS icons use their own SVG
34+
novnc-ios-%.png: novnc-ios-icon.svg
35+
convert -depth 8 -background transparent \
36+
-size $*x$* "$(lastword $^)" "$@"
37+
38+
# The smallest sizes are generated using a different SVG
39+
novnc-16.png novnc-24.png novnc-32.png: novnc-icon-sm.svg
4040

4141
clean:
4242
rm -f *.png

systemvm/agent/noVNC/app/images/icons/novnc-ios-120.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-152.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-167.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-180.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-40.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-58.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-60.png

Loading

systemvm/agent/noVNC/app/images/icons/novnc-ios-80.png

Loading

0 commit comments

Comments
 (0)