tor-browser

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

send-data-blob.htm (2189B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[2]/p[3]"/>
      5    <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
      6    <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetype-attribute"  data-tested-assertations="following::ol[1]/li[4]"/>
      7    <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute"  data-tested-assertations="following::a[contains(@href,'#blob-response-entity-body')]/.."/>
      8 
      9    <script src="/resources/testharness.js"></script>
     10    <script src="/resources/testharnessreport.js"></script>
     11    <title>XMLHttpRequest: The send() method: Blob data</title>
     12 </head>
     13 
     14 <body>
     15    <div id="log"></div>
     16 
     17    <script type="text/javascript">
     18        var test = async_test();
     19 
     20        test.step(function()
     21        {
     22            var xhr = new XMLHttpRequest();
     23            var xhr2 = new XMLHttpRequest();
     24 
     25            var content = "Hello";
     26            var blob;
     27 
     28            xhr.onreadystatechange = function()
     29            {
     30                if (xhr.readyState == 4)
     31                {
     32                    test.step(function()
     33                    {
     34                        blob = xhr.response;
     35                        assert_true(blob instanceof Blob, "Blob from XHR Response");
     36 
     37                        xhr2.open("POST", "./resources/content.py", true);
     38                        xhr2.send(blob);
     39                    });
     40                }
     41            }
     42 
     43            xhr2.onreadystatechange = function()
     44            {
     45                if (xhr2.readyState == 4)
     46                {
     47                    test.step(function()
     48                    {
     49                        assert_equals(xhr2.status, 200);
     50                        assert_equals(xhr2.response, content);
     51                        test.done();
     52                    });
     53                }
     54            };
     55 
     56            xhr.open("GET", "./resources/content.py?content=" + content, true);
     57            xhr.responseType = "blob";
     58            xhr.send();
     59        });
     60    </script>
     61 </body>
     62 </html>