summaryrefslogtreecommitdiffstats
path: root/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html')
-rw-r--r--dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html b/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html
new file mode 100644
index 0000000000..99e6bde004
--- /dev/null
+++ b/dom/xhr/tests/test_xhr_overridemimetype_throws_on_invalid_state.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test bug 482935</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href=" /tests/SimpleTest/test.css" />
+</head>
+<body onload="onWindowLoad()">
+<script class="testbody" type="text/javascript">"use strict";
+SimpleTest.waitForExplicitFinish();
+
+var url = "file_XHR_pass1.xml";
+
+function onWindowLoad() {
+ runTest();
+}
+
+function runTest() {
+ var testFunctions = [
+ function() { testOverMimeTypeThrowsDuringReadyState(3, "text/plain"); },
+ function() { testOverMimeTypeThrowsDuringReadyState(3, "text/plain;charset=Shift-JIS"); },
+ function() { testOverMimeTypeThrowsDuringReadyState(4, "text/plain"); },
+ function() { testOverMimeTypeThrowsDuringReadyState(4, "text/plain;charset=Shift-JIS"); },
+ ];
+
+ function nextTest() {
+ if (!testFunctions.length) {
+ SimpleTest.finish();
+ return;
+ }
+ (testFunctions.shift())();
+ }
+
+ nextTest();
+
+ function testOverMimeTypeThrowsDuringReadyState(readyState, mimeType) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === readyState) {
+ try {
+ xhr.overrideMimeType(mimeType);
+ ok(false, "No exception thrown, but expected InvalidStateError" +
+ " for readyState=" + readyState + ", mimeType=" + mimeType);
+ } catch(exc) {
+ is(exc.name, "InvalidStateError", "Expected InvalidStateError, got " + exc.name +
+ " for readyState=" + readyState + ", mimeType=" + mimeType);
+ }
+ }
+ if (xhr.readyState === 4) {
+ isnot(xhr.responseXML, null, "responseXML was null" +
+ " for readyState=" + readyState +
+ ", mimeType=" + mimeType);
+ nextTest();
+ }
+ }
+ xhr.open("GET", url);
+ xhr.send();
+ }
+}
+</script>
+</body>
+</html>