fune/editor/libeditor/tests/test_documentCharacterSet.html
Mark Banner e824d800fb Bug 1489980 - Enable ESLint for editor/ - Manual fixes. r=masayuki
This enables the editor directory to be linted, and fixes the remaining issues raised by ESLint. Various rules were fixed here including, no-shadow, no-undef, no-unused-vars and others.

I've generally gone conservative, disabling rules where it doesn't make sense to fix them (e.g. sometimes suggests use-services for tests, but it is only used once, or within a Chrome script).

Depends on D5585

Differential Revision: https://phabricator.services.mozilla.com/D5587

--HG--
extra : moz-landing-system : lando
2018-09-13 07:59:47 +00:00

59 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script type="application/javascript" 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>