summaryrefslogtreecommitdiff
path: root/cgi-bin
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin')
-rw-r--r--cgi-bin/and-then-js-async-cb-adds-timeout.js11
-rwxr-xr-xcgi-bin/and-then-js.cgi24
2 files changed, 35 insertions, 0 deletions
diff --git a/cgi-bin/and-then-js-async-cb-adds-timeout.js b/cgi-bin/and-then-js-async-cb-adds-timeout.js
new file mode 100644
index 0000000..b53678b
--- /dev/null
+++ b/cgi-bin/and-then-js-async-cb-adds-timeout.js
@@ -0,0 +1,11 @@
+/* JS returned by and-then-js.cgi
+ * this is to be loaded as an async script
+ */
+
+/* After one second */
+setTimeout(1000, function() {
+ /* Add a <script> tag */
+ var script = document.createElement("SCRIPT");
+ script.src = "https://test.netsurf-browser.org/hello-world.js";
+ document.body.appendChild(script);
+});
diff --git a/cgi-bin/and-then-js.cgi b/cgi-bin/and-then-js.cgi
new file mode 100755
index 0000000..1930df3
--- /dev/null
+++ b/cgi-bin/and-then-js.cgi
@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+
+import cgi
+import cgitb
+import os
+import time
+
+cgitb.enable()
+
+qs = cgi.parse_qs(os.getenv("QUERY_STRING", "t=1&val=async-cb-adds-timeout"))
+
+content = qs.get("val", ["async-cb-adds-timeout"])[0]
+
+print("Content-Type: text/javascript")
+print("")
+
+sleep_time = int(qs.get("t", [1])[0])
+
+print("{}Sleeping for {} seconds".format(prefix, sleep_time))
+
+time.sleep(sleep_time)
+
+print("{}Done sleeping {} seconds".format(prefix,sleep_time))
+