summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--app/ui.js66
-rw-r--r--core/rfb.js5
-rw-r--r--core/util/browser.js6
-rw-r--r--tests/playback.js12
-rw-r--r--tests/vnc_playback.html23
-rwxr-xr-xutils/launch.sh6
-rw-r--r--vnc.html7
-rw-r--r--vnc_lite.html7
9 files changed, 62 insertions, 72 deletions
diff --git a/.travis.yml b/.travis.yml
index 20004d7..e9c4767 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ env:
- TEST_BROWSER_NAME='internet explorer' TEST_BROWSER_OS='Windows 10'
- TEST_BROWSER_NAME='internet explorer' TEST_BROWSER_OS='Windows 7'
- TEST_BROWSER_NAME=microsoftedge TEST_BROWSER_OS='Windows 10'
- - TEST_BROWSER_NAME=safari TEST_BROWSER_OS='OS X 10.12'
+ - TEST_BROWSER_NAME=safari TEST_BROWSER_OS='OS X 10.13'
before_script: npm install -g karma-cli
addons:
sauce_connect:
diff --git a/app/ui.js b/app/ui.js
index 4fe2a3f..c03f8d3 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -1,7 +1,7 @@
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin
- * Copyright (C) 2016 Samuel Mannehed for Cendio AB
+ * Copyright (C) 2018 Samuel Mannehed for Cendio AB
* Copyright (C) 2016 Pierre Ossman for Cendio AB
* Licensed under MPL 2.0 (see LICENSE.txt)
*
@@ -10,7 +10,7 @@
import * as Log from '../core/util/logging.js';
import _, { l10n } from './localization.js';
-import { isTouchDevice } from '../core/util/browser.js';
+import { isTouchDevice, dragThreshold } from '../core/util/browser.js';
import { setCapture, getPointerEvent } from '../core/util/events.js';
import KeyTable from "../core/input/keysym.js";
import keysyms from "../core/input/keysymdef.js";
@@ -340,8 +340,8 @@ const UI = {
UI.addSettingChangeHandler('encrypt');
UI.addSettingChangeHandler('resize');
- UI.addSettingChangeHandler('resize', UI.enableDisableViewClip);
UI.addSettingChangeHandler('resize', UI.applyResizeMode);
+ UI.addSettingChangeHandler('resize', UI.updateViewClip);
UI.addSettingChangeHandler('view_clip');
UI.addSettingChangeHandler('view_clip', UI.updateViewClip);
UI.addSettingChangeHandler('shared');
@@ -408,9 +408,9 @@ const UI = {
return;
}
- UI.enableDisableViewClip();
-
if (UI.connected) {
+ UI.updateViewClip();
+
UI.disableSetting('encrypt');
UI.disableSetting('shared');
UI.disableSetting('host');
@@ -432,11 +432,7 @@ const UI = {
UI.keepControlbar();
}
- // State change disables viewport dragging.
- // It is enabled (toggled) by direct click on the button
- UI.setViewDrag(false);
-
- // State change also closes the password dialog
+ // State change closes the password dialog
document.getElementById('noVNC_password_dlg')
.classList.remove('noVNC_open');
},
@@ -594,9 +590,6 @@ const UI = {
}
if (!UI.controlbarDrag) {
- // The goal is to trigger on a certain physical width, the
- // devicePixelRatio brings us a bit closer but is not optimal.
- const dragThreshold = 10 * (window.devicePixelRatio || 1);
const dragDistance = Math.abs(ptr.clientY - UI.controlbarMouseDownClientY);
if (dragDistance < dragThreshold) return;
@@ -1204,7 +1197,6 @@ const UI = {
document.body.msRequestFullscreen();
}
}
- UI.enableDisableViewClip();
UI.updateFullscreenButton();
},
@@ -1241,20 +1233,25 @@ const UI = {
* VIEW CLIPPING
* ------v------*/
- // Update parameters that depend on the viewport clip setting
+ // Update viewport clipping property for the connection. The normal
+ // case is to get the value from the setting. There are special cases
+ // for when the viewport is scaled or when a touch device is used.
updateViewClip() {
if (!UI.rfb) return;
- const cur_clip = UI.rfb.clipViewport;
- let new_clip = UI.getSetting('view_clip');
+ const scaling = UI.getSetting('resize') === 'scale';
- if (isTouchDevice) {
+ if (scaling) {
+ // Can't be clipping if viewport is scaled to fit
+ UI.forceSetting('view_clip', false);
+ UI.rfb.clipViewport = false;
+ } else if (isTouchDevice) {
// Touch devices usually have shit scrollbars
- new_clip = true;
- }
-
- if (cur_clip !== new_clip) {
- UI.rfb.clipViewport = new_clip;
+ UI.forceSetting('view_clip', true);
+ UI.rfb.clipViewport = true;
+ } else {
+ UI.enableSetting('view_clip');
+ UI.rfb.clipViewport = UI.getSetting('view_clip');
}
// Changing the viewport may change the state of
@@ -1262,18 +1259,6 @@ const UI = {
UI.updateViewDrag();
},
- // Handle special cases where viewport clipping is locked
- enableDisableViewClip() {
- const resizeSetting = UI.getSetting('resize');
- if (isTouchDevice) {
- UI.forceSetting('view_clip', true);
- } else if (resizeSetting === 'scale') {
- UI.disableSetting('view_clip');
- } else {
- UI.enableSetting('view_clip');
- }
- },
-
/* ------^-------
* /VIEW CLIPPING
* ==============
@@ -1283,16 +1268,7 @@ const UI = {
toggleViewDrag() {
if (!UI.rfb) return;
- const drag = UI.rfb.dragViewport;
- UI.setViewDrag(!drag);
- },
-
- // Set the view drag mode which moves the viewport on mouse drags
- setViewDrag(drag) {
- if (!UI.rfb) return;
-
- UI.rfb.dragViewport = drag;
-
+ UI.rfb.dragViewport = !UI.rfb.dragViewport;
UI.updateViewDrag();
},
diff --git a/core/rfb.js b/core/rfb.js
index f09e241..a52c00d 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -12,6 +12,7 @@
import * as Log from './util/logging.js';
import { decodeUTF8 } from './util/strings.js';
+import { dragThreshold } from './util/browser.js';
import EventTargetMixin from './util/eventtarget.js';
import Display from "./display.js";
import Keyboard from "./input/keyboard.js";
@@ -786,10 +787,6 @@ export default class RFB extends EventTargetMixin {
const deltaX = this._viewportDragPos.x - x;
const deltaY = this._viewportDragPos.y - y;
- // The goal is to trigger on a certain physical width, the
- // devicePixelRatio brings us a bit closer but is not optimal.
- const dragThreshold = 10 * (window.devicePixelRatio || 1);
-
if (this._viewportHasMoved || (Math.abs(deltaX) > dragThreshold ||
Math.abs(deltaY) > dragThreshold)) {
this._viewportHasMoved = true;
diff --git a/core/util/browser.js b/core/util/browser.js
index 80551d4..3eca5bc 100644
--- a/core/util/browser.js
+++ b/core/util/browser.js
@@ -1,6 +1,7 @@
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin
+ * Copyright (C) 2018 Samuel Mannehed for Cendio AB
* Licensed under MPL 2.0 (see LICENSE.txt)
*
* See README.md for usage and integration instructions.
@@ -20,6 +21,11 @@ window.addEventListener('touchstart', function onFirstTouch() {
window.removeEventListener('touchstart', onFirstTouch, false);
}, false);
+
+// The goal is to find a certain physical width, the devicePixelRatio
+// brings us a bit closer but is not optimal.
+export let dragThreshold = 10 * (window.devicePixelRatio || 1);
+
let _cursor_uris_supported = null;
export function supportsCursorURIs () {
diff --git a/tests/playback.js b/tests/playback.js
index c48a2a4..94b75be 100644
--- a/tests/playback.js
+++ b/tests/playback.js
@@ -79,6 +79,8 @@ export default class RecordingPlayer {
this._rfb.viewOnly = true;
this._rfb.addEventListener("disconnect",
this._handleDisconnect.bind(this));
+ this._rfb.addEventListener("credentialsrequired",
+ this._handleCredentials.bind(this));
this._enablePlaybackMode();
// reset the frame index and timer
@@ -89,18 +91,18 @@ export default class RecordingPlayer {
this._trafficManagement = (trafficManagement === undefined) ? !realtime : trafficManagement;
this._running = true;
-
- this._queueNextPacket();
}
// _enablePlaybackMode mocks out things not required for running playback
_enablePlaybackMode() {
+ const self = this;
this._rfb._sock.send = () => {};
this._rfb._sock.close = () => {};
this._rfb._sock.flush = () => {};
this._rfb._sock.open = function () {
this.init();
this._eventHandlers.open();
+ self._queueNextPacket();
};
}
@@ -191,4 +193,10 @@ export default class RecordingPlayer {
this._running = false;
this._disconnected(evt.detail.clean, this._frame_index);
}
+
+ _handleCredentials(evt) {
+ this._rfb.sendCredentials({"username": "Foo",
+ "password": "Bar",
+ "target": "Baz"});
+ }
}
diff --git a/tests/vnc_playback.html b/tests/vnc_playback.html
index d5f9442..353f03d 100644
--- a/tests/vnc_playback.html
+++ b/tests/vnc_playback.html
@@ -2,8 +2,22 @@
<html>
<head>
<title>VNC Playback</title>
- <script src="/vendor/browser-es-module-loader/dist/browser-es-module-loader.js"></script>
- <script type="module" src="./playback.js"></script>
+ <!-- promise polyfills promises for IE11 -->
+ <script src="../vendor/promise.js"></script>
+ <!-- ES2015/ES6 modules polyfill -->
+ <script type="module">
+ window._noVNC_has_module_support = true;
+ </script>
+ <script>
+ window.addEventListener("load", function() {
+ if (window._noVNC_has_module_support) return;
+ var loader = document.createElement("script");
+ loader.src = "../vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
+ document.head.appendChild(loader);
+ });
+ </script>
+ <!-- actual script modules -->
+ <script type="module" src="./playback-ui.js"></script>
</head>
<body>
@@ -30,10 +44,5 @@
</body>
- <!--
- <script type='text/javascript'
- src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
- -->
-
<script type="module" src="./playback-ui.js">
</html>
diff --git a/utils/launch.sh b/utils/launch.sh
index 2007c85..ee2ca5e 100755
--- a/utils/launch.sh
+++ b/utils/launch.sh
@@ -24,6 +24,8 @@ usage() {
echo " Default: ./"
echo " --ssl-only Disable non-https connections."
echo " "
+ echo " --record FILE Record traffic to FILE.session.js"
+ echo " "
exit 2
}
@@ -36,6 +38,7 @@ CERT=""
WEB=""
proxy_pid=""
SSLONLY=""
+RECORD_ARG=""
die() {
echo "$*"
@@ -63,6 +66,7 @@ while [ "$*" ]; do
--cert) CERT="${OPTARG}"; shift ;;
--web) WEB="${OPTARG}"; shift ;;
--ssl-only) SSLONLY="--ssl-only" ;;
+ --record) RECORD_ARG="--record ${OPTARG}"; shift ;;
-h|--help) usage ;;
-*) usage "Unknown chrooter option: ${param}" ;;
*) break ;;
@@ -145,7 +149,7 @@ fi
echo "Starting webserver and WebSockets proxy on port ${PORT}"
#${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} &
-${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} &
+${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} ${RECORD_ARG} &
proxy_pid="$!"
sleep 1
if ! ps -p ${proxy_pid} >/dev/null; then
diff --git a/vnc.html b/vnc.html
index 701714c..14b8558 100644
--- a/vnc.html
+++ b/vnc.html
@@ -23,7 +23,7 @@
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <!-- Icons (see Makefile for what the sizes are for) -->
+ <!-- Icons (see app/images/icons/Makefile for what the sizes are for) -->
<link rel="icon" sizes="16x16" type="image/png" href="app/images/icons/novnc-16x16.png">
<link rel="icon" sizes="24x24" type="image/png" href="app/images/icons/novnc-24x24.png">
<link rel="icon" sizes="32x32" type="image/png" href="app/images/icons/novnc-32x32.png">
@@ -56,11 +56,6 @@
<!-- Stylesheets -->
<link rel="stylesheet" href="app/styles/base.css" />
- <!--
- <script type='text/javascript'
- src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
- -->
-
<!-- this is included as a normal file in order to catch script-loading errors as well -->
<script type="text/javascript" src="app/error-handler.js"></script>
diff --git a/vnc_lite.html b/vnc_lite.html
index c580e11..e5ab3c2 100644
--- a/vnc_lite.html
+++ b/vnc_lite.html
@@ -22,7 +22,7 @@
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <!-- Icons (see Makefile for what the sizes are for) -->
+ <!-- Icons (see app/images/icons/Makefile for what the sizes are for) -->
<link rel="icon" sizes="16x16" type="image/png" href="app/images/icons/novnc-16x16.png">
<link rel="icon" sizes="24x24" type="image/png" href="app/images/icons/novnc-24x24.png">
<link rel="icon" sizes="32x32" type="image/png" href="app/images/icons/novnc-32x32.png">
@@ -55,11 +55,6 @@
<!-- Stylesheets -->
<link rel="stylesheet" href="app/styles/lite.css">
- <!--
- <script type='text/javascript'
- src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
- -->
-
<!-- promise polyfills promises for IE11 -->
<script src="vendor/promise.js"></script>
<!-- ES2015/ES6 modules polyfill -->