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 --- .../test/webgl-mochitest/mochi-to-testcase.py | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 dom/canvas/test/webgl-mochitest/mochi-to-testcase.py (limited to 'dom/canvas/test/webgl-mochitest/mochi-to-testcase.py') diff --git a/dom/canvas/test/webgl-mochitest/mochi-to-testcase.py b/dom/canvas/test/webgl-mochitest/mochi-to-testcase.py new file mode 100644 index 0000000000..bff3b675b0 --- /dev/null +++ b/dom/canvas/test/webgl-mochitest/mochi-to-testcase.py @@ -0,0 +1,119 @@ +#! /usr/bin/env python3 +import pathlib +import re +import sys + +assert len(sys.argv) == 2 +MOCHI_PATH = pathlib.Path(sys.argv[1]) +assert MOCHI_PATH.suffix == ".html" + +TEST_PATH = MOCHI_PATH.with_suffix(".solo.html") + + +def read_local_file(include): + inc_path = MOCHI_PATH.parent + file_path = inc_path / include + + try: + return file_path.read_bytes() + except IOError: + return b"" + + +SIMPLETEST_REPLACEMENT = b""" + + +
+ +""" + +INCLUDE_PATTERN = re.compile(b"\\s*") +CSS_PATTERN = re.compile( + b"]*)['\"]>" +) + +with open(TEST_PATH, "wb") as fout: + with open(MOCHI_PATH, "rb") as fin: + for line in fin: + skip_line = False + for css in CSS_PATTERN.findall(line): + skip_line = True + print("Ignoring stylesheet: " + css.decode()) + + for inc in INCLUDE_PATTERN.findall(line): + skip_line = True + if inc == b"/MochiKit/MochiKit": + continue + + if inc == b"/tests/SimpleTest/SimpleTest": + print("Injecting SimpleTest replacement") + fout.write(SIMPLETEST_REPLACEMENT) + continue + + inc_js = inc.decode() + ".js" + inc_data = read_local_file(inc_js) + if not inc_data: + print("Warning: Unknown JS file ignored: " + inc_js) + continue + + print("Injecting include: " + inc_js) + fout.write(b"\n\n") + continue + + if skip_line: + continue + + fout.write(line) + continue -- cgit v1.2.3