-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 in EXTENSIONS/browser-extension from feature/…
…issues/1001-encoding to master * commit 'f5997350cd1ce8329fa05e96db59981fb32b353a': Removed unused variable Fixed tests runner Encoding fallback strategy
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Encoding Tests</title> | ||
<link rel="stylesheet" href="../qunit/qunit-2.0.1.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../qunit/qunit-2.0.1.js"></script> | ||
|
||
<script type="text/javascript" src="../../lib/libs/encoding.js"></script> | ||
<script type="text/javascript" src="test-encoding.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* global QUnit */ | ||
|
||
QUnit.test("Test Encodings", function (assert) { | ||
|
||
function testEncodeDecode(charset) { | ||
|
||
var encoder = new TextEncoder(charset, { NONSTANDARD_allowLegacyEncoding: true }); | ||
var decoder = new TextDecoder(charset, { NONSTANDARD_allowLegacyEncoding: true }); | ||
|
||
for (var i = 0; i < 65533; i++) { | ||
var bytes = encoder.encode(String.fromCharCode(i)); | ||
decoder.decode(bytes); | ||
if (i <= 0x7F) { | ||
assert.equal(i, bytes[0]); | ||
} | ||
} | ||
} | ||
|
||
testEncodeDecode('utf-8'); | ||
testEncodeDecode('windows-1251'); | ||
testEncodeDecode('windows-1252'); | ||
|
||
// Some specific cases | ||
|
||
// Fallback to windows-1252 | ||
var encoder = new TextEncoder('windows-1251', { NONSTANDARD_allowLegacyEncoding: true }); | ||
var bytes = encoder.encode(String.fromCharCode(244)); | ||
assert.equal(244, bytes[0]); | ||
|
||
// Fallback to replacement | ||
assert.equal(63, encoder.encode("Ⓢ")[0]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters