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

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html

Issue 198893002: Make supported-xml-content-types.html tests faster. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More splitting Created 6 years, 9 months 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML>
2 <script src="/js-test-resources/js-test.js"></script>
3 <script src="resources/supported-xml-content-types.js"></script>
1 <script> 4 <script>
5 description("Test identification of XML content type in XHR responses.");
6 window.jsTestIsAsync = true;
2 if (window.testRunner) 7 if (window.testRunner)
3 testRunner.dumpAsText(); 8 testRunner.dumpAsText();
4 9
5 var request = new XMLHttpRequest();
6
7 function getXMLOfType(type)
8 {
9 var escapedType = escape(type).replace(/\+/g, "^^PLUS^^"); // Perl CGI modul e seems replace + with a space
10 request.open("GET", "supported-xml-content-types.cgi?type=" + escapedType, f alse);
11 request.send(null);
12 return request.responseXML;
13 }
14
15 function testXMLType(type, expected)
16 {
17 var xmlResult = getXMLOfType(type);
18 var statusText = "FAIL (response type: " + request.getResponseHeader("Conten t-type") + ")";
19
20 if (xmlResult) {
21 statusText = "FAIL (got document -- response type: " + request.getRespon seHeader("Content-type") + ")";
22 var typeElement = xmlResult.firstChild;
23 if (expected && typeElement) {
24 if (typeElement.textContent == type)
25 statusText = "PASS";
26 else
27 statusText = "FAIL (incorrect content: " + typeElement.textConte nt + " expected: " + type + ")";
28 }
29 } else if (!expected)
30 statusText = "PASS";
31
32 document.write("<p>" + statusText + " -- testing: " + type + " -- responseXM L: " + xmlResult + "</p>");
33 }
34
35 // valid types 10 // valid types
36 testXMLType("text/xml", true); 11 testXMLType("text/xml", true);
37 testXMLType("image/svg+xml", true); 12 testXMLType("image/svg+xml", true);
38 testXMLType("application/soap+xml", true); 13 testXMLType("application/soap+xml", true);
39 testXMLType("foo/bar+xml", true); 14 testXMLType("foo/bar+xml", true);
40 testXMLType("123/BAR+xml", true); 15 testXMLType("123/BAR+xml", true);
41 16
42 // They may be strange, but these should all be valid:
43 testXMLType("foo_bar/baz+xml", true);
44 testXMLType("foo-bar/baz+xml", true);
45 testXMLType("foo+bar/baz+xml", true);
46 testXMLType("foo~bar/baz+xml", true);
47 testXMLType("foo!bar/baz+xml", true);
48 testXMLType("foo$bar/baz+xml", true);
49 testXMLType("foo^bar/baz+xml", true);
50 testXMLType("foo{bar/baz+xml", true);
51 testXMLType("foo}bar/baz+xml", true);
52 testXMLType("foo|bar/baz+xml", true);
53 testXMLType("foo%bar/baz+xml", true);
54 testXMLType("foo'bar/baz+xml", true);
55 testXMLType("foo`bar/baz+xml", true);
56 testXMLType("foo#bar/baz+xml", true);
57 testXMLType("foo&bar/baz+xml", true);
58 testXMLType("foo*bar/baz+xml", true);
59
60 // non-xml types 17 // non-xml types
61 testXMLType("text/html", false); 18 testXMLType("text/html", false);
62 testXMLType("image/png", false); 19 testXMLType("image/png", false);
63 20
64
65 // invalid types 21 // invalid types
66 testXMLType("invalid", false); 22 testXMLType("invalid", false);
67 23
68 // FIXME: our code intentionally skips spaces, that seems wrong to me. 24 runNextTest();
69 // https://bugs.webkit.org/show_bug.cgi?id=8644
70 testXMLType("foo bar/baz+xml", false);
71
72 testXMLType("foo[bar/baz+xml", false);
73 testXMLType("foo]bar/baz+xml", false);
74 testXMLType("foo(bar/baz+xml", false);
75 testXMLType("foo)bar/baz+xml", false);
76 testXMLType("foo<bar/baz+xml", false);
77 testXMLType("foo>bar/baz+xml", false);
78 testXMLType("foo@bar/baz+xml", false);
79 testXMLType("foo,bar/baz+xml", false);
80 testXMLType("foo;bar/baz+xml", false);
81 testXMLType("foo:bar/baz+xml", false);
82 testXMLType("foo\\bar/baz+xml", false);
83 testXMLType('foo"bar/baz+xml', false);
84 testXMLType("foo/bar/baz+xml", false);
85 testXMLType("foo?bar/baz+xml", false);
86 testXMLType("foo=bar/baz+xml", false);
87
88 </script> 25 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698