Skip to content

Commit 7b21a32

Browse files
committed
[grid] Loading live view under https
Fixes SeleniumHQ/docker-selenium#1450
1 parent 5382a49 commit 7b21a32

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

javascript/grid-ui/src/components/RunningSessions/RunningSessions.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function createSessionData (
7979
nodeUri: string,
8080
sessionDurationMillis: number,
8181
slot: any,
82-
hostname: string
82+
origin: string
8383
): SessionData {
8484
const parsed = JSON.parse(capabilities) as Capabilities
8585
const browserName = parsed.browserName
@@ -88,8 +88,10 @@ function createSessionData (
8888
let vnc: string = parsed['se:vnc'] ?? ''
8989
if (vnc.length > 0) {
9090
try {
91-
const url = new URL(vnc)
92-
url.hostname = hostname
91+
const url = new URL(origin)
92+
const vncUrl = new URL(vnc)
93+
url.pathname = vncUrl.pathname
94+
url.protocol = 'https:' === url.protocol ? 'wss:' : 'ws:'
9395
vnc = url.href
9496
} catch (error) {
9597
console.log(error)
@@ -252,7 +254,7 @@ const useStyles = (theme: Theme): StyleRules => createStyles(
252254

253255
interface RunningSessionsProps {
254256
sessions: SessionData[]
255-
hostname: string
257+
origin: string
256258
classes: any
257259
}
258260

@@ -373,7 +375,7 @@ class RunningSessions extends React.Component<RunningSessionsProps, RunningSessi
373375
}
374376

375377
render (): ReactNode {
376-
const { sessions, hostname, classes } = this.props
378+
const { sessions, origin, classes } = this.props
377379
const {
378380
dense,
379381
order,
@@ -394,7 +396,7 @@ class RunningSessions extends React.Component<RunningSessionsProps, RunningSessi
394396
session.nodeUri,
395397
session.sessionDurationMillis,
396398
session.slot,
397-
hostname
399+
origin
398400
)
399401
})
400402
const emptyRows = rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage)

javascript/grid-ui/src/screens/Sessions/Sessions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Sessions extends React.Component<SessionsProps, SessionsState> {
119119
<Grid container spacing={3}>
120120
<RunningSessions
121121
sessions={data.sessionsInfo.sessions}
122-
hostname={window.location.hostname}
122+
origin={window.location.origin}
123123
/>
124124
<QueuedSessions
125125
sessionQueueRequests={data.sessionsInfo.sessionQueueRequests}/>

0 commit comments

Comments
 (0)