chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/post-blob-content-type-sync.html

<!DOCTYPE html>

<script src="/js-test-resources/js-test.js"></script>
<script src="post-blob-content-type-tests.js"></script>
<script type="text/javascript">
  description("Test verifies that content MIME type is set correctly " +
              "when Blob is sent using " +
              "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest synchronously.</a>");

  var xhr;
  var expectedMimeType;

  function runSyncTests() {
      var testCount = xhrBlobTestCases.length;
      for (var i = 0; i < testCount; i++) {
          var testCase = xhrBlobTestCases[i];
          var mime = testCase.mime;
          var file = testCase.file;
          var expectedMime = testCase.expectedMime;
          var url = testCase.url !== undefined ? testCase.url + xhrBlobTestUrl : xhrBlobTestUrl;
          url += testCase.allowOrigin || "";
          if (testCase.shouldThrow !== undefined) {
              try {
                  testBlobContentTypeSync(url, file, mime, expectedMime, testCase.closeBeforeSend);
              } catch (e) {
                  testPassed("Exception should be thrown.")
              }
          } else {
              testBlobContentTypeSync(url, file, mime, expectedMime);
          }
      }
  }

  function testBlobContentTypeSync(url, fileName, mimeType, expectedMime, closeBeforeSend) {
      var blob;
      if (fileName) {
          if (mimeType !== "")
              blob = new File(["Test content"], fileName, {type: mimeType});
          else
              blob = new File(["Test content"], fileName);
      } else {
          if (mimeType !== "")
              blob = new Blob(["Test content"], {type: mimeType});
          else
              blob = new Blob(["Test content"]);
      }

      xhr = new XMLHttpRequest();
      xhr.open("POST", url, false);
      if (closeBeforeSend)
          blob.close();
      xhr.send(blob);
      if (xhr.status === 200) {
          postedMimeType = JSON.parse(xhr.response)['content-type'];
          if (expectedMime === '') {
              shouldBeTrue("postedMimeType === undefined");
          } else {
              shouldBeEqualToString("postedMimeType", expectedMime);
          }
      } else
          testFailed("Unknown error");

  }

  runSyncTests();

</script>