Bug 1613139 - Enable ESLint for intl/uconv (manual changes). r=hsivonen

Depends on D61583

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2020-02-05 08:43:49 +00:00
parent b3e53ab97f
commit 53b74572ff
14 changed files with 113 additions and 99 deletions

View file

@ -130,8 +130,6 @@ dom/workers/test/importScripts_worker_imported3.js
dom/workers/test/invalid.js dom/workers/test/invalid.js
dom/workers/test/threadErrors_worker1.js dom/workers/test/threadErrors_worker1.js
# intl/ exclusions
intl/uconv/
# Bug 1527075: This directory is linted in github repository # Bug 1527075: This directory is linted in github repository
intl/l10n/ intl/l10n/

View file

@ -64,14 +64,13 @@ var decoders = [
"UTF-8" "UTF-8"
]; ];
var decoder;
for (var i = 0; i < decoders.length; i++) { for (var i = 0; i < decoders.length; i++) {
var decoder = decoders[i]; var decoder = decoders[i];
var data = encodeURI(testContent); var data = encodeURI(testContent);
var dataURI = "data:text/html;charset=" + decoder + "," + data; var dataURI = "data:text/html;charset=" + decoder + "," + data;
var testFrame = document.createElement("iframe"); var testFrame = document.createElement("iframe");
frameID = decoder; let frameID = decoder;
testFrame.setAttribute("id", frameID); testFrame.setAttribute("id", frameID);
var testFrameObj = document.body.appendChild(testFrame); var testFrameObj = document.body.appendChild(testFrame);
if (i < decoders.length) if (i < decoders.length)

View file

@ -13,6 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=445886
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* eslint-disable no-eval */
/** Test that unicode non-characters are not discarded **/ /** Test that unicode non-characters are not discarded **/
function test() function test()
{ {
@ -20,6 +22,7 @@ function test()
SimpleTest.finish(); SimpleTest.finish();
} }
// eslint-disable-next-line complexity
function Inject() function Inject()
{ {
// script fragments containing Unicode non-characters // script fragments containing Unicode non-characters

View file

@ -13,6 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=445886
<body onload="Inject()"> <body onload="Inject()">
<pre id="test"><script class="testbody" type="text/javascript"> <pre id="test"><script class="testbody" type="text/javascript">
/* eslint-disable no-eval */
/** Test that unicode non-characters are not discarded **/ /** Test that unicode non-characters are not discarded **/
function test() function test()
{ {
@ -20,272 +22,273 @@ function test()
SimpleTest.finish(); SimpleTest.finish();
} }
// eslint-disable-next-line complexity
function Inject() function Inject()
{ {
// script fragments containing Unicode non-characters // script fragments containing Unicode non-characters
try { try {
// U+FDD0 // U+FDD0
eval("$(\"display\").inner„0ú2HTML += \" U+FDD0 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>2HTML += \" U+FDD0 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD1 // U+FDD1
eval("$(\"display\").inner„0ú3HTML += \" U+FDD1 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>3HTML += \" U+FDD1 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD2 // U+FDD2
eval("$(\"display\").inner„0ú4HTML += \" U+FDD2 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>4HTML += \" U+FDD2 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD3 // U+FDD3
eval("$(\"display\").inner„0ú5HTML += \" U+FDD3 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>5HTML += \" U+FDD3 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD4 // U+FDD4
eval("$(\"display\").inner„0ú6HTML += \" U+FDD4 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>6HTML += \" U+FDD4 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD5 // U+FDD5
eval("$(\"display\").inner„0ú7HTML += \" U+FDD5 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>7HTML += \" U+FDD5 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD6 // U+FDD6
eval("$(\"display\").inner„0ú8HTML += \" U+FDD6 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+FDD6 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD7 // U+FDD7
eval("$(\"display\").inner„0ú9HTML += \" U+FDD7 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+FDD7 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD8 // U+FDD8
eval("$(\"display\").inner„0û0HTML += \" U+FDD8 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>0HTML += \" U+FDD8 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDD9 // U+FDD9
eval("$(\"display\").inner„0û1HTML += \" U+FDD9 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>1HTML += \" U+FDD9 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDA // U+FDDA
eval("$(\"display\").inner„0û2HTML += \" U+FDDA is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>2HTML += \" U+FDDA is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDB // U+FDDB
eval("$(\"display\").inner„0û3HTML += \" U+FDDB is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>3HTML += \" U+FDDB is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDC // U+FDDC
eval("$(\"display\").inner„0û4HTML += \" U+FDDC is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>4HTML += \" U+FDDC is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDD // U+FDDD
eval("$(\"display\").inner„0û5HTML += \" U+FDDD is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>5HTML += \" U+FDDD is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDE // U+FDDE
eval("$(\"display\").inner„0û6HTML += \" U+FDDE is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>6HTML += \" U+FDDE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDDF // U+FDDF
eval("$(\"display\").inner„0û7HTML += \" U+FDDF is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>7HTML += \" U+FDDF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE0 // U+FDE0
eval("$(\"display\").inner„0û8HTML += \" U+FDE0 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+FDE0 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE1 // U+FDE1
eval("$(\"display\").inner„0û9HTML += \" U+FDE1 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+FDE1 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE2 // U+FDE2
eval("$(\"display\").inner„0ü0HTML += \" U+FDE2 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>0HTML += \" U+FDE2 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE3 // U+FDE3
eval("$(\"display\").inner„0ü1HTML += \" U+FDE3 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>1HTML += \" U+FDE3 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE4 // U+FDE4
eval("$(\"display\").inner„0ü2HTML += \" U+FDE4 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>2HTML += \" U+FDE4 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE5 // U+FDE5
eval("$(\"display\").inner„0ü3HTML += \" U+FDE5 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>3HTML += \" U+FDE5 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE6 // U+FDE6
eval("$(\"display\").inner„0ü4HTML += \" U+FDE6 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>4HTML += \" U+FDE6 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE7 // U+FDE7
eval("$(\"display\").inner„0ü5HTML += \" U+FDE7 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>5HTML += \" U+FDE7 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE8 // U+FDE8
eval("$(\"display\").inner„0ü6HTML += \" U+FDE8 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>6HTML += \" U+FDE8 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDE9 // U+FDE9
eval("$(\"display\").inner„0ü7HTML += \" U+FDE9 is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>7HTML += \" U+FDE9 is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDEA // U+FDEA
eval("$(\"display\").inner„0ü8HTML += \" U+FDEA is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+FDEA is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDEB // U+FDEB
eval("$(\"display\").inner„0ü9HTML += \" U+FDEB is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+FDEB is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDEC // U+FDEC
eval("$(\"display\").inner„0ý0HTML += \" U+FDEC is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>0HTML += \" U+FDEC is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDED // U+FDED
eval("$(\"display\").inner„0ý1HTML += \" U+FDED is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>1HTML += \" U+FDED is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDEE // U+FDEE
eval("$(\"display\").inner„0ý2HTML += \" U+FDEE is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>2HTML += \" U+FDEE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FDEF // U+FDEF
eval("$(\"display\").inner„0ý3HTML += \" U+FDEF is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>3HTML += \" U+FDEF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FFFE // U+FFFE
eval("$(\"display\").inner„1¤8HTML += \" U+FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>1<EFBFBD>8HTML += \" U+FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FFFF // U+FFFF
eval("$(\"display\").inner„1¤9HTML += \" U+FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>1<EFBFBD>9HTML += \" U+FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+1FFFE // U+1FFFE
eval("$(\"display\").inner•24HTML += \" U+1FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>4HTML += \" U+1FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+1FFFF // U+1FFFF
eval("$(\"display\").inner•25HTML += \" U+1FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>5HTML += \" U+1FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+2FFFE // U+2FFFE
eval("$(\"display\").innerš4„0HTML += \" U+2FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>0HTML += \" U+2FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+2FFFF // U+2FFFF
eval("$(\"display\").innerš4„1HTML += \" U+2FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>1HTML += \" U+2FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+3FFFE // U+3FFFE
eval("$(\"display\").innerŸ6…6HTML += \" U+3FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>6HTML += \" U+3FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+3FFFF // U+3FFFF
eval("$(\"display\").innerŸ6…7HTML += \" U+3FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>7HTML += \" U+3FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+4FFFE // U+4FFFE
eval("$(\"display\").inner¤8‡2HTML += \" U+4FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>2HTML += \" U+4FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+4FFFF // U+4FFFF
eval("$(\"display\").inner¤8‡3HTML += \" U+4FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>3HTML += \" U+4FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+5FFFE // U+5FFFE
eval("$(\"display\").innerª0ˆ8HTML += \" U+5FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+5FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+5FFFF // U+5FFFF
eval("$(\"display\").innerª0ˆ9HTML += \" U+5FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+5FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+6FFFE // U+6FFFE
eval("$(\"display\").inner¯2Š4HTML += \" U+6FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>4HTML += \" U+6FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+6FFFF // U+6FFFF
eval("$(\"display\").inner¯2Š5HTML += \" U+6FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>5HTML += \" U+6FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+7FFFE // U+7FFFE
eval("$(\"display\").inner´0HTML += \" U+7FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>0HTML += \" U+7FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+7FFFF // U+7FFFF
eval("$(\"display\").inner´1HTML += \" U+7FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>1HTML += \" U+7FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+8FFFE // U+8FFFE
eval("$(\"display\").inner¹6<EFBFBD>6HTML += \" U+8FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>6HTML += \" U+8FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+8FFFF // U+8FFFF
eval("$(\"display\").inner¹6<EFBFBD>7HTML += \" U+8FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>7HTML += \" U+8FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+9FFFE // U+9FFFE
eval("$(\"display\").inner¾8<EFBFBD>2HTML += \" U+9FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>2HTML += \" U+9FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+9FFFF // U+9FFFF
eval("$(\"display\").inner¾8<EFBFBD>3HTML += \" U+9FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>3HTML += \" U+9FFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+AFFFE // U+AFFFE
eval("$(\"display\").innerÄ0<EFBFBD>8HTML += \" U+AFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+AFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+AFFFF // U+AFFFF
eval("$(\"display\").innerÄ0<EFBFBD>9HTML += \" U+AFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+AFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+BFFFE // U+BFFFE
eval("$(\"display\").innerÉ24HTML += \" U+BFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>4HTML += \" U+BFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+BFFFF // U+BFFFF
eval("$(\"display\").innerÉ25HTML += \" U+BFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>5HTML += \" U+BFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+CFFFE // U+CFFFE
eval("$(\"display\").innerÎ4”0HTML += \" U+CFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>0HTML += \" U+CFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+CFFFF // U+CFFFF
eval("$(\"display\").innerÎ4”1HTML += \" U+CFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>4<EFBFBD>1HTML += \" U+CFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+DFFFE // U+DFFFE
eval("$(\"display\").innerÓ6•6HTML += \" U+DFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>6HTML += \" U+DFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+DFFFF // U+DFFFF
eval("$(\"display\").innerÓ6•7HTML += \" U+DFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>6<EFBFBD>7HTML += \" U+DFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+EFFFE // U+EFFFE
eval("$(\"display\").innerØ8—2HTML += \" U+EFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>2HTML += \" U+EFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+EFFFF // U+EFFFF
eval("$(\"display\").innerØ8—3HTML += \" U+EFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>8<EFBFBD>3HTML += \" U+EFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FFFFE // U+FFFFE
eval("$(\"display\").innerÞ0˜8HTML += \" U+FFFFE is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>8HTML += \" U+FFFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+FFFFF // U+FFFFF
eval("$(\"display\").innerÞ0˜9HTML += \" U+FFFFF is evil \""); eval("$(\"display\").inner<EFBFBD>0<EFBFBD>9HTML += \" U+FFFFF is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+10FFFE // U+10FFFE
eval("$(\"display\").innerã2š4HTML += \" U+10FFFE is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>4HTML += \" U+10FFFE is evil \"");
} catch(e) {} } catch(e) {}
try { try {
// U+10FFFF // U+10FFFF
eval("$(\"display\").innerã2š5HTML += \" U+10FFFF is evil \""); eval("$(\"display\").inner<EFBFBD>2<EFBFBD>5HTML += \" U+10FFFF is evil \"");
} catch(e) {} } catch(e) {}
test(); test();
} }

View file

@ -13,6 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=445886
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* eslint-disable no-eval */
/** Test that unicode non-characters are not discarded **/ /** Test that unicode non-characters are not discarded **/
function test() function test()
{ {
@ -20,6 +22,7 @@ function test()
SimpleTest.finish(); SimpleTest.finish();
} }
// eslint-disable-next-line complexity
function Inject() function Inject()
{ {
// script fragments containing Unicode non-characters // script fragments containing Unicode non-characters

View file

@ -1,3 +1,5 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var CC = Components.Constructor; var CC = Components.Constructor;
function CreateScriptableConverter() { function CreateScriptableConverter() {

View file

@ -112,7 +112,7 @@ function testCase(testText, expectedText, bufferLength, charset) {
); );
if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) { if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) {
throw "not line input stream"; throw new Error("not line input stream");
} }
var outStr = ""; var outStr = "";

View file

@ -12,7 +12,6 @@
*/ */
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm"); const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const beBOM = "%FE%FF"; const beBOM = "%FE%FF";
const leBOM = "%FF%FE"; const leBOM = "%FF%FE";
@ -29,6 +28,7 @@ registerCleanupFunction(() => {
}); });
function makeText(withBOM, charset) { function makeText(withBOM, charset) {
// eslint-disable-next-line no-eval
var theText = eval("sample" + charset); var theText = eval("sample" + charset);
if (withBOM) { if (withBOM) {
if (charset == "UTF16BE") { if (charset == "UTF16BE") {
@ -63,7 +63,7 @@ function testCase(withBOM, charset, charsetDec, decoder, bufferLength) {
); );
if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) { if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) {
throw "not line input stream"; throw new Error("not line input stream");
} }
var outStr = ""; var outStr = "";
@ -90,7 +90,7 @@ function testCase(withBOM, charset, charsetDec, decoder, bufferLength) {
"\n" "\n"
); );
if (outStr.length == expected.length) { if (outStr.length == expected.length) {
for (i = 0; i < outStr.length; ++i) { for (let i = 0; i < outStr.length; ++i) {
if (outStr.charCodeAt(i) != expected.charCodeAt(i)) { if (outStr.charCodeAt(i) != expected.charCodeAt(i)) {
dump( dump(
i + i +

View file

@ -1,7 +1,4 @@
// crash test with invaild parameter (bug 522931) // crash test with invaild parameter (bug 522931)
function run_test() { function run_test() {
var textToSubURI = Cc["@mozilla.org/intl/texttosuburi;1"].getService( Assert.equal(Services.textToSubURI.UnEscapeAndConvert("UTF-8", null), "");
Ci.nsITextToSubURI
);
Assert.equal(textToSubURI.UnEscapeAndConvert("UTF-8", null), "");
} }

View file

@ -54,7 +54,7 @@ function testCase(testText, expectedText, bufferLength, charset) {
); );
if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) { if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) {
throw "not line input stream"; throw new Error("not line input stream");
} }
var outStr = ""; var outStr = "";
@ -69,7 +69,7 @@ function testCase(testText, expectedText, bufferLength, charset) {
if (outStr != expectedText) { if (outStr != expectedText) {
dump("Failed with bufferLength = " + bufferLength + "\n"); dump("Failed with bufferLength = " + bufferLength + "\n");
if (outStr.length == expectedText.length) { if (outStr.length == expectedText.length) {
for (i = 0; i < outStr.length; ++i) { for (let i = 0; i < outStr.length; ++i) {
if (outStr.charCodeAt(i) != expectedText.charCodeAt(i)) { if (outStr.charCodeAt(i) != expectedText.charCodeAt(i)) {
dump( dump(
i + i +

View file

@ -32,14 +32,14 @@ function test(inString) {
var outLen = outString.length; var outLen = outString.length;
for (var pos = 1; pos < 3; ++pos) { for (var pos = 1; pos < 3; ++pos) {
outPos = outLen - (9 - pos); let outPos = outLen - (9 - pos);
if (outPos < 0) { if (outPos < 0) {
outPos = 0; outPos = 0;
} }
c0 = inString.charCodeAt(0); let c0 = inString.charCodeAt(0);
c1 = inString.charCodeAt(1); let c1 = inString.charCodeAt(1);
c2 = inString.charCodeAt(2); let c2 = inString.charCodeAt(2);
c3 = inString.charCodeAt(3); let c3 = inString.charCodeAt(3);
if ( if (
IsASCII(inString.charCodeAt(pos)) && IsASCII(inString.charCodeAt(pos)) &&
!( !(

View file

@ -129,7 +129,12 @@ function getUnicharInputStream(filename, encoding) {
file.append(filename); file.append(filename);
const PR_RDONLY = 0x1; const PR_RDONLY = 0x1;
var fis = new FIS(file, PR_RDONLY, 0644, Ci.nsIFileInputStream.CLOSE_ON_EOF); var fis = new FIS(
file,
PR_RDONLY,
"0644",
Ci.nsIFileInputStream.CLOSE_ON_EOF
);
return new CIS(fis, encoding, 8192, 0x0); return new CIS(fis, encoding, 8192, 0x0);
} }
@ -138,13 +143,17 @@ function getBinaryInputStream(filename, encoding) {
file.append(filename); file.append(filename);
const PR_RDONLY = 0x1; const PR_RDONLY = 0x1;
var fis = new FIS(file, PR_RDONLY, 0644, Ci.nsIFileInputStream.CLOSE_ON_EOF); var fis = new FIS(
file,
PR_RDONLY,
"0644",
Ci.nsIFileInputStream.CLOSE_ON_EOF
);
return new BIS(fis); return new BIS(fis);
} }
function equalStreams(stream, codePoints) { function equalStreams(stream, codePoints) {
var sz, var currIndex = 0;
currIndex = 0;
while (true) { while (true) {
var unit = stream.readUnit(); var unit = stream.readUnit();
if (unit < 0) { if (unit < 0) {
@ -154,7 +163,7 @@ function equalStreams(stream, codePoints) {
return false; return false;
} }
} }
// eslint-disable-next-line no-unreachable
do_throw("not reached"); do_throw("not reached");
return false; return false;
} }
@ -179,6 +188,7 @@ function equalUnicharStreams(s1, s2) {
} }
// not reached // not reached
// eslint-disable-next-line no-unreachable
return false; return false;
} }

View file

@ -1,12 +1,11 @@
// Tests for nsITextToSubURI.unEscapeNonAsciiURI // Tests for nsITextToSubURI.unEscapeNonAsciiURI
function run_test() { function run_test() {
const textToSubURI = Cc["@mozilla.org/intl/texttosuburi;1"].getService(
Ci.nsITextToSubURI
);
// Tests whether nsTextToSubURI does UTF-16 unescaping (it shouldn't) // Tests whether nsTextToSubURI does UTF-16 unescaping (it shouldn't)
const testURI = "data:text/html,%FE%FF"; const testURI = "data:text/html,%FE%FF";
Assert.equal(textToSubURI.unEscapeNonAsciiURI("UTF-16", testURI), testURI); Assert.equal(
Services.textToSubURI.unEscapeNonAsciiURI("UTF-16", testURI),
testURI
);
// Tests whether incomplete multibyte sequences throw. // Tests whether incomplete multibyte sequences throw.
const tests = [ const tests = [
@ -44,14 +43,14 @@ function run_test() {
if (t.throws !== undefined) { if (t.throws !== undefined) {
let thrown = undefined; let thrown = undefined;
try { try {
textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input); Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input);
} catch (e) { } catch (e) {
thrown = e.result; thrown = e.result;
} }
Assert.equal(thrown, t.throws); Assert.equal(thrown, t.throws);
} else { } else {
Assert.equal( Assert.equal(
textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input), Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input),
t.expected t.expected
); );
} }

View file

@ -136,7 +136,7 @@ function testCaseInputStream(inStr, expected) {
); );
if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) { if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) {
throw "not line input stream"; throw new Error("not line input stream");
} }
var outStr = ""; var outStr = "";