2016-07-14 03:44:00 +03:00
|
|
|
|
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Test allow-presentation sandboxing flag</title>
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="application/javascript">
|
2016-07-14 03:44:00 +03:00
|
|
|
|
|
|
|
"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();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:12:00 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-07-14 03:44:00 +03:00
|
|
|
function runTest() {
|
|
|
|
testGetAvailability()
|
|
|
|
.then(testStartRequest)
|
|
|
|
.then(testDefaultRequest)
|
2016-08-02 20:12:00 +03:00
|
|
|
.then(testReconnectRequest)
|
2016-07-14 03:44:00 +03:00
|
|
|
.then(finish);
|
|
|
|
}
|
|
|
|
|
2017-01-25 09:01:52 +03:00
|
|
|
window.addEventListener("message", function(evt) {
|
2016-07-14 03:44:00 +03:00
|
|
|
if (evt.data === "start") {
|
|
|
|
runTest();
|
|
|
|
}
|
2017-01-25 09:01:52 +03:00
|
|
|
}, {once: true});
|
2016-07-14 03:44:00 +03:00
|
|
|
|
|
|
|
window.setTimeout(function() {
|
|
|
|
command("ready-to-start");
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
</html>
|