summaryrefslogtreecommitdiffstats
path: root/dom/websocket/tests/window_websocket_wss.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/websocket/tests/window_websocket_wss.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/websocket/tests/window_websocket_wss.html')
-rw-r--r--dom/websocket/tests/window_websocket_wss.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/dom/websocket/tests/window_websocket_wss.html b/dom/websocket/tests/window_websocket_wss.html
new file mode 100644
index 0000000000..391ab74e40
--- /dev/null
+++ b/dom/websocket/tests/window_websocket_wss.html
@@ -0,0 +1,65 @@
+<html><body>
+Creating WebSocket
+<iframe id="frame" sandbox="allow-scripts"></iframe>
+<script type="application/javascript">
+
+function cleanup() {
+ window.document.getElementById("frame").removeAttribute("src");
+ window.document.getElementById("frame").remove();
+}
+
+onmessage = function(e) {
+ cleanup();
+ window.opener.postMessage(e.data, '*');
+}
+
+// Mixed content blocker will prevent loading iframes via http, so in that case pass back the error
+window.document.getElementById("frame").onerror = function(e) {
+ cleanup();
+ window.opener.postMessage("Error - iframe not loaded", '*');
+}
+
+// Load one of the iframe variants?
+if (location.search == '?https_iframe_wss') {
+ window.document.getElementById("frame").src = "https://example.com/tests/dom/websocket/tests/iframe_websocket_wss.html";
+} else if (location.search == '?https_iframe_ws') {
+ window.document.getElementById("frame").src = "https://example.com/tests/dom/websocket/tests/iframe_websocket_wss.html?insecure";
+} else if (location.search == '?http_iframe_wss' || location.search == '?http_iframe_ws') {
+ let iFrameUrl = "http://example.com/tests/dom/websocket/tests/iframe_websocket_wss.html";
+ if (location.search == '?http_iframe_ws') {
+ iFrameUrl += "?insecure";
+ }
+ window.document.getElementById("frame").src = iFrameUrl;
+}
+else {
+ try {
+ let socket;
+ if (location.search == '?insecure') {
+ socket = new WebSocket('ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello');
+ }
+ else {
+ socket = new WebSocket('wss://example.com/tests/dom/websocket/tests/file_websocket_hello');
+ }
+ socket.onerror = function(e) {
+ cleanup();
+ window.opener.postMessage("WS onerror", "*");
+ };
+ socket.onopen = function(event) {
+ socket.close();
+ cleanup();
+ window.opener.postMessage("WS onopen", "*");
+ };
+ }
+ catch(e) {
+ if (e.name == 'SecurityError') {
+ cleanup();
+ window.opener.postMessage("SecurityError", "*");
+ } else {
+ cleanup();
+ window.opener.postMessage("Test Throws", "*");
+ }
+ }
+}
+
+</script>
+</body></html>