Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

2.5 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>load test</title>
</head>
<body>
<div>Number of participants: <span id="participants">1</span></div>
<script>
    /**
     * Wrapper page for the load-test client (react/features/load-test), uploaded into the browser by Malleus.
     * Loads config.js and lib-jitsi-meet from the deployment under test, then the uploaded client bundle, which
     * reads its parameters from this page's URL hash. The parameters this page itself needs are:
     * - domain: the deployment's host;
     * - tenant: the deployment's tenant path (e.g. "torture/"), if any, for the location of config.js;
     * - bundle: the local path of the uploaded load-test-participant bundle;
     * - room: the room, also read by the client; passed along when fetching config.js as jitsi-meet does, so
     *   that deployments which route by room name serve the config of the shard the room lives on.
     * Values are JSON-encoded like all jitsi-meet URL parameters.
     */
    const params = {};

    (document.location.hash || '').substring(1).split('&').forEach(part => {
        const [ key, value ] = part.split('=');

        if (![ 'domain', 'tenant', 'bundle', 'room' ].includes(key)) {
            return;
        }
        try {
            params[key] = JSON.parse(decodeURIComponent(value));
        } catch (e) {
            console.error(`Failed to parse URL parameter ${key}`, e);
        }
    });

    function log(msg) {
        console.log(`${new Date().toISOString()} [LoadTestPage] ${msg}`);
    }

    function loadScript(src) {
        return new Promise((resolve, reject) => {
            const script = document.createElement('script');

            script.src = src;
            script.onload = () => {
                log(`loaded ${src}`);
                resolve();
            };
            script.onerror = () => reject(new Error(`Failed to load ${src}`));
            document.head.appendChild(script);
        });
    }

    const { domain, tenant = '', bundle, room } = params;

    if (!domain || !bundle) {
        log('Missing the domain or bundle parameter, not starting.');
    } else {
        loadScript(`https://${domain}/${tenant}config.js${room ? `?room=${encodeURIComponent(room)}` : ''}`)
            .then(() => loadScript(`https://${domain}/libs/lib-jitsi-meet.min.js`))
            .then(() => loadScript(bundle.startsWith('file://') ? bundle : `file://${bundle}`))
            .catch(e => console.error(e));
    }
</script>
</body>
</html>