diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /editor/libeditor/tests/test_documentCharacterSet.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'editor/libeditor/tests/test_documentCharacterSet.html')
-rw-r--r-- | editor/libeditor/tests/test_documentCharacterSet.html | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_documentCharacterSet.html b/editor/libeditor/tests/test_documentCharacterSet.html new file mode 100644 index 0000000000..d8ee10b06b --- /dev/null +++ b/editor/libeditor/tests/test_documentCharacterSet.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<html> +<head> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none;"> + +</div> + +<iframe></iframe> + +<pre id="test"> + +<script class="testbody" type="application/javascript"> +function getEditor() { + let editframe = window.frames[0]; + return SpecialPowers.wrap(editframe).docShell.editingSession + .getEditorForWindow(editframe); +} + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(function() { + let editdoc = window.frames[0].document; + editdoc.designMode = "on"; + let editor = getEditor(); + + editor.documentCharacterSet = "us-ascii"; + let meta = editdoc.getElementsByTagName("meta")[0]; + is(meta.getAttribute("http-equiv"), "Content-Type", + "meta element should have http-equiv"); + is(meta.getAttribute("content"), "text/html;charset=us-ascii", + "charset should be set as us-ascii"); + + let dummyMeta = editdoc.createElement("meta"); + dummyMeta.setAttribute("name", "keywords"); + dummyMeta.setAttribute("content", "test"); + meta.parentNode.insertBefore(dummyMeta, meta); + + editor.documentCharacterSet = "utf-8"; + + meta = editdoc.getElementsByTagName("meta")[0]; + isnot(meta.getAttribute("http-equiv"), "Content-Type", + "first meta element shouldn't have http-equiv"); + + meta = editdoc.getElementsByTagName("meta")[1]; + is(meta.getAttribute("http-equiv"), "Content-Type", + "second meta element should have http-equiv"); + is(meta.getAttribute("content"), "text/html;charset=utf-8", + "charset should be set as utf-8"); + + SimpleTest.finish(); +}); +</script> +</pre> +</body> +</html> |