Truly independent web browser
LibWeb: Import asynchronous XHR timeout override coverage
Andreas Kling094a165294f9
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 4ac99b1ff7f..d87558e1400 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -88,6 +88,12 @@ Text/input/wpt-import/html/semantics/embedded-content/the-img-element/image-loadText/input/wpt-import/picture-in-picture/Text/input/wpt-import/video-rvfc/+; XHR timeout tests use WPT Python handlers, which need the HTTP server.+Text/input/wpt-import/xhr/xmlhttprequest-timeout-overrides.html+Text/input/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires.html+Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides.html+Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires.html+; fetching a file only works from an HTTP server.Text/input/wpt-import/fetch/api/basic/text-utf8.any.htmlText/input/wpt-import/fetch/api/abort/general.any.htmldiff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout disabled after initially set.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout disabled after initially set.txtnew file mode 100644index 00000000000..556524e8a10--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout disabled after initially set.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout disabled after initially set, original timeout at 5000, reset at 2000 to 0\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout enabled after initially disabled.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout enabled after initially disabled.txtnew file mode 100644index 00000000000..65177b2cfe7--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout enabled after initially disabled.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout enabled after initially disabled, original timeout at 0, reset at 2000 to 50000\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout overrides load after a delay.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout overrides load after a delay.txtnew file mode 100644index 00000000000..3b82df1a3f5--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overrides@timeout overrides load after a delay.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Timeout test: timeout overrides load after a delay, original timeout at 5000, reset at 1000 to 2000\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expired value before load fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expired value before load fires.txtnew file mode 100644index 00000000000..93cecc4b34d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expired value before load fires.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Timeout test: timeout set to expired value before load fires, original timeout at 5000, reset at 2000 to 1100\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expiring value after load fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expiring value after load fires.txtnew file mode 100644index 00000000000..bb2cc750948--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to expiring value after load fires.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout set to expiring value after load fires, original timeout at 5000, reset at 4000 to 1000\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to non-expiring value after timeout fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to non-expiring value after timeout fires.txtnew file mode 100644index 00000000000..fa4ed7ff03d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires@timeout set to non-expiring value after timeout fires.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout set to non-expiring value after timeout fires, original timeout at 1000, reset at 2000 to 500\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout disabled after initially set.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout disabled after initially set.txtnew file mode 100644index 00000000000..556524e8a10--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout disabled after initially set.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout disabled after initially set, original timeout at 5000, reset at 2000 to 0\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout enabled after initially disabled.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout enabled after initially disabled.txtnew file mode 100644index 00000000000..65177b2cfe7--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout enabled after initially disabled.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Timeout test: timeout enabled after initially disabled, original timeout at 0, reset at 2000 to 50000\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout overrides load after a delay.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout overrides load after a delay.txtnew file mode 100644index 00000000000..3b82df1a3f5--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides@timeout overrides load after a delay.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Timeout test: timeout overrides load after a delay, original timeout at 5000, reset at 1000 to 2000\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expired value before load fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expired value before load fires.txtnew file mode 100644index 00000000000..0c9217e6c44--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expired value before load fires.txt@@ -0,0 +1,9 @@+Harness status: OK++Found 3 tests++2 Pass+1 Fail+Pass Timeout test: timeout set to expiring value after load fires, original timeout at 5000, reset at 4000 to 1000+Fail Timeout test: timeout set to expired value before load fires, original timeout at 5000, reset at 2000 to 1100+Pass Timeout test: timeout set to non-expiring value after timeout fires, original timeout at 1000, reset at 2000 to 500\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expiring value after load fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expiring value after load fires.txtnew file mode 100644index 00000000000..0c9217e6c44--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to expiring value after load fires.txt@@ -0,0 +1,9 @@+Harness status: OK++Found 3 tests++2 Pass+1 Fail+Pass Timeout test: timeout set to expiring value after load fires, original timeout at 5000, reset at 4000 to 1000+Fail Timeout test: timeout set to expired value before load fires, original timeout at 5000, reset at 2000 to 1100+Pass Timeout test: timeout set to non-expiring value after timeout fires, original timeout at 1000, reset at 2000 to 500\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to non-expiring value after timeout fires.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to non-expiring value after timeout fires.txtnew file mode 100644index 00000000000..0c9217e6c44--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires@timeout set to non-expiring value after timeout fires.txt@@ -0,0 +1,9 @@+Harness status: OK++Found 3 tests++2 Pass+1 Fail+Pass Timeout test: timeout set to expiring value after load fires, original timeout at 5000, reset at 4000 to 1000+Fail Timeout test: timeout set to expired value before load fires, original timeout at 5000, reset at 2000 to 1100+Pass Timeout test: timeout set to non-expiring value after timeout fires, original timeout at 1000, reset at 2000 to 500\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overrides.js b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overrides.jsnew file mode 100644index 00000000000..be8e4a95503--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overrides.js@@ -0,0 +1,12 @@+if (this.document === undefined)+ importScripts("xmlhttprequest-timeout.js");+/*+Sets up three requests to a resource that will take 0.6 seconds to load:+1) timeout first set to TIME_NORMAL_LOAD, after TIME_REGULAR_TIMEOUT timeout is set to 0, asserts load fires+2) timeout first set to TIME_NORMAL_LOAD, after TIME_DELAY timeout is set to TIME_REGULAR_TIMEOUT, asserts load fires (race condition..?!?)+3) timeout first set to 0, after TIME_REGULAR_TIMEOUT it is set to TIME_REGULAR_TIMEOUT * 10, asserts load fires+*/++runTestRequests([ ["RequestTracker", true, "timeout disabled after initially set", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, 0],+ ["RequestTracker", true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT],+ ["RequestTracker", true, "timeout enabled after initially disabled", 0, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD * 10] ]);diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overridesexpires.js b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overridesexpires.jsnew file mode 100644index 00000000000..5151b5d5610--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-overridesexpires.js@@ -0,0 +1,12 @@+if (this.document === undefined)+ importScripts("xmlhttprequest-timeout.js");+/*+ Starts three requests:+ 1) XHR to resource which will take a least TIME_XHR_LOAD ms with timeout initially set to TIME_NORMAL_LOAD ms. After TIME_LATE_TIMEOUT ms timeout is supposedly reset to TIME_DELAY ms,+ but the resource should have finished loading already. Asserts "load" fires.+ 2) XHR with initial timeout set to TIME_NORMAL_LOAD, after TIME_REGULAR_TIMEOUT sets timeout to TIME_DELAY+100. Asserts "timeout" fires.+ 3) XHR with initial timeout set to TIME_DELAY, after TIME_REGULAR_TIMEOUT sets timeout to 500ms. Asserts "timeout" fires (the change happens when timeout already fired and the request is done).+*/+runTestRequests([ ["RequestTracker", true, "timeout set to expiring value after load fires", TIME_NORMAL_LOAD, TIME_LATE_TIMEOUT, TIME_DELAY],+ ["RequestTracker", true, "timeout set to expired value before load fires", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_DELAY+100],+ ["RequestTracker", true, "timeout set to non-expiring value after timeout fires", TIME_DELAY, TIME_REGULAR_TIMEOUT, 500] ]);diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-runner.js b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-runner.jsnew file mode 100644index 00000000000..151226a94fb--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout-runner.js@@ -0,0 +1,21 @@++function testResultCallbackHandler(event) {+ if (event.data == "done") {+ done();+ return;+ }+ if (event.data.type == "is") {+ test(function() { assert_equals(event.data.got, event.data.expected); }, "Timeout test: " + event.data.msg);+ return;+ }+ if (event.data.type == "ok") {+ test(function() { assert_true(event.data.bool); }, "Timeout test: " + event.data.msg);+ return;+ }+}++window.addEventListener("message", testResultCallbackHandler);++// Setting up testharness.js+setup({ explicit_done: true });+diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout.js b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout.jsnew file mode 100644index 00000000000..9375bab7f3b--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/resources/xmlhttprequest-timeout.js@@ -0,0 +1,333 @@+/* Test adapted from Alex Vincent's XHR2 timeout tests, written for Mozilla.+ https://hg.mozilla.org/mozilla-central/file/tip/content/base/test/+ Released into the public domain or under BSD, according to+ https://bugzilla.mozilla.org/show_bug.cgi?id=525816#c86+*/++/* Notes:+ - All times are expressed in milliseconds in this test suite.+ - Test harness code is at the end of this file.+ - We generate only one request at a time, to avoid overloading the HTTP+ request handlers.+ */++var TIME_NORMAL_LOAD = 5000;+var TIME_LATE_TIMEOUT = 4000;+var TIME_XHR_LOAD = 3000;+var TIME_REGULAR_TIMEOUT = 2000;+var TIME_SYNC_TIMEOUT = 1000;+var TIME_DELAY = 1000;++/*+ * This should point to a resource that responds with a text/plain resource after a delay of TIME_XHR_LOAD milliseconds.+ */+var STALLED_REQUEST_URL = "delay.py?ms=" + (TIME_XHR_LOAD);++var inWorker = false;+try {+ inWorker = !(self instanceof Window);+} catch (e) {+ inWorker = true;+}++if (!inWorker)+ STALLED_REQUEST_URL = "resources/" + STALLED_REQUEST_URL;++function message(obj) {+ if (inWorker)+ self.postMessage(obj);+ else+ self.postMessage(obj, "*");+}++function is(got, expected, msg) {+ var obj = {};+ obj.type = "is";+ obj.got = got;+ obj.expected = expected;+ obj.msg = msg;++ message(obj);+}++function ok(bool, msg) {+ var obj = {};+ obj.type = "ok";+ obj.bool = bool;+ obj.msg = msg;++ message(obj);+}++/**+ * Generate and track results from a XMLHttpRequest with regards to timeouts.+ *+ * @param {String} id The test description.+ * @param {Number} timeLimit The initial setting for the request timeout.+ * @param {Number} resetAfter (Optional) The time after sending the request, to+ * reset the timeout.+ * @param {Number} resetTo (Optional) The delay to reset the timeout to.+ *+ * @note The actual testing takes place in handleEvent(event).+ * The requests are generated in startXHR().+ *+ * @note If resetAfter and resetTo are omitted, only the initial timeout setting+ * applies.+ *+ * @constructor+ * @implements DOMEventListener+ */+function RequestTracker(async, id, timeLimit /*[, resetAfter, resetTo]*/) {+ this.async = async;+ this.id = id;+ this.timeLimit = timeLimit;++ if (arguments.length > 3) {+ this.mustReset = true;+ this.resetAfter = arguments[3];+ this.resetTo = arguments[4];+ }++ this.hasFired = false;+}+RequestTracker.prototype = {+ /**+ * Start the XMLHttpRequest!+ */+ startXHR: function() {+ var req = new XMLHttpRequest();+ this.request = req;+ req.open("GET", STALLED_REQUEST_URL, this.async);+ var me = this;+ function handleEvent(e) { return me.handleEvent(e); };+ req.onerror = handleEvent;+ req.onload = handleEvent;+ req.onabort = handleEvent;+ req.ontimeout = handleEvent;++ req.timeout = this.timeLimit;++ if (this.mustReset) {+ var resetTo = this.resetTo;+ self.setTimeout(function() {+ req.timeout = resetTo;+ }, this.resetAfter);+ }++ try {+ req.send(null);+ }+ catch (e) {+ // Synchronous case in workers.+ ok(!this.async && this.timeLimit < TIME_XHR_LOAD && e.name == "TimeoutError", "Unexpected error: " + e);+ TestCounter.testComplete();+ }+ },++ /**+ * Get a message describing this test.+ *+ * @returns {String} The test description.+ */+ getMessage: function() {+ var rv = this.id + ", ";+ if (this.mustReset) {+ rv += "original timeout at " + this.timeLimit + ", ";+ rv += "reset at " + this.resetAfter + " to " + this.resetTo;+ }+ else {+ rv += "timeout scheduled at " + this.timeLimit;+ }+ return rv;+ },++ /**+ * Check the event received, and if it's the right (and only) one we get.+ *+ * @param {DOMProgressEvent} evt An event of type "load" or "timeout".+ */+ handleEvent: function(evt) {+ if (this.hasFired) {+ ok(false, "Only one event should fire: " + this.getMessage());+ return;+ }+ this.hasFired = true;++ var type = evt.type, expectedType;+ // The XHR responds after TIME_XHR_LOAD milliseconds with a load event.+ var timeLimit = this.mustReset && (this.resetAfter < Math.min(TIME_XHR_LOAD, this.timeLimit)) ?+ this.resetTo :+ this.timeLimit;+ if ((timeLimit == 0) || (timeLimit >= TIME_XHR_LOAD)) {+ expectedType = "load";+ }+ else {+ expectedType = "timeout";+ }+ is(type, expectedType, this.getMessage());+ TestCounter.testComplete();+ }+};++/**+ * Generate and track XMLHttpRequests which will have abort() called on.+ *+ * @param shouldAbort {Boolean} True if we should call abort at all.+ * @param abortDelay {Number} The time in ms to wait before calling abort().+ */+function AbortedRequest(shouldAbort, id, abortDelay) {+ this.shouldAbort = shouldAbort;+ this.abortDelay = abortDelay;+ this.hasFired = false;+}+AbortedRequest.prototype = {+ /**+ * Start the XMLHttpRequest!+ */+ startXHR: function() {+ var req = new XMLHttpRequest();+ this.request = req;+ req.open("GET", STALLED_REQUEST_URL);+ var _this = this;+ function handleEvent(e) { return _this.handleEvent(e); };+ req.onerror = handleEvent;+ req.onload = handleEvent;+ req.onabort = handleEvent;+ req.ontimeout = handleEvent;++ req.timeout = TIME_REGULAR_TIMEOUT;++ function abortReq() {+ req.abort();+ }++ if (!this.shouldAbort) {+ self.setTimeout(function() {+ try {+ _this.noEventsFired();+ }+ catch (e) {+ ok(false, "Unexpected error: " + e);+ TestCounter.testComplete();+ }+ }, TIME_NORMAL_LOAD);+ }+ else {+ // Abort events can only be triggered on sent requests.+ req.send();+ if (this.abortDelay == -1) {+ abortReq();+ }+ else {+ self.setTimeout(abortReq, this.abortDelay);+ }+ }+ },++ /**+ * Ensure that no events fired at all, especially not our timeout event.+ */+ noEventsFired: function() {+ ok(!this.hasFired, "No events should fire for an unsent, unaborted request");+ // We're done; if timeout hasn't fired by now, it never will.+ TestCounter.testComplete();+ },++ /**+ * Get a message describing this test.+ *+ * @returns {String} The test description.+ */+ getMessage: function() {+ return "time to abort is " + this.abortDelay + ", timeout set at " + TIME_REGULAR_TIMEOUT;+ },++ /**+ * Check the event received, and if it's the right (and only) one we get.+ *+ * WebKit fires abort events even for DONE and UNSENT states, which is+ * discussed in http://webkit.org/b/98404+ * That's why we chose to accept secondary "abort" events in this test.+ *+ * @param {DOMProgressEvent} evt An event of type "load" or "timeout".+ */+ handleEvent: function(evt) {+ if (this.hasFired && evt.type != "abort") {+ ok(false, "Only abort event should fire: " + this.getMessage());+ return;+ }++ var expectedEvent = (this.abortDelay >= TIME_REGULAR_TIMEOUT && !this.hasFired) ? "timeout" : "abort";+ this.hasFired = true;+ is(evt.type, expectedEvent, this.getMessage());+ TestCounter.testComplete();+ }+};++function SyncRequestSettingTimeoutAfterOpen() {+ this.startXHR = function() {+ var pass = false;+ var req = new XMLHttpRequest();+ req.open("GET", STALLED_REQUEST_URL, false);+ try {+ req.timeout = TIME_SYNC_TIMEOUT;+ }+ catch (e) {+ pass = true;+ }+ ok(pass, "Synchronous XHR must not allow a timeout to be set - setting timeout must throw");+ TestCounter.testComplete();+ };+ return this;+};++function SyncRequestSettingTimeoutBeforeOpen() {+ this.startXHR = function() {+ var pass = false;+ var req = new XMLHttpRequest();+ req.timeout = TIME_SYNC_TIMEOUT;+ try {+ req.open("GET", STALLED_REQUEST_URL, false);+ }+ catch (e) {+ pass = true;+ }+ ok(pass, "Synchronous XHR must not allow a timeout to be set - calling open() after timeout is set must throw");+ TestCounter.testComplete();+ }+ return this;+};++var TestRequests = [];++// This code controls moving from one test to another.+var TestCounter = {+ testComplete: function() {+ // Allow for the possibility there are other events coming.+ self.setTimeout(function() {+ TestCounter.next();+ }, TIME_NORMAL_LOAD);+ },++ next: function() {+ var test = TestRequests.shift();++ if (test) {+ test.startXHR();+ }+ else {+ message("done");+ }+ }+};++function runTestRequests(testRequests) {+ if (location.search) {+ testRequests = testRequests.filter(test => test[2] == decodeURIComponent(location.search.substr(1)));+ }+ TestRequests = testRequests.map(test => {+ var constructor = test.shift();+ return new self[constructor](...test)+ });+ TestCounter.next();+}diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overrides.html b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overrides.htmlnew file mode 100644index 00000000000..64539ad8ed3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overrides.html@@ -0,0 +1,26 @@+ <!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>XHR2 Timeout Property Tests</title>+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />+ <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>+ <meta name=timeout content=long>+ <meta name=variant content="?timeout disabled after initially set">+ <meta name=variant content="?timeout overrides load after a delay">+ <meta name=variant content="?timeout enabled after initially disabled">+ <script src="../resources/testharness.js"></script>+ <script src="../resources/testharnessreport.js"></script>+ <script src="resources/xmlhttprequest-timeout.js"></script>+ <script src="resources/xmlhttprequest-timeout-runner.js"></script>+</head>+<body>+ <h1>Description</h1>+ <p>This test validates that the XHR2 timeout property behaves as expected in async cases in document (i.e. non-worker) context.</p>+ <div id="log"></div>+ <script src="resources/xmlhttprequest-timeout-overrides.js"></script>+</body>+</html>+diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires.html b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires.htmlnew file mode 100644index 00000000000..8b9ad555dc5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-overridesexpires.html@@ -0,0 +1,26 @@+ <!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>XHR2 Timeout Property Tests</title>+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />+ <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />+ <meta name=timeout content=long>+ <meta name=variant content="?timeout set to expiring value after load fires">+ <meta name=variant content="?timeout set to expired value before load fires">+ <meta name=variant content="?timeout set to non-expiring value after timeout fires">+ <script src="../resources/testharness.js"></script>+ <script src="../resources/testharnessreport.js"></script>+ <script src="resources/xmlhttprequest-timeout.js"></script>+ <script src="resources/xmlhttprequest-timeout-runner.js"></script>+</head>+<body>+ <h1>Description</h1>+ <p>This test validates that the XHR2 timeout property behaves as expected in async cases in document (i.e. non-worker) context.</p>+ <div id="log"></div>+ <script src="resources/xmlhttprequest-timeout-overridesexpires.js" type="text/javascript"></script>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides.html b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides.htmlnew file mode 100644index 00000000000..c3f42d72e1b--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overrides.html@@ -0,0 +1,27 @@+ <!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>XHR2 Timeout Property Tests in Worker</title>+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />+ <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>+ <meta name=timeout content=long>+ <meta name=variant content="?timeout disabled after initially set">+ <meta name=variant content="?timeout overrides load after a delay">+ <meta name=variant content="?timeout enabled after initially disabled">+ <script src="../resources/testharness.js"></script>+ <script src="../resources/testharnessreport.js"></script>+ <script src="resources/xmlhttprequest-timeout-runner.js"></script>+</head>+<body>+ <h1>Description</h1>+ <p>This test validates that the XHR2 timeout property behaves as expected in in a worker context.</p>+ <div id="log"></div>+ <script type="text/javascript">+ var worker = new Worker("resources/xmlhttprequest-timeout-overrides.js" + location.search);+ worker.addEventListener("message", testResultCallbackHandler);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires.html b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires.htmlnew file mode 100644index 00000000000..a1e518c492e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/xhr/xmlhttprequest-timeout-worker-overridesexpires.html@@ -0,0 +1,28 @@+ <!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>XHR2 Timeout Property Tests in Worker</title>+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />+ <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>+ <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />+ <meta name=timeout content=long>+ <meta name=variant content="?timeout set to expiring value after load fires">+ <meta name=variant content="?timeout set to expired value before load fires">+ <meta name=variant content="?timeout set to non-expiring value after timeout fires">+ <script src="../resources/testharness.js"></script>+ <script src="../resources/testharnessreport.js"></script>+ <script src="resources/xmlhttprequest-timeout-runner.js"></script>+</head>+<body>+ <h1>Description</h1>+ <p>This test validates that the XHR2 timeout property behaves as expected in in a worker context.</p>+ <div id="log"></div>+ <script type="text/javascript">+ var worker = new Worker("resources/xmlhttprequest-timeout-overridesexpires.js");+ worker.addEventListener("message", testResultCallbackHandler);+ </script>+</body>+</html>