tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

feature-policy-trust-token-redemption.html (1386B)


      1 <script>
      2  'use strict';
      3 
      4  window.onload = function() {
      5    // When the trust-token-redemption feature policy is enabled, redemption
      6    // and signing ("send-redemption-record") should both be available; when it's disabled,
      7    // they should both be unavailable. Send the number of available operations
      8    // upstream in order to enforce this in assertions.
      9    let num_enabled = 4;
     10    try {
     11      new Request("https://issuer.example/", {
     12        trustToken: {
     13          type: "token-redemption"
     14        }
     15      });
     16    } catch (e) {
     17      num_enabled--;
     18    }
     19    try {
     20      new Request("https://destination.example/", {
     21        trustToken: {
     22          type: "send-redemption-record",
     23          issuers: ["https://issuer.example/"]
     24        }
     25      });
     26    } catch (e) {
     27      num_enabled--;
     28    }
     29 
     30    try {
     31      const xhr = new XMLHttpRequest();
     32      xhr.open("GET", "https://issuer.example/");
     33      xhr.setTrustToken({
     34        type: "token-redemption"
     35      });
     36    } catch (e) {
     37      num_enabled--;
     38    }
     39 
     40    try {
     41      const xhr = new XMLHttpRequest();
     42      xhr.open("GET", "https://destination.example/");
     43      xhr.setTrustToken({
     44        type: "send-redemption-record",
     45        issuers: ["https://issuer.example/"]
     46      });
     47    } catch (e) {
     48      num_enabled--;
     49    }
     50 
     51    parent.postMessage({
     52      num_operations_enabled: num_enabled
     53    }, '*');
     54  }
     55 </script>