From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. 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.ini | 15 ++++ dom/tests/mochitest/script/slow.sjs | 15 ++++ dom/tests/mochitest/script/subdir/.eslintrc.js | 11 +++ .../mochitest/script/subdir/bug1656248_import.js | 1 + .../mochitest/script/subdir/bug1656248_script.js | 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 ++++++++ 13 files changed, 353 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.ini create mode 100644 dom/tests/mochitest/script/slow.sjs create mode 100644 dom/tests/mochitest/script/subdir/.eslintrc.js create mode 100644 dom/tests/mochitest/script/subdir/bug1656248_import.js create mode 100644 dom/tests/mochitest/script/subdir/bug1656248_script.js 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..9030b4cbcf --- /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.ini b/dom/tests/mochitest/script/mochitest.ini new file mode 100644 index 0000000000..d792777d41 --- /dev/null +++ b/dom/tests/mochitest/script/mochitest.ini @@ -0,0 +1,15 @@ +[DEFAULT] +support-files = + file_blocked_script.sjs + bug1656248_frame.html + subdir/bug1656248_script.js + subdir/bug1656248_import.js + test_bug1788532_moduleA.mjs + test_bug1788532_moduleB.mjs + slow.sjs + +[test_bug1053321.html] +[test_whitespace.html] +[test_bug1656248.html] +skip-if = verify +[test_bug1788532.html] diff --git a/dom/tests/mochitest/script/slow.sjs b/dom/tests/mochitest/script/slow.sjs new file mode 100644 index 0000000000..7139eb91f3 --- /dev/null +++ b/dom/tests/mochitest/script/slow.sjs @@ -0,0 +1,15 @@ +function handleRequest(request, response) { + response.processAsync(); + + timer = Components.classes["@mozilla.org/timer;1"].createInstance( + Components.interfaces.nsITimer + ); + timer.init( + function () { + response.write("Here the content. But slowly."); + response.finish(); + }, + 5000, + Components.interfaces.nsITimer.TYPE_ONE_SHOT + ); +} diff --git a/dom/tests/mochitest/script/subdir/.eslintrc.js b/dom/tests/mochitest/script/subdir/.eslintrc.js new file mode 100644 index 0000000000..c85129a731 --- /dev/null +++ b/dom/tests/mochitest/script/subdir/.eslintrc.js @@ -0,0 +1,11 @@ +/* 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/. */ + +"use strict"; + +module.exports = { + parserOptions: { + sourceType: "module", + }, +}; diff --git a/dom/tests/mochitest/script/subdir/bug1656248_import.js b/dom/tests/mochitest/script/subdir/bug1656248_import.js new file mode 100644 index 0000000000..7a4e8a723a --- /dev/null +++ b/dom/tests/mochitest/script/subdir/bug1656248_import.js @@ -0,0 +1 @@ +export default 42; diff --git a/dom/tests/mochitest/script/subdir/bug1656248_script.js b/dom/tests/mochitest/script/subdir/bug1656248_script.js new file mode 100644 index 0000000000..25cd8c241f --- /dev/null +++ b/dom/tests/mochitest/script/subdir/bug1656248_script.js @@ -0,0 +1,18 @@ +// Import a module which should be resolved relative to this script's URL. +import("./bug1656248_import.js") + .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