diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html')
-rw-r--r-- | dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html b/dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html new file mode 100644 index 0000000000..162e4209e7 --- /dev/null +++ b/dom/presentation/tests/mochitest/file_presentation_sandboxed_presentation.html @@ -0,0 +1,113 @@ + +<!DOCTYPE HTML> +<html> +<head> +<meta charset="utf-8"> +<title>Test allow-presentation sandboxing flag</title> +<script type="application/javascript"> + +"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", "*"); +} + +function testGetAvailability() { + return new Promise(function(aResolve, aReject) { + ok(navigator.presentation, "navigator.presentation should be available."); + var request = new PresentationRequest("http://example.com"); + + request.getAvailability().then( + function(aAvailability) { + ok(false, "Unexpected success, should get a security error."); + aReject(); + }, + function(aError) { + is(aError.name, "SecurityError", "Should get a security error."); + aResolve(); + } + ); + }); +} + +function testStartRequest() { + return new Promise(function(aResolve, aReject) { + var request = new PresentationRequest("http://example.com"); + + request.start().then( + function(aAvailability) { + ok(false, "Unexpected success, should get a security error."); + aReject(); + }, + function(aError) { + is(aError.name, "SecurityError", "Should get a security error."); + aResolve(); + } + ); + }); +} + +function testDefaultRequest() { + return new Promise(function(aResolve, aReject) { + navigator.presentation.defaultRequest = new PresentationRequest("http://example.com"); + is(navigator.presentation.defaultRequest, null, "DefaultRequest shoud be null."); + aResolve(); + }); +} + +function testReconnectRequest() { + return new Promise(function(aResolve, aReject) { + var request = new PresentationRequest("http://example.com"); + + request.reconnect("dummyId").then( + function(aConnection) { + ok(false, "Unexpected success, should get a security error."); + aReject(); + }, + function(aError) { + is(aError.name, "SecurityError", "Should get a security error."); + aResolve(); + } + ); + }); +} + +function runTest() { + testGetAvailability() + .then(testStartRequest) + .then(testDefaultRequest) + .then(testReconnectRequest) + .then(finish); +} + +window.addEventListener("message", function(evt) { + if (evt.data === "start") { + runTest(); + } +}, {once: true}); + +window.setTimeout(function() { + command("ready-to-start"); +}, 3000); + +</script> +</head> +<body> +</body> +</html> |