Bug 1347818 - Part 2. Add documentCharacterSet test. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 16 Mar 2017 15:49:14 +0900
changeset 499767 36569259e0fe909324623684ecdda8109d31c4f8
parent 499766 77174a81d63a138b36485c3dfa5248e652852834
child 549452 2e4896ca6f8064456ad06ec4c3f0d74d6d69b4a7
push id49518
push userm_kato@ga2.so-net.ne.jp
push dateThu, 16 Mar 2017 06:52:42 +0000
reviewersmasayuki
bugs1347818
milestone55.0a1
Bug 1347818 - Part 2. Add documentCharacterSet test. r?masayuki MozReview-Commit-ID: LvUNE7UNpik
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_documentCharacterSet.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -230,16 +230,17 @@ skip-if = toolkit == 'android' # bug 131
 [test_bug1328023.html]
 [test_bug1330796.html]
 [test_bug1332876.html]
 
 [test_CF_HTML_clipboard.html]
 subsuite = clipboard
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_focus.html]
+[test_documentCharacterSet.html]
 [test_dom_input_event_on_htmleditor.html]
 skip-if = toolkit == 'android' # bug 1054087
 [test_dom_input_event_on_texteditor.html]
 [test_dragdrop.html]
 skip-if = os == 'android'
 [test_inline_style_cache.html]
 [test_inlineTableEditing.html]
 [test_keypress_untrusted_event.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_documentCharacterSet.html
@@ -0,0 +1,54 @@
+<!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() {
+  const Ci = SpecialPowers.Ci;
+  let editframe = window.frames[0];
+  return SpecialPowers.wrap(editframe)
+                      .QueryInterface(Ci.nsIInterfaceRequestor)
+                      .getInterface(Ci.nsIWebNavigation)
+                      .QueryInterface(Ci.nsIInterfaceRequestor)
+                      .getInterface(Ci.nsIEditingSession)
+                      .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");
+
+  editor.documentCharacterSet = "utf-8";
+  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=utf-8",
+     "charset should be set as utf-8");
+
+  SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>