tor-browser

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

authentication-basic.any.js (927B)


      1 // META: global=window,worker
      2 
      3 function basicAuth(desc, user, pass, mode, status) {
      4  promise_test(function(test) {
      5    var headers = { "Authorization": "Basic " + btoa(user + ":" + pass)};
      6    var requestInit = {"credentials": mode, "headers": headers};
      7    return fetch("../resources/authentication.py?realm=test", requestInit).then(function(resp) {
      8        assert_equals(resp.status, status, "HTTP status is " + status);
      9        assert_equals(resp.type , "basic", "Response's type is basic");
     10    });
     11  }, desc);
     12 }
     13 
     14 basicAuth("User-added Authorization header with include mode", "user", "password", "include", 200);
     15 basicAuth("User-added Authorization header with same-origin mode", "user", "password", "same-origin", 200);
     16 basicAuth("User-added Authorization header with omit mode", "user", "password", "omit", 200);
     17 basicAuth("User-added bogus Authorization header with omit mode", "notuser", "notpassword", "omit", 401);