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

Unified Diff: LayoutTests/http/tests/xmlhttprequest/resources/supported-xml-content-types.js

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/SlowTests ('k') | LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/xmlhttprequest/resources/supported-xml-content-types.js
diff --git a/LayoutTests/http/tests/xmlhttprequest/resources/supported-xml-content-types.js b/LayoutTests/http/tests/xmlhttprequest/resources/supported-xml-content-types.js
new file mode 100644
index 0000000000000000000000000000000000000000..8b30c76b577eeee09b2d00aba8a99e610ce88494
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/resources/supported-xml-content-types.js
@@ -0,0 +1,51 @@
+function getXMLOfType(testcase)
+{
+ var request = new XMLHttpRequest();
+ function failure()
+ {
+ testFailed(testcase.xmlType)
+ runNextTest();
+ }
+ function checkResult()
+ {
+ var statusText = "";
+ if (request.responseXML) {
+ var typeElement = request.responseXML.firstChild;
+ if (testcase.expectPass && typeElement) {
+ if (typeElement.textContent !== testcase.xmlType)
+ statusText = "Incorrect content: " + typeElement.textContent;
+ } else {
+ statusText = "Document type: " + request.getResponseHeader("Content-type");
+ }
+ } else if (testcase.expectPass) {
+ statusText = "Response type: " + request.getResponseHeader("Content-type");
+ }
+ if (statusText)
+ testFailed(testcase.xmlType + " -- " + statusText + "; responseXML: " + new XMLSerializer().serializeToString(request.responseXML));
+ else
+ testPassed(testcase.xmlType);
+
+ runNextTest();
+ }
+
+ var escapedType = escape(testcase.xmlType).replace(/\+/g, "^^PLUS^^"); // Perl CGI module seems replace + with a space
+ request.open("GET", "supported-xml-content-types.cgi?type=" + escapedType, true);
+ request.onerror = checkResult;
+ request.onload = checkResult;
+ request.send(null);
+}
+
+var tests = [];
+
+function testXMLType(type, expected)
+{
+ tests.push({xmlType: type, expectPass: expected});
+}
+
+function runNextTest()
+{
+ if (tests.length)
+ getXMLOfType(tests.shift());
+ else
+ finishJSTest();
+}
« no previous file with comments | « LayoutTests/SlowTests ('k') | LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698