diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/html/test/test_bug1472426.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/test_bug1472426.html')
-rw-r--r-- | dom/html/test/test_bug1472426.html | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/dom/html/test/test_bug1472426.html b/dom/html/test/test_bug1472426.html new file mode 100644 index 0000000000..6f891184b8 --- /dev/null +++ b/dom/html/test/test_bug1472426.html @@ -0,0 +1,120 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1472426 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1472426</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + + /** Test for Bug 1472426 **/ + + var shadowIframe; + var targetIframe; + var form; + var sr; + + function checkMPSubmission(sub, expected, test) { + function getPropCount(o) { + var x, l = 0; + for (x in o) ++l; + return l; + } + function mpquote(s) { + return s.replace(/\r\n/g, " ") + .replace(/\r/g, " ") + .replace(/\n/g, " ") + .replace(/\"/g, "\\\""); + } + + is(sub.length, expected.length, + "Correct number of multipart items in " + test); + + if (sub.length != expected.length) { + alert(JSON.stringify(sub)); + } + + var i; + for (i = 0; i < expected.length; ++i) { + if (!("fileName" in expected[i])) { + is(sub[i].headers["Content-Disposition"], + "form-data; name=\"" + mpquote(expected[i].name) + "\"", + "Correct name in " + test); + is (getPropCount(sub[i].headers), 1, + "Wrong number of headers in " + test); + is(sub[i].body, + expected[i].value.replace(/\r\n|\r|\n/, "\r\n"), + "Correct value in " + test); + } + else { + is(sub[i].headers["Content-Disposition"], + "form-data; name=\"" + mpquote(expected[i].name) + "\"; filename=\"" + + mpquote(expected[i].fileName) + "\"", + "Correct name in " + test); + is(sub[i].headers["Content-Type"], + expected[i].contentType, + "Correct content type in " + test); + is (getPropCount(sub[i].headers), 2, + "Wrong number of headers in " + test); + is(sub[i].body, + expected[i].value, + "Correct value in " + test); + } + } + } + + function testFormSubmissionInShadowDOM() { + targetIframe = document.getElementById("target_iframe"); + shadowIframe = document.createElement("iframe"); + shadowIframe.src = "about:blank"; + shadowIframe.onload = shadowFrameCreated; + document.body.appendChild(shadowIframe); + } + + function shadowFrameCreated() { + var doc = shadowIframe.contentDocument; + var body = doc.body; + var host = doc.createElement("div"); + body.appendChild(host); + sr = host.attachShadow({ mode: "open" }); + sr.appendChild(document.getElementById('template').content.cloneNode(true)); + targetIframe.onload = checkSubmitValues; + sr.getElementById("form").submit(); + } + + function checkSubmitValues() { + submission = JSON.parse(targetIframe.contentDocument.documentElement.textContent); + var expected = [ + { name: "text", value: "textvalue" }, + { name: "hidden", value: "hiddenvalue" }, + { name: "select", value: "selectvalue" }, + { name: "textarea", value: "textareavalue" } + ]; + checkMPSubmission(submission, expected, "form submission inside shadow DOM"); + SimpleTest.finish(); + } + + window.onload = function() { + SimpleTest.waitForExplicitFinish(); + testFormSubmissionInShadowDOM(); + } + + </script> + <template id="template"> + <form action="form_submit_server.sjs" target="target_iframe" id="form" + method="POST" enctype="multipart/form-data"> + <input name="text" value="textvalue"> + <input name="hidden" value="hiddenvalue" type="hidden"> + <select name="select"><option selected>selectvalue</option></select> + <textarea name="textarea">textareavalue</textarea> + </form> + </template> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1472426">Mozilla Bug 1472426</a> +<iframe name="target_iframe" id="target_iframe"></iframe> +</body> +</html> |