Bug 877500 - Test. r=joshmoz
authorSteven Michaud <smichaud@pobox.com>
Tue, 18 Jun 2013 10:18:59 -0500
changeset 146970 175f9d9b9918dc477f1438bc119b06bd4895538f
parent 146969 d4518f89e75a3731a8676308f3c73a55bc1abdde
child 146971 cbf6498d13537b4d5af2008b65775a5be022a0f6
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoshmoz
bugs877500
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 877500 - Test. r=joshmoz
uriloader/exthandler/tests/mochitest/Makefile.in
uriloader/exthandler/tests/mochitest/test_badMimeType.html
--- a/uriloader/exthandler/tests/mochitest/Makefile.in
+++ b/uriloader/exthandler/tests/mochitest/Makefile.in
@@ -11,11 +11,12 @@ relativesrcdir	= @relativesrcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES =	\
 		test_handlerApps.xhtml \
 		test_unsafeBidiChars.xhtml \
 		handlerApps.js \
 		handlerApp.xhtml \
 		unsafeBidiFileName.sjs \
+		test_badMimeType.html \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/uriloader/exthandler/tests/mochitest/test_badMimeType.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Crashtest for bad MIME type</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+  const Cc = SpecialPowers.Cc;
+  const Ci = SpecialPowers.Ci;
+  const mimeService = Cc["@mozilla.org/mime;1"].
+                      getService(Ci.nsIMIMEService);
+  // "text/plain" has an 0xFF character appended to it.  This means it's an
+  // invalid string, which is tricky to enter using a text editor (I used
+  // emacs' hexl-mode).  It also means an ordinary text editor might drop it
+  // or convert it to something that *is* valid (in UTF8).  So we measure
+  // its length to make sure this hasn't happened.
+  var badMimeType = "text/plain˙";
+  ok(badMimeType.length == 11, "badMimeType has changed, making this test invalid");
+  mimeService.getFromTypeAndExtension(badMimeType, "txt");
+  ok(true, "The test shouldn't trigger a crash");
+</script>
+</pre>
+</body>
+</html>