diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/presentation/tests/mochitest/file_presentation_reconnect.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/presentation/tests/mochitest/file_presentation_reconnect.html')
-rw-r--r-- | dom/presentation/tests/mochitest/file_presentation_reconnect.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dom/presentation/tests/mochitest/file_presentation_reconnect.html b/dom/presentation/tests/mochitest/file_presentation_reconnect.html new file mode 100644 index 000000000..174ccd3f3 --- /dev/null +++ b/dom/presentation/tests/mochitest/file_presentation_reconnect.html @@ -0,0 +1,102 @@ + +<!DOCTYPE HTML> +<html> +<head> +<meta charset="utf-8"> +<title>Test allow-presentation sandboxing flag</title> +<script type="application/javascript;version=1.8"> + +"use strict"; + +function is(a, b, msg) { + window.parent.postMessage((a === b ? "OK " : "KO ") + msg, "*"); +} + +function ok(a, msg) { + window.parent.postMessage((a ? "OK " : "KO ") + msg, "*"); +} + +function info(msg) { + window.parent.postMessage("INFO " + msg, "*"); +} + +function command(msg) { + window.parent.postMessage("COMMAND " + JSON.stringify(msg), "*"); +} + +function finish() { + window.parent.postMessage("DONE", "*"); +} + +var request; +var connection; + +function testStartRequest() { + return new Promise(function(aResolve, aReject) { + ok(navigator.presentation, "navigator.presentation should be available."); + request = new PresentationRequest("http://example1.com"); + + request.start().then( + function(aConnection) { + connection = aConnection; + ok(connection, "Connection should be available."); + ok(connection.id, "Connection ID should be set."); + is(connection.state, "connecting", "The initial state should be connecting."); + + connection.onclose = function() { + connection.onclose = null; + command({ name: "notify-connection-closed", id: connection.id }); + }; + connection.onconnect = function() { + connection.onconnect = null; + is(connection.state, "connected", "Connection should be connected."); + aResolve(); + }; + }, + function(aError) { + ok(false, "Error occurred when establishing a connection: " + aError); + teardown(); + aReject(); + } + ); + }); +} + +function testCloseConnection() { + return new Promise(function(aResolve, aReject) { + if (connection.state === "closed") { + aResolve(); + return; + } + connection.onclose = function() { + connection.onclose = null; + is(connection.state, "closed", "The connection should be closed."); + aResolve(); + }; + + connection.close(); + }); +} + +window.addEventListener("message", function onMessage(evt) { + if (evt.data === "startConnection") { + testStartRequest().then( + function () { + command({ name: "connection-connected", id: connection.id }); + } + ); + } + else if (evt.data === "closeConnection") { + testCloseConnection().then( + function () { + command({ name: "connection-closed", id: connection.id }); + } + ); + } +}, false); + +</script> +</head> +<body> +</body> +</html> |