// 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();
}
}
// 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();
}
}
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.