summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/open-after-stop.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/xhr/open-after-stop.window.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/xhr/open-after-stop.window.js')
-rw-r--r--testing/web-platform/tests/xhr/open-after-stop.window.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/xhr/open-after-stop.window.js b/testing/web-platform/tests/xhr/open-after-stop.window.js
new file mode 100644
index 0000000000..e836a523f8
--- /dev/null
+++ b/testing/web-platform/tests/xhr/open-after-stop.window.js
@@ -0,0 +1,43 @@
+// window.stop() below prevents the load event from firing, so wait until it is
+// fired to start the test.
+setup({explicit_done: true });
+
+onload = () => {
+ async_test(function(t) {
+ const client = new XMLHttpRequest();
+
+ const result = [];
+ const expected = [
+ 'readystatechange', 0, 1, // open()
+ ];
+
+ let state = 0;
+
+ client.onreadystatechange = t.step_func(() => {
+ result.push('readystatechange', state, client.readyState);
+ });
+ client.onabort = t.unreached_func("abort should not be fired after window.stop() and open()");
+ client.onloadend = t.unreached_func("loadend should not be fired after window.stop() and open()");
+
+ client.open("GET", "resources/well-formed.xml");
+ assert_equals(client.readyState, 1);
+
+ state = 1;
+ client.send(null);
+ state = 2;
+ window.stop();
+ // Unlike client.abort(), window.stop() does not change readyState
+ // immediately, rather through a task...
+ assert_equals(client.readyState, 1);
+ state = 3;
+ // ... which is then canceled when we open a new request anyway.
+ client.open("GET", "resources/well-formed.xml");
+ assert_equals(client.readyState, 1);
+ assert_array_equals(result, expected);
+
+ // Give the abort and loadend events a chance to fire (erroneously) before
+ // calling this a success.
+ t.step_timeout(t.step_func_done(), 1000);
+ }, "open() after window.stop()");
+ done();
+};