Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/websocket/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  test_websocket_mixed_content.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/websocket/tests/test_websocket_mixed_content.html


<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta>
  <title>WebSocket mixed content tests - load secure and insecure websockets</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>

  <script type="text/javascript" src="websocket_helpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="container"></div>
<iframe id="frame" sandbox="allow-scripts"></iframe>
<script class="testbody" type="text/javascript">

let iFrameTests = [testWebSocketSecure, testWebSocketInsecure, testWebSocketInsecureDataURI, testSameOriginSandboxInsecure, testSameOriginSandboxSecure, testCrossOriginSandboxInsecure, testCrossOriginSandboxSecure];

function nextIFrameTest() {
  if(!iFrameTests.length) {
    document.getElementById("frame").removeAttribute("src");
    document.getElementById("frame").remove();
    SimpleTest.finish();
  }
  else {
    let test = iFrameTests.shift();
    test();
  }
}

function testWebSockets () {
  nextIFrameTest();
}

function testWebSocketSecure () {
  let ws = CreateTestWS("wss://example.com/tests/dom/websocket/tests/file_websocket_hello");
  ws.onopen = function() {
    ws.send("data");
  }
  ws.onmessage = function(e) {
    is(e.data, "Hello world!""Wrong data");
    ws.close();
    nextIFrameTest();
  }
}

// Negative test: this should fail as the page was loaded over https
function testWebSocketInsecure () {
  try {
    new WebSocket("ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello");
    ok(false, "Should throw DOMException");
  } catch (e) {
    ok(e instanceof DOMException, "DOMException thrown ");
    nextIFrameTest();
  }
}

// Negative test: this should fail as the page was loaded over https
function testWebSocketInsecureDataURI() {
  document.getElementById("frame").src = "https://example.com/tests/dom/websocket/tests/iframe_webworker_wss.html";
  onmessage = function(e) {
    is(e.data, "SecurityError: The operation is insecure.""SecurityError received");
    nextIFrameTest();
  }
}

// Negative test: this should fail as the page was loaded over https
function testSameOriginSandboxInsecure() {
  document.getElementById("frame").src = "https://example.com/tests/dom/websocket/tests/iframe_websocket_wss.html?insecure";
  onmessage = function(e) {
    is(e.data, "SecurityError""ws://URI cannot be used when loaded over https");
    nextIFrameTest();
  }
}

function testSameOriginSandboxSecure() {
  document.getElementById("frame").src = "https://example.com/tests/dom/websocket/tests/iframe_websocket_wss.html"
  onmessage = function(e) {
    is(e.data, "WS onopen""wss://URI opened");
    nextIFrameTest();
  }
}

// Negative test: this should fail as the page was loaded over https
function testCrossOriginSandboxInsecure() {
  document.getElementById("frame").src = "https://example.org/tests/dom/websocket/tests/iframe_websocket_wss.html?insecure";
  onmessage = function(e) {
    is(e.data, "SecurityError""ws://URI cannot be used when loaded over https");
    nextIFrameTest();
  }
}

function testCrossOriginSandboxSecure() {
  document.getElementById("frame").src = "https://example.org/tests/dom/websocket/tests/iframe_websocket_wss.html"

  onmessage = function(e) {
    is(e.data, "WS onopen""wss://URI opened");
    nextIFrameTest();
  }
}

SimpleTest.waitForExplicitFinish();
testWebSockets();
</script>
</body>
</html>

Messung V0.5
C=90 H=91 G=90

¤ Dauer der Verarbeitung: 0.28 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.