From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- dom/tests/mochitest/script/bug1656248_frame.html | 11 +++ dom/tests/mochitest/script/file_blocked_script.sjs | 70 ++++++++++++++++ dom/tests/mochitest/script/mochitest.toml | 19 +++++ dom/tests/mochitest/script/slow.sjs | 13 +++ .../mochitest/script/subdir/bug1656248_import.mjs | 1 + .../mochitest/script/subdir/bug1656248_script.mjs | 18 +++++ dom/tests/mochitest/script/test_bug1053321.html | 50 ++++++++++++ dom/tests/mochitest/script/test_bug1656248.html | 93 ++++++++++++++++++++++ dom/tests/mochitest/script/test_bug1788532.html | 21 +++++ .../mochitest/script/test_bug1788532_moduleA.mjs | 15 ++++ .../mochitest/script/test_bug1788532_moduleB.mjs | 2 + dom/tests/mochitest/script/test_whitespace.html | 31 ++++++++ 12 files changed, 344 insertions(+) create mode 100644 dom/tests/mochitest/script/bug1656248_frame.html create mode 100644 dom/tests/mochitest/script/file_blocked_script.sjs create mode 100644 dom/tests/mochitest/script/mochitest.toml create mode 100644 dom/tests/mochitest/script/slow.sjs create mode 100644 dom/tests/mochitest/script/subdir/bug1656248_import.mjs create mode 100644 dom/tests/mochitest/script/subdir/bug1656248_script.mjs create mode 100644 dom/tests/mochitest/script/test_bug1053321.html create mode 100644 dom/tests/mochitest/script/test_bug1656248.html create mode 100644 dom/tests/mochitest/script/test_bug1788532.html create mode 100644 dom/tests/mochitest/script/test_bug1788532_moduleA.mjs create mode 100644 dom/tests/mochitest/script/test_bug1788532_moduleB.mjs create mode 100644 dom/tests/mochitest/script/test_whitespace.html (limited to 'dom/tests/mochitest/script') diff --git a/dom/tests/mochitest/script/bug1656248_frame.html b/dom/tests/mochitest/script/bug1656248_frame.html new file mode 100644 index 0000000000..7d24911899 --- /dev/null +++ b/dom/tests/mochitest/script/bug1656248_frame.html @@ -0,0 +1,11 @@ + + + + + + + diff --git a/dom/tests/mochitest/script/file_blocked_script.sjs b/dom/tests/mochitest/script/file_blocked_script.sjs new file mode 100644 index 0000000000..a5b375a23d --- /dev/null +++ b/dom/tests/mochitest/script/file_blocked_script.sjs @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +function setGlobalState(data, key) { + x = { + data, + QueryInterface(iid) { + return this; + }, + }; + x.wrappedJSObject = x; + setObjectState(key, x); +} + +function getGlobalState(key) { + var data; + getObjectState(key, function (x) { + data = x && x.wrappedJSObject.data; + }); + return data; +} + +function finishBlockedRequest(request, response, query) { + response.setStatusLine(request.httpVersion, 200, "OK"); + response.setHeader("Cache-Control", "no-cache", false); + response.setHeader("Content-Type", "application/javascript", false); + response.write("scriptLoaded('" + query[1] + "');"); + response.finish(); + + setGlobalState(undefined, query[1]); +} + +function handleRequest(request, response) { + var query = request.queryString.split("&"); + switch (query[0]) { + case "blocked": + var alreadyUnblocked = getGlobalState(query[1]); + + response.processAsync(); + if (alreadyUnblocked === true) { + // the unblock request came before the blocked request, just go on and finish synchronously + finishBlockedRequest(request, response, query); + } else { + setGlobalState(response, query[1]); + } + break; + + case "unblock": + response.setStatusLine(request.httpVersion, 200, "OK"); + response.setHeader("Cache-Control", "no-cache", false); + response.setHeader("Content-Type", "image/png", false); + response.write("\x89PNG"); // just a broken image is enough for our purpose + + var blockedResponse = getGlobalState(query[1]); + if (blockedResponse === undefined) { + // the unblock request came before the blocked request, remember to not block it + setGlobalState(true, query[1]); + } else if (typeof blockedResponse == "object") { + finishBlockedRequest(request, blockedResponse, query); + } + break; + + default: + response.setStatusLine(request.httpVersion, 400, "Bad request"); + break; + } +} diff --git a/dom/tests/mochitest/script/mochitest.toml b/dom/tests/mochitest/script/mochitest.toml new file mode 100644 index 0000000000..ddd448cd88 --- /dev/null +++ b/dom/tests/mochitest/script/mochitest.toml @@ -0,0 +1,19 @@ +[DEFAULT] +support-files = [ + "file_blocked_script.sjs", + "bug1656248_frame.html", + "subdir/bug1656248_script.mjs", + "subdir/bug1656248_import.mjs", + "test_bug1788532_moduleA.mjs", + "test_bug1788532_moduleB.mjs", + "slow.sjs", +] + +["test_bug1053321.html"] + +["test_bug1656248.html"] +skip-if = ["verify"] + +["test_bug1788532.html"] + +["test_whitespace.html"] diff --git a/dom/tests/mochitest/script/slow.sjs b/dom/tests/mochitest/script/slow.sjs new file mode 100644 index 0000000000..39a75acd86 --- /dev/null +++ b/dom/tests/mochitest/script/slow.sjs @@ -0,0 +1,13 @@ +function handleRequest(request, response) { + response.processAsync(); + + timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + timer.init( + function () { + response.write("Here the content. But slowly."); + response.finish(); + }, + 5000, + Ci.nsITimer.TYPE_ONE_SHOT + ); +} diff --git a/dom/tests/mochitest/script/subdir/bug1656248_import.mjs b/dom/tests/mochitest/script/subdir/bug1656248_import.mjs new file mode 100644 index 0000000000..7a4e8a723a --- /dev/null +++ b/dom/tests/mochitest/script/subdir/bug1656248_import.mjs @@ -0,0 +1 @@ +export default 42; diff --git a/dom/tests/mochitest/script/subdir/bug1656248_script.mjs b/dom/tests/mochitest/script/subdir/bug1656248_script.mjs new file mode 100644 index 0000000000..ee65a6046a --- /dev/null +++ b/dom/tests/mochitest/script/subdir/bug1656248_script.mjs @@ -0,0 +1,18 @@ +// Import a module which should be resolved relative to this script's URL. +import("./bug1656248_import.mjs") + .then(ns => window.parent.checkResult(ns.default)) + .catch(e => window.parent.checkResult(`error: ${e}`)); + +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. +// To trigger the bytecode cache, this script needs to be at least 1KB. diff --git a/dom/tests/mochitest/script/test_bug1053321.html b/dom/tests/mochitest/script/test_bug1053321.html new file mode 100644 index 0000000000..bad2b4b4c4 --- /dev/null +++ b/dom/tests/mochitest/script/test_bug1053321.html @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/dom/tests/mochitest/script/test_bug1656248.html b/dom/tests/mochitest/script/test_bug1656248.html new file mode 100644 index 0000000000..3b12fdaf80 --- /dev/null +++ b/dom/tests/mochitest/script/test_bug1656248.html @@ -0,0 +1,93 @@ + + + + + + + + + + + diff --git a/dom/tests/mochitest/script/test_bug1788532.html b/dom/tests/mochitest/script/test_bug1788532.html new file mode 100644 index 0000000000..8465c3a1fc --- /dev/null +++ b/dom/tests/mochitest/script/test_bug1788532.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/dom/tests/mochitest/script/test_bug1788532_moduleA.mjs b/dom/tests/mochitest/script/test_bug1788532_moduleA.mjs new file mode 100644 index 0000000000..d667aac482 --- /dev/null +++ b/dom/tests/mochitest/script/test_bug1788532_moduleA.mjs @@ -0,0 +1,15 @@ +let xhrFinished = false; + +import("./test_bug1788532_moduleB.mjs") + .then(() => { + ok(xhrFinished, "Loaded after XHR finished"); + SimpleTest.finish(); + }) + .catch(e => { + ok(false, "Caught exception: " + e); + }); + +let request = new XMLHttpRequest(); +request.open("GET", "./slow.sjs", false); +request.send(null); +xhrFinished = true; diff --git a/dom/tests/mochitest/script/test_bug1788532_moduleB.mjs b/dom/tests/mochitest/script/test_bug1788532_moduleB.mjs new file mode 100644 index 0000000000..71e2e7009b --- /dev/null +++ b/dom/tests/mochitest/script/test_bug1788532_moduleB.mjs @@ -0,0 +1,2 @@ +/* eslint-disable-next-line import/no-unassigned-import */ +import "./test_bug1788532_moduleA.mjs"; diff --git a/dom/tests/mochitest/script/test_whitespace.html b/dom/tests/mochitest/script/test_whitespace.html new file mode 100644 index 0000000000..7ab14d9b67 --- /dev/null +++ b/dom/tests/mochitest/script/test_whitespace.html @@ -0,0 +1,31 @@ + + + + Test for ScriptLoader and type with whitespaces + + + + + + + + + -- cgit v1.2.3