1
0
Fork 0
firefox/testing/web-platform/tests/speculation-rules/prefetch/resources/util.py
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

16 lines
554 B
Python

import os
from wptserve.pipes import template
# Returns the executor HTML (as bytes).
# `additional_script` (str) is inserted to the JavaScript before the executor.
def get_executor_html(request, additional_script):
content = template(
request,
open(os.path.join(os.path.dirname(__file__), "executor.sub.html"), "rb").read())
# Insert an additional script at the head of script before Executor.
content = content.replace(
b'<script nonce="abc">',
b'<script nonce="abc">' + additional_script.encode('utf-8'))
return content