tor-browser

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

download-helper.js (779B)


      1 function StreamDownloadFinishDelay() {
      2  return 1000;
      3 }
      4 
      5 function DownloadVerifyDelay() {
      6  return 1000;
      7 }
      8 
      9 async function VerifyDownload(test_obj, token) {
     10  const verifyToken = async (token) => {
     11    const url = `resources/download-stash.py?verify-token&token=${token}`;
     12    const response = await fetch(url);
     13    if (!response.ok) {
     14      throw new Error('An error happened in the server');
     15    }
     16    const message = await response.text();
     17    return message === 'TOKEN_SET';
     18  };
     19 
     20  return new Promise((resolve) => {
     21    test_obj.step_wait(
     22        async () => {
     23          const result = await verifyToken(token);
     24          resolve(result);
     25        },
     26        'Check if the download has finished or not',
     27        StreamDownloadFinishDelay() + DownloadVerifyDelay());
     28  });
     29 }