tor-browser

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

mode-same-origin.any.js (1303B)


      1 // META: script=../resources/utils.js
      2 // META: script=/common/get-host-info.sub.js
      3 
      4 function fetchSameOrigin(url, shouldPass) {
      5  promise_test(function(test) {
      6    if (shouldPass)
      7      return fetch(url , {"mode": "same-origin"}).then(function(resp) {
      8        assert_equals(resp.status, 200, "HTTP status is 200");
      9        assert_equals(resp.type, "basic", "response type is basic");
     10      });
     11    else
     12      return promise_rejects_js(test, TypeError, fetch(url, {mode: "same-origin"}));
     13  }, "Fetch "+ url + " with same-origin mode");
     14 }
     15 
     16 var host_info = get_host_info();
     17 
     18 fetchSameOrigin(RESOURCES_DIR + "top.txt", true);
     19 fetchSameOrigin(host_info.HTTP_ORIGIN + "/fetch/api/resources/top.txt", true);
     20 fetchSameOrigin(host_info.HTTPS_ORIGIN + "/fetch/api/resources/top.txt", false);
     21 fetchSameOrigin(host_info.HTTP_REMOTE_ORIGIN + "/fetch/api/resources/top.txt", false);
     22 
     23 var redirPath = dirname(location.pathname) + RESOURCES_DIR + "redirect.py?location=";
     24 
     25 fetchSameOrigin(redirPath + RESOURCES_DIR + "top.txt", true);
     26 fetchSameOrigin(redirPath + host_info.HTTP_ORIGIN + "/fetch/api/resources/top.txt", true);
     27 fetchSameOrigin(redirPath + host_info.HTTPS_ORIGIN + "/fetch/api/resources/top.txt", false);
     28 fetchSameOrigin(redirPath + host_info.HTTP_REMOTE_ORIGIN + "/fetch/api/resources/top.txt", false);