v151 · Web APIs · Policy Demo

Policy Demo

Feature-detects the Permissions Policy directives available in this browser session and shows which header pattern applies — pre-Chrome 151 or post-merger.

The Direct Sockets API is only available inside Isolated Web Apps (IWAs). Feature detection below checks for API surface availability; actual socket use requires the IWA context and the relevant Permissions Policy headers served by the app manifest.

directive feature detection

document.featurePolicy supported
local-network allowed by page
loopback-network allowed by page
direct-sockets-private (legacy) allowed
navigator.openTCPSocket available
navigator.openUDPSocket available
Recommended header pattern

header comparison

# Pre-Chrome 151: three separate directives
Permissions-Policy: direct-sockets=*, direct-sockets-private=*, local-network=*

# Chrome 151+: direct-sockets-private is subsumed
# Use local-network for RFC 1918 private ranges
# Use loopback-network for 127.0.0.1 / ::1
Permissions-Policy: direct-sockets=*, local-network=*, loopback-network=*

# For backwards compatibility during rollout (Chrome 149–151 transition):
# Include all four — browsers ignore unknown directives, so this is safe
Permissions-Policy: direct-sockets=*, direct-sockets-private=*, local-network=*, loopback-network=*

detection code

// Feature-detect which directive pattern is supported
function getDirectSocketsHeaderPattern() {
  const fp = document.featurePolicy;
  if (!fp) return 'feature-policy API not supported';

  const hasLocal = fp.allowedFeatures().includes('local-network');
  const hasLoopback = fp.allowedFeatures().includes('loopback-network');
  const hasLegacy = fp.allowedFeatures().includes('direct-sockets-private');

  if (hasLocal && hasLoopback && !hasLegacy) {
    return 'Chrome 151+ merged directives';
  }
  if (hasLegacy) {
    return 'Legacy: direct-sockets-private directive active';
  }
  return 'Neither pattern detected (IWA context required for full access)';
}

// TCP socket availability (IWA only)
const tcpAvail = typeof navigator.openTCPSocket === 'function';
const udpAvail = typeof navigator.openUDPSocket === 'function';

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗