Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE html>
<meta charset="euc-kr">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/GleanTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>
// This file is actually ascii, because otherwise text editors would have hard time.
// "icon" in Korean, encoded with euc-kr
const iconEucKr = new Uint8Array([0xbe, 0xc6, 0xc0, 0xcc, 0xc4, 0xdc]);
add_task(async function test() {
await SpecialPowers.pushPrefEnv({
set: [["dom.webnotifications.icon_encoding_utf8.enabled", false]]
});
await GleanTest.testResetFOG();
new Notification("title", { icon: "?icon=icon" });
// "utf8" because the string can be encoded in either euc-kr or utf-8 and
// the result is same.
is(await GleanTest.webNotification.iconUrlEncoding.utf8.testGetValue(), 1, "utf8");
await GleanTest.testResetFOG();
const iconKorean = new TextDecoder("euc-kr").decode(iconEucKr);
const icon = new Notification("title", { icon: `?icon=${iconKorean}` }).icon;
ok(icon.endsWith("?icon=%BE%C6%C0%CC%C4%DC"), "icon encoded with euc-kr");
// "either way" because the string can be encoded in either euc-kr or utf-8
// while the result is different.
is(await GleanTest.webNotification.iconUrlEncoding.either_way.testGetValue(), 1, "either way");
// I cannot find an example to trigger "document charset" or "neither way".
// Probably they can't happen because
// 1. unicode really covers everything that legacy encodings cover
// 2. the URL encoding fall back to HTML entity encoding when document
// charset doesn't support given characters
})
</script>