From 743bd9f1e8599f4c8fbf4bb500c0ac8f471e25ca Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:07:32 +0330 Subject: [PATCH] Import tests: test/encoding Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- test/encoding.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/encoding.js diff --git a/test/encoding.js b/test/encoding.js new file mode 100644 index 0000000..83a7d3d --- /dev/null +++ b/test/encoding.js @@ -0,0 +1,35 @@ +"use strict"; + +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const path = require("node:path"); + +const root = path.join(__dirname, ".."); +const files = [ + "manifest.json", + "README.md", + "demo.html", + "src/content.js", + "popup/popup.html", + "popup/popup.js", + "test/content-engine.js", + "test/edge-cases.js" +]; +const mojibakeMarkers = ["\u00D8\u00A7", "\u00D9\u0085", "\u00E2\u20AC", "\u00C3\u0097"]; + +for (const file of files) { + const text = fs.readFileSync(path.join(root, file), "utf8"); + for (const marker of mojibakeMarkers) { + assert.equal(text.includes(marker), false, `${file} contains a mojibake marker`); + } +} + +const fixtures = fs.readFileSync(path.join(root, "test/content-engine.js"), "utf8"); +assert.match(fixtures, /[پچژگکی]/, "tests must contain real Persian-specific characters"); + +const manifest = JSON.parse(fs.readFileSync(path.join(root, "manifest.json"), "utf8")); +assert.match(manifest.name, /Persian/); +assert.doesNotMatch(manifest.name, /Arabic/); +assert.equal(manifest.content_scripts[0].match_origin_as_fallback, true); + +console.log("Encoding and manifest checks passed");