summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/characterset-helper.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/dom/nodes/characterset-helper.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/characterset-helper.js')
-rw-r--r--testing/web-platform/tests/dom/nodes/characterset-helper.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/characterset-helper.js b/testing/web-platform/tests/dom/nodes/characterset-helper.js
new file mode 100644
index 0000000000..ecbe556ae2
--- /dev/null
+++ b/testing/web-platform/tests/dom/nodes/characterset-helper.js
@@ -0,0 +1,62 @@
+function runCharacterSetTests(encodingMap) {
+ // Add spaces and mix up case
+ Object.keys(encodingMap).forEach(function(name) {
+ var lower = encodingMap[name];
+ var upper = encodingMap[name].map(function(s) { return s.toUpperCase() });
+ var mixed = encodingMap[name].map(function(s) {
+ var ret = "";
+ for (var i = 0; i < s.length; i += 2) {
+ ret += s[i].toUpperCase();
+ if (i + 1 < s.length) {
+ ret += s[i + 1];
+ }
+ }
+ return ret;
+ });
+ var spacey = encodingMap[name].map(function(s) {
+ return " \t\n\f\r" + s + " \t\n\f\r";
+ });
+ encodingMap[name] = [];
+ for (var i = 0; i < lower.length; i++) {
+ encodingMap[name].push(lower[i]);
+ /*
+ if (lower[i] != upper[i]) {
+ encodingMap[name].push(upper[i]);
+ }
+ if (lower[i] != mixed[i] && upper[i] != mixed[i]) {
+ encodingMap[name].push(mixed[i]);
+ }
+ encodingMap[name].push(spacey[i]);
+ */
+ }
+ });
+
+ Object.keys(encodingMap).forEach(function(name) {
+ encodingMap[name].forEach(function(label) {
+ var iframe = document.createElement("iframe");
+ var t = async_test("Name " + format_value(name) +
+ " has label " + format_value(label) + " (characterSet)");
+ var t2 = async_test("Name " + format_value(name) +
+ " has label " + format_value(label) + " (inputEncoding)");
+ var t3 = async_test("Name " + format_value(name) +
+ " has label " + format_value(label) + " (charset)");
+ iframe.src = "encoding.py?label=" + label;
+ iframe.onload = function() {
+ t.step(function() {
+ assert_equals(iframe.contentDocument.characterSet, name);
+ });
+ t2.step(function() {
+ assert_equals(iframe.contentDocument.inputEncoding, name);
+ });
+ t3.step(function() {
+ assert_equals(iframe.contentDocument.charset, name);
+ });
+ document.body.removeChild(iframe);
+ t.done();
+ t2.done();
+ t3.done();
+ };
+ document.body.appendChild(iframe);
+ });
+ });
+} \ No newline at end of file