Bug 1204269 - Part 2: Add unit tests; r=smaug

This commit is contained in:
Ehsan Akhgari 2015-09-12 17:38:51 -04:00
Родитель bc25c907d6
Коммит 6fc6fe1c47
4 изменённых файлов: 57 добавлений и 0 удалений

Просмотреть файл

@ -117,6 +117,8 @@ support-files =
sharedWorker_ports.js
sharedWorker_lifetime.js
worker_referrer.js
websocket_https.html
websocket_https_worker.js
[test_404.html]
[test_atob.html]
@ -210,6 +212,8 @@ skip-if = (toolkit == 'gonk' && debug) # Bug 1176223
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 982828
[test_websocket_basic.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 982828
[test_websocket_https.html]
skip-if = buildapp == 'b2g' # no https on b2g
[test_websocket_loadgroup.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 982828
[test_webSocket_sharedWorker.html]

Просмотреть файл

@ -0,0 +1,30 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Test that creating insecure websockets from https workers is not possible</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" language="javascript">
onmessage = function(event) {
is(event.data, "not created", "WebSocket object must not be created");
SimpleTest.finish();
};
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<iframe src="https://example.com/tests/dom/workers/test/websocket_https.html"></iframe>
</body>
</html>

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<script>
var worker = new Worker("https://example.com/tests/dom/workers/test/websocket_https_worker.js");
worker.onmessage = function(event) {
parent.postMessage(event.data, "*");
};
worker.onerror = function(event) {
parent.postMessage("error", "*");
};
worker.postMessage("start");
</script>

Просмотреть файл

@ -0,0 +1,9 @@
onmessage = function() {
var wsCreated = true;
try {
new WebSocket("ws://mochi.test:8888/tests/dom/base/test/file_websocket_hello");
} catch(e) {
wsCreated = false;
}
postMessage(wsCreated ? "created" : "not created");
};