permissions-policy-private-state-token-issuance.html (809B)
1 <!DOCTYPE html> 2 <script> 3 'use strict'; 4 5 window.onload = function() { 6 // Check issuance operation availability for both Request and XMLHttpRequest. 7 // They are tied to the same permission policy. They should be both enabled or disabled. 8 let num_enabled = 2; 9 try { 10 const issue_request = new Request("https://issuer.example/", { 11 privateToken: { 12 version: 1, 13 operation: "token-request" 14 } 15 }); 16 } catch (e) { 17 num_enabled--; 18 } 19 20 try { 21 const xhr = new XMLHttpRequest(); 22 xhr.open("GET", "https://issuer.example/"); 23 xhr.setPrivateToken({ 24 version: 1, 25 operation: "token-request" 26 }); 27 } catch (e) { 28 num_enabled--; 29 } 30 parent.postMessage({ 31 type: 'availability-result', 32 num_operations_enabled: num_enabled, 33 }, '*'); 34 } 35 </script>