Permissions-Policy: Unload

Contact: bfcache-dev@chromium.org

This document describes the status of the current implementation of the Permissions-Policy: unload feature in Chrome, and how to enable it.

Starting from version 107, Chrome experimentally supports Permissions-Policy: unload. This allows sites to prevent usage of unload event listeners.

Note that this policy is not available by default. Chrome plans to do an origin trial to evaluate its effectiveness and to allow site authors to give feedback.

What’s supported

A new permission is added, unload, which defaults to be enabled but when disabled makes calls to window.addEventListener("unload", callback) a no-op.

What’s not supported

Activation

The policy can be enabled in several ways.

Using command line flag

Pass the --enable-features=PermissionsPolicyUnload command line flag.

Using the Chromium UI

Enable the flag chrome://flags/#enable-experimental-web-platform-features .

Using Origin Trial

The Origin Trial feature is named PermissionsPolicyUnload. Registration for the trial is here. See feature status to find out if the origin trial is currently running.

The origin trial tutorial describes how to participate.

Verifying the API is working

In devtools, run the following piece of javascript

document.createElement("iframe").allow="unload";

If it succeeds then the feature is enabled. If it gives an error like Unrecognized feature: 'unload'. then the feature is not enabled.

Related Links