demo · v140

Nav Policy Tester

In a kiosk you don't trust the embedded page — you trust the URL whitelist. Controlled Frame fires newwindow and permissionrequest events that a host page can intercept. This tester lets you author a glob whitelist and dry-run navigation attempts against it.

allow list (one pattern per line)

test a navigation

// Inside the IWA: bind the navigation interceptor.
const frame = document.querySelector("controlledframe");
const allow = ["https://example.com/*", "https://*.wikipedia.org/wiki/*"];

frame.addEventListener("newwindow", e => {
  if (!allow.some(p => matchGlob(p, e.targetUrl))) e.preventDefault();
});

frame.addEventListener("beforeunload", e => {
  // Trap reloads to a confirmation
});

how the matcher works

Each rule is a glob: * matches host labels (not / within a path) and ** matches anything. Schemes are matched verbatim. This is the same shape the Controlled Frame proposal uses for the partition and navigation events on the host element, mirroring how the WebView2 partition system works.

see also