tor-browser

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

request-init-001.sub.html (5625B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title>Request init: simple cases</title>
      6    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
      7    <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
      8    <script src="/resources/testharness.js"></script>
      9    <script src="/resources/testharnessreport.js"></script>
     10  </head>
     11  <body>
     12    <script>
     13      // https://fetch.spec.whatwg.org/#concept-method-normalize
     14      var methods = {
     15        "givenValues" : [
     16          "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS",
     17          "get", "head", "post", "put", "delete", "options",
     18          "Get", "hEad", "poSt", "Put", "deleTe", "optionS",
     19          "PATCH", "patch", "patCh"
     20        ],
     21        "expectedValues" : [
     22          "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS",
     23          "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS",
     24          "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS",
     25          "PATCH", "patch", "patCh"
     26        ]
     27      };
     28      var referrers = {"givenValues" : ["/relative/ressource",
     29                                        "http://{{host}}:{{ports[http][0]}}/relative/ressource?query=true#fragment",
     30                                        "http://{{host}}:{{ports[http][0]}}/",
     31                                        "http://test.url",
     32                                        "about:client",
     33                                        ""
     34                                       ],
     35                       "expectedValues" : ["http://{{host}}:{{ports[http][0]}}/relative/ressource",
     36                                           "http://{{host}}:{{ports[http][0]}}/relative/ressource?query=true#fragment",
     37                                           "http://{{host}}:{{ports[http][0]}}/",
     38                                           "about:client",
     39                                           "about:client",
     40                                           ""
     41                                          ]
     42      };
     43      var referrerPolicies = {"givenValues" : [ "",
     44                                                "no-referrer",
     45                                                "no-referrer-when-downgrade",
     46                                                "origin",
     47                                                "origin-when-cross-origin",
     48                                                "unsafe-url",
     49                                                "same-origin",
     50                                                "strict-origin",
     51                                                "strict-origin-when-cross-origin"
     52                                              ],
     53                              "expectedValues" : ["",
     54                                                  "no-referrer",
     55                                                  "no-referrer-when-downgrade",
     56                                                  "origin",
     57                                                  "origin-when-cross-origin",
     58                                                  "unsafe-url",
     59                                                  "same-origin",
     60                                                  "strict-origin",
     61                                                  "strict-origin-when-cross-origin"
     62                                                  ]
     63      };
     64      var modes = {"givenValues" : ["same-origin", "no-cors", "cors"],
     65                   "expectedValues" : ["same-origin", "no-cors", "cors"]
     66      };
     67      var credentials = {"givenValues" : ["omit", "same-origin", "include"],
     68                          "expectedValues" : ["omit", "same-origin", "include"]
     69      };
     70      var caches = {"givenValues" : [ "default", "no-store", "reload", "no-cache", "force-cache"],
     71                    "expectedValues" : [ "default", "no-store", "reload", "no-cache", "force-cache"]
     72      };
     73      var redirects = {"givenValues" : ["follow", "error", "manual"],
     74                       "expectedValues" : ["follow", "error", "manual"]
     75      };
     76      var integrities = {"givenValues" : ["", "AZERTYUIOP1234567890" ],
     77                         "expectedValues" : ["", "AZERTYUIOP1234567890"]
     78      };
     79 
     80      //there is no getter for window, init's window might be null
     81      var windows = {"givenValues" : [ null ],
     82                     "expectedValues" : [undefined]
     83      };
     84 
     85      var initValuesDict = { "method" : methods,
     86                             "referrer" : referrers,
     87                             "referrerPolicy" : referrerPolicies,
     88                             "mode" : modes,
     89                             "credentials" : credentials,
     90                             "cache" : caches,
     91                             "redirect" : redirects,
     92                             "integrity" : integrities,
     93                             "window" : windows
     94      };
     95 
     96      for (var attributeName in initValuesDict) {
     97        var valuesToTest = initValuesDict[attributeName];
     98        for (var valueIdx in valuesToTest["givenValues"]) {
     99          var givenValue = valuesToTest["givenValues"][valueIdx];
    100          var expectedValue = valuesToTest["expectedValues"][valueIdx];
    101          test(function() {
    102            var requestInit = {};
    103            requestInit[attributeName] = givenValue
    104            var request = new Request("", requestInit);
    105            assert_equals(request[attributeName], expectedValue,
    106              "Expect request's " + attributeName + " is " + expectedValue + " when initialized with " + givenValue);
    107          }, "Check " + attributeName + " init value of " + givenValue + " and associated getter");
    108        }
    109      }
    110    </script>
    111  </body>
    112 </html>