Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html

Issue 57483002: Implement File constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed most feedback. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html b/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html
index 4a78bd69aefc9e179a859daf1251ad8af676eea6..e111c942ef33909a94483a24adfc3cdce4664af4 100644
--- a/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html
+++ b/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html
@@ -1,57 +1,61 @@
<!DOCTYPE html>
-<html>
-<head>
- <script src="/js-test-resources/js-test.js"></script>
-</head>
-<body>
- <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 mime = xhrBlobTestCases[i].mime;
- var expectedMime = xhrBlobTestCases[i].expectedMime;
- var url = xhrBlobTestCases[i].url !== undefined ? xhrBlobTestCases[i].url + xhrBlobTestUrl : xhrBlobTestUrl;
- url += xhrBlobTestCases[i].allowOrigin || "";
- if (xhrBlobTestCases[i].shouldThrow !== undefined) {
- try {
- testBlobContentTypeSync(url, mime, expectedMime);
- } catch (e) {
- testPassed("Exception should be thrown.")
- }
- } else {
- testBlobContentTypeSync(url, mime, expectedMime);
- }
- }
- }
-
- function testBlobContentTypeSync(url, mimeType, expectedMime) {
- var blob;
- if (mimeType !== "")
- blob = new Blob(["Test content"], {type: mimeType});
- else
- blob = new Blob(["Test content"]);
-
- xhr = new XMLHttpRequest();
- xhr.open("POST", url, false);
- xhr.send(blob);
- if (xhr.status === 200) {
- expectedMimeType = JSON.parse(xhr.response)['content-type'] || "";
- shouldBeEqualToString("expectedMimeType", expectedMime);
- } else
- testFailed("Unknown error");
-
- }
-
- runSyncTests();
-
- </script>
-</body>
-</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);
+ } catch (e) {
+ testPassed("Exception should be thrown.")
+ }
+ } else {
+ testBlobContentTypeSync(url, file, mime, expectedMime);
+ }
+ }
+ }
+
+ function testBlobContentTypeSync(url, fileName, mimeType, expectedMime) {
+ 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);
+ xhr.send(blob);
+ if (xhr.status === 200) {
+ postedMimeType = JSON.parse(xhr.response)['content-type'] || "";
+ shouldBeEqualToString("postedMimeType", expectedMime);
+ } else
+ testFailed("Unknown error");
+
+ }
+
+ runSyncTests();
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698