Browse Source

Tests/LibWeb: Verify XHR.response is an instance of Document

This verifies that XHR.response is an instance of Document when
XHR.responseType is set to 'document' and the response contains HTML.
Kenneth Myhra 1 year ago
parent
commit
09487679eb

+ 1 - 0
Tests/LibWeb/Text/expected/XHR/XMLHttpRequest-response-gives-Document.txt

@@ -0,0 +1 @@
+PASS

+ 18 - 0
Tests/LibWeb/Text/input/XHR/XMLHttpRequest-response-gives-Document.html

@@ -0,0 +1,18 @@
+<script src="../include.js"></script>
+<script>
+    asyncTest((done) => {
+        const xhr = new XMLHttpRequest();
+        xhr.responseType = "document";
+        xhr.open("GET", "data:text/html,<!DOCTYPE html><html/>", true);
+        xhr.onreadystatechange = function() {
+            if (xhr.readyState === 4 && xhr.status === 200) {
+                if (xhr.response instanceof Document)
+                    println("PASS");
+                else
+                    println("FAIL");
+                done();
+            }
+        };
+        xhr.send();
+    });
+</script>