Bug 1245031 - [Presentation WebAPI] Add missing test receiver files. r=schien

This commit is contained in:
Sean Lin 2016-02-02 17:08:07 +08:00
parent 719c86f0b7
commit a5a01397c9
4 changed files with 70 additions and 2 deletions

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for B2G PresentationReceiver on a non-receiver inner iframe of the receiver page at receiver side (OOP)</title>
</head>
<body onload="testConnectionAvailable()">
<div id="content"></div>
<script type="application/javascript;version=1.7">
"use strict";
function ok(a, msg) {
alert((a ? 'OK ' : 'KO ') + msg);
}
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(!navigator.presentation, "navigator.presentation shouldn't be available in inner iframes with different origins from receiving OOP pages.");
aResolve();
});
}
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for B2G PresentationReceiver in an inner iframe of the receiver page at receiver side (OOP)</title>
</head>
<body onload="testConnectionAvailable()">
<div id="content"></div>
<script type="application/javascript;version=1.7">
"use strict";
function ok(a, msg) {
alert((a ? 'OK ' : 'KO ') + msg);
}
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(navigator.presentation, "navigator.presentation should be available in same-origin inner iframes of receiving OOP pages.");
aResolve();
});
}
</script>
</body>
</html>

View File

@ -54,7 +54,7 @@ function testConnectionAvailable() {
});
}
function testConnectionAvailableInnerIframe() {
function testConnectionAvailableSameOriginInnerIframe() {
return new Promise(function(aResolve, aReject) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', './file_presentation_receiver_inner_iframe_oop.html');
@ -64,6 +64,16 @@ function testConnectionAvailableInnerIframe() {
});
}
function testConnectionUnavailableDiffOriginInnerIframe() {
return new Promise(function(aResolve, aReject) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', 'http://example.com/tests/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe_oop.html');
document.body.appendChild(iframe);
aResolve();
});
}
function testConnectionReady() {
return new Promise(function(aResolve, aReject) {
connection.onstatechange = function() {
@ -104,7 +114,11 @@ function testTerminateConnection() {
}
testConnectionAvailable().
then(testConnectionAvailableInnerIframe).
// TODO Bug 1234128 - Fix the timing issue for navigator.presentation.receiver.
// This test fails intermittently under some edge cases. Disable it for now until
// the issue gets fixed.
// then(testConnectionAvailableSameOriginInnerIframe).
then(testConnectionUnavailableDiffOriginInnerIframe).
then(testConnectionReady).
then(testIncomingMessage).
then(testTerminateConnection).

View File

@ -6,6 +6,8 @@ support-files =
file_presentation_receiver_oop.html
file_presentation_non_receiver_oop.html
file_presentation_receiver_establish_connection_error.html
file_presentation_receiver_inner_iframe_oop.html
file_presentation_non_receiver_inner_iframe_oop.html
[test_presentation_device_info.html]
[test_presentation_device_info_permission.html]