diff --git a/dom/encoding/test/Makefile.in b/dom/encoding/test/Makefile.in index a3e9e64c4b1f..36f836d0a9b6 100644 --- a/dom/encoding/test/Makefile.in +++ b/dom/encoding/test/Makefile.in @@ -10,22 +10,22 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk +TEST_DIRS = unit + +XPCSHELL_TESTS = unit + MOCHITEST_FILES = \ test_BOMEncoding.js \ test_TextDecoder.html \ test_TextDecoder.js \ test_TextEncoder.html \ test_TextEncoder.js \ - test-big5.js \ - test-euc-jp.js \ - test-euc-kr.js \ - test-gbk.js \ - test-hz-gb-2312.js \ - test-iso-2022-jp.js \ - test-iso-2022-kr.js \ - test-shift_jis.js \ test_stringencoding.html \ - tests.js \ + $(NULL) + +MOCHITEST_CHROME_FILES = \ + file_stringencoding.jsm \ + test_stringencoding.xul \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/encoding/test/file_stringencoding.jsm b/dom/encoding/test/file_stringencoding.jsm new file mode 100644 index 000000000000..79f78bb2309b --- /dev/null +++ b/dom/encoding/test/file_stringencoding.jsm @@ -0,0 +1,6 @@ +var EXPORTED_SYMBOLS = ['checkFromJSM']; + +function checkFromJSM(is_op) { + is_op(new TextDecoder().encoding, "utf-8", "JSM should have TextDecoder"); + is_op(new TextEncoder().encoding, "utf-8", "JSM should have TextEncoder"); +} diff --git a/dom/encoding/test/stringencoding-license.txt b/dom/encoding/test/stringencoding-license.txt index 343557be674f..da3146b42e18 100644 --- a/dom/encoding/test/stringencoding-license.txt +++ b/dom/encoding/test/stringencoding-license.txt @@ -1,12 +1,12 @@ The following files are licensed under Apache License 2.0 : -test-big5.js -test-euc-jp.js -test-euc-kr.js -test-gbk.js -test-hz-gb-2312.js -test-iso-2022-jp.js -test-iso-2022-kr.js -test-shift_jis.js test_stringencoding.html -tests.js +unit/test_big5.js +unit/test_euc-jp.js +unit/test_euc-kr.js +unit/test_gbk.js +unit/test_hz-gb-2312.js +unit/test_iso-2022-jp.js +unit/test_iso-2022-kr.js +unit/test_shift_jis.js +unit/test_singlebytes.js diff --git a/dom/encoding/test/test_stringencoding.html b/dom/encoding/test/test_stringencoding.html index 1155274b2ac3..b686d238109e 100644 --- a/dom/encoding/test/test_stringencoding.html +++ b/dom/encoding/test/test_stringencoding.html @@ -13,18 +13,18 @@ expect = function() {};
- + - + - + - + - - - + + + - - + + diff --git a/dom/encoding/test/test_stringencoding.xul b/dom/encoding/test/test_stringencoding.xul new file mode 100644 index 000000000000..9e47ad44d97a --- /dev/null +++ b/dom/encoding/test/test_stringencoding.xul @@ -0,0 +1,26 @@ + + + + + + diff --git a/dom/encoding/test/unit/Makefile.in b/dom/encoding/test/unit/Makefile.in new file mode 100644 index 000000000000..19a4ed53e1ed --- /dev/null +++ b/dom/encoding/test/unit/Makefile.in @@ -0,0 +1,26 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_FILES = \ + test_big5.js \ + test_euc-jp.js \ + test_euc-kr.js \ + test_gbk.js \ + test_hz-gb-2312.js \ + test_iso-2022-jp.js \ + test_iso-2022-kr.js \ + test_shift_jis.js \ + test_singlebytes.js \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + diff --git a/dom/encoding/test/unit/head.js b/dom/encoding/test/unit/head.js new file mode 100644 index 000000000000..7d10a228feaa --- /dev/null +++ b/dom/encoding/test/unit/head.js @@ -0,0 +1,43 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +const { 'classes': Cc, 'interfaces': Ci } = Components; + +function equal(a, b, msg) { + dump("equal(" + a + ", " + b + ", \"" + msg + "\")"); + do_check_eq(a, b, Components.stack.caller); +} + +function ok(cond, msg) { + dump("ok(" + cond + ", \"" + msg + "\")"); + do_check_true(!!cond, Components.stack.caller); +} + +function raises(func) { + dump("raises(" + func + ")"); + try { + func(); + do_check_true(false, Components.stack.caller); + } catch (e) { + do_check_true(true, Components.stack.caller); + } +} + +var tests = []; + +function test(msg, no, func) { + tests.push({msg: msg, func: func || no}); +} + +function expect(count) { + dump("expect(", count, ")"); +} + +function run_test() { + tests.forEach(function(t) { + dump("test(\"" + t.msg + "\")"); + t.func(); + }); +}; diff --git a/dom/encoding/test/test-big5.js b/dom/encoding/test/unit/test_big5.js similarity index 100% rename from dom/encoding/test/test-big5.js rename to dom/encoding/test/unit/test_big5.js diff --git a/dom/encoding/test/test-euc-jp.js b/dom/encoding/test/unit/test_euc-jp.js similarity index 100% rename from dom/encoding/test/test-euc-jp.js rename to dom/encoding/test/unit/test_euc-jp.js diff --git a/dom/encoding/test/test-euc-kr.js b/dom/encoding/test/unit/test_euc-kr.js similarity index 100% rename from dom/encoding/test/test-euc-kr.js rename to dom/encoding/test/unit/test_euc-kr.js diff --git a/dom/encoding/test/test-gbk.js b/dom/encoding/test/unit/test_gbk.js similarity index 100% rename from dom/encoding/test/test-gbk.js rename to dom/encoding/test/unit/test_gbk.js diff --git a/dom/encoding/test/test-hz-gb-2312.js b/dom/encoding/test/unit/test_hz-gb-2312.js similarity index 100% rename from dom/encoding/test/test-hz-gb-2312.js rename to dom/encoding/test/unit/test_hz-gb-2312.js diff --git a/dom/encoding/test/test-iso-2022-jp.js b/dom/encoding/test/unit/test_iso-2022-jp.js similarity index 100% rename from dom/encoding/test/test-iso-2022-jp.js rename to dom/encoding/test/unit/test_iso-2022-jp.js diff --git a/dom/encoding/test/test-iso-2022-kr.js b/dom/encoding/test/unit/test_iso-2022-kr.js similarity index 100% rename from dom/encoding/test/test-iso-2022-kr.js rename to dom/encoding/test/unit/test_iso-2022-kr.js diff --git a/dom/encoding/test/test-shift_jis.js b/dom/encoding/test/unit/test_shift_jis.js similarity index 100% rename from dom/encoding/test/test-shift_jis.js rename to dom/encoding/test/unit/test_shift_jis.js diff --git a/dom/encoding/test/tests.js b/dom/encoding/test/unit/test_singlebytes.js similarity index 100% rename from dom/encoding/test/tests.js rename to dom/encoding/test/unit/test_singlebytes.js diff --git a/dom/encoding/test/unit/xpcshell.ini b/dom/encoding/test/unit/xpcshell.ini new file mode 100644 index 000000000000..c616e59e7fc2 --- /dev/null +++ b/dom/encoding/test/unit/xpcshell.ini @@ -0,0 +1,13 @@ +[DEFAULT] +head = head.js +tail = + +[test_big5.js] +[test_euc-jp.js] +[test_euc-kr.js] +[test_gbk.js] +[test_hz-gb-2312.js] +[test_iso-2022-jp.js] +[test_iso-2022-kr.js] +[test_shift_jis.js] +[test_singlebytes.js] diff --git a/testing/xpcshell/xpcshell.ini b/testing/xpcshell/xpcshell.ini index 45059c8ca9be..70f030c7014d 100644 --- a/testing/xpcshell/xpcshell.ini +++ b/testing/xpcshell/xpcshell.ini @@ -9,6 +9,7 @@ [include:uriloader/exthandler/tests/unit/xpcshell.ini] [include:parser/xml/test/unit/xpcshell.ini] [include:image/test/unit/xpcshell.ini] +[include:dom/encoding/test/unit/xpcshell.ini] [include:dom/plugins/test/unit/xpcshell.ini] [include:dom/sms/tests/xpcshell.ini] [include:dom/mms/tests/xpcshell.ini]