title: How to set feature policy headers in JS
body: <p>I am getting the following errors in my console on my site:</p>
  <pre><code>Error with Feature-Policy header: Unrecognized feature: 'unsized-media'.
  Error with Feature-Policy header: Unrecognized feature: 'ambient-light-sensor'.
  Error with Feature-Policy header: Unrecognized feature: 'speaker'.
  Error with Feature-Policy header: Unrecognized feature: 'vr'.
  </code></pre>
  <p>I am a front end web developer so I'm trying to set this in JS as described here <a href="https://developers.google.com/web/updates/2018/06/feature-policy#js" rel="noreferrer">https://developers.google.com/web/updates/2018/06/feature-policy#js</a> without messing with my server config.</p>
  <pre><code>console.log(document.featurePolicy.allowedFeatures());
  </code></pre>
  <p>results in:</p>
  <pre><code>[&quot;geolocation&quot;, &quot;midi&quot;, &quot;ch-ect&quot;, &quot;usb&quot;, &quot;magnetometer&quot;, &quot;picture-in-picture&quot;, &quot;publickey-credentials-get&quot;, &quot;accelerometer&quot;, &quot;ch-lang&quot;, &quot;document-domain&quot;, &quot;encrypted-media&quot;, &quot;ch-downlink&quot;, &quot;ch-ua-arch&quot;, &quot;xr-spatial-tracking&quot;, &quot;ch-ua-platform-version&quot;, &quot;ch-width&quot;, &quot;ch-ua-model&quot;, &quot;sync-xhr&quot;, &quot;camera&quot;, &quot;ch-viewport-width&quot;, &quot;payment&quot;, &quot;ch-rtt&quot;, &quot;ch-ua-full-version&quot;, &quot;fullscreen&quot;, &quot;autoplay&quot;, &quot;ch-dpr&quot;, &quot;ch-ua-platform&quot;, &quot;screen-wake-lock&quot;, &quot;gyroscope&quot;, &quot;ch-ua-mobile&quot;, &quot;ch-device-memory&quot;, &quot;ch-ua&quot;, &quot;microphone&quot;]
  </code></pre>
  <p>Also</p>
  <pre><code>document.featurePolicy.allowsFeature('unsized-media', 'self');
  </code></pre>
  <p>results in:</p>
  <pre><code>Invalid origin url for feature 'unsized-media': self.
  </code></pre>