CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-9/

WebRTC Compatibility Detector

A utility that detects WebRTC browser compatibility and reports available features after compatibility shims have been applied.

Problem

Build a WebRTC compatibility detector that analyzes the current browser environment and reports which WebRTC features are available. The tool should work across different browsers (Chrome, Firefox, Safari) and benefit from compatibility layers that automatically normalize browser differences.

Your implementation should:

  1. Detect the current browser type and version
  2. Check for the availability of core WebRTC APIs:
    • RTCPeerConnection
    • getUserMedia (via navigator.mediaDevices.getUserMedia)
    • RTCSessionDescription
    • RTCIceCandidate
  3. Return a report object containing browser information and feature availability

The detector should work seamlessly across different browser environments, taking advantage of any compatibility shims that normalize WebRTC APIs.

Requirements

  • Export a function detectWebRTCSupport() that returns a compatibility report object
  • The report must include:
    • browser: Browser name string (e.g., "chrome", "firefox", "safari")
    • version: Browser version number
    • features: Object with boolean values indicating feature availability
      • RTCPeerConnection: true if available
      • getUserMedia: true if available
      • RTCSessionDescription: true if available
      • RTCIceCandidate: true if available
  • Tests should verify the report structure and that features are properly detected

@generates

API

/**
 * Detects WebRTC feature availability in the current browser.
 *
 * @returns {Object} Compatibility report with browser info and feature availability
 * @returns {string} return.browser - Browser name
 * @returns {number} return.version - Browser version
 * @returns {Object} return.features - Map of feature names to availability booleans
 */
function detectWebRTCSupport() {
  // IMPLEMENTATION HERE
}

module.exports = {
  detectWebRTCSupport
};

Test Cases

  • Calling detectWebRTCSupport() returns an object with browser, version, and features properties @test
  • The features.RTCPeerConnection property is true when RTCPeerConnection is available (either natively or via shim) @test
  • The features.getUserMedia property is true when navigator.mediaDevices.getUserMedia is available @test
  • The returned browser is a non-empty string and version is a positive number @test

Dependencies { .dependencies }

webrtc-adapter { .dependency }

Provides cross-browser WebRTC compatibility by automatically applying browser-specific shims on import.

Install with Tessl CLI

npx tessl i tessl/npm-webrtc-adapter

tile.json