зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1234128 - Part 3, update test cases. r=smaug.
MozReview-Commit-ID: I5CoLpcXxXz --HG-- rename : dom/presentation/tests/mochitest/file_presentation_non_receiver_oop.html => dom/presentation/tests/mochitest/file_presentation_non_receiver.html rename : dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe_oop.html => dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html rename : dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe_oop.html => dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe.html
This commit is contained in:
Родитель
427d2ea1b5
Коммит
ef7fdfc03a
|
@ -257,7 +257,6 @@ const mockedSessionTransport = {
|
||||||
},
|
},
|
||||||
// in-process case
|
// in-process case
|
||||||
buildDataChannelTransport: function(role, window, controlChannel, listener) {
|
buildDataChannelTransport: function(role, window, controlChannel, listener) {
|
||||||
dump("build data channel transport\n");
|
|
||||||
this._listener = listener;
|
this._listener = listener;
|
||||||
this._role = role;
|
this._role = role;
|
||||||
|
|
||||||
|
|
|
@ -13,26 +13,26 @@
|
||||||
|
|
||||||
function is(a, b, msg) {
|
function is(a, b, msg) {
|
||||||
if (a === b) {
|
if (a === b) {
|
||||||
window.parent.postMessage('OK ' + msg, '*');
|
alert('OK ' + msg);
|
||||||
} else {
|
} else {
|
||||||
window.parent.postMessage('KO ' + msg + ' | reason: ' + a + ' != ' + b, '*');
|
alert('KO ' + msg + ' | reason: ' + a + ' != ' + b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ok(a, msg) {
|
function ok(a, msg) {
|
||||||
window.parent.postMessage((a ? 'OK ' : 'KO ') + msg, '*');
|
alert((a ? 'OK ' : 'KO ') + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function info(msg) {
|
function info(msg) {
|
||||||
window.parent.postMessage('INFO ' + msg, '*');
|
alert('INFO ' + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function command(name, data) {
|
function command(name, data) {
|
||||||
window.parent.postMessage('COMMAND ' + JSON.stringify({name: name, data: data}), '*');
|
alert('COMMAND ' + JSON.stringify({name: name, data: data}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
window.parent.postMessage('DONE', '*');
|
alert('DONE');
|
||||||
}
|
}
|
||||||
|
|
||||||
var connection;
|
var connection;
|
||||||
|
@ -41,12 +41,6 @@ function testConnectionAvailable() {
|
||||||
return new Promise(function(aResolve, aReject) {
|
return new Promise(function(aResolve, aReject) {
|
||||||
info('Receiver: --- testConnectionAvailable ---');
|
info('Receiver: --- testConnectionAvailable ---');
|
||||||
ok(navigator.presentation, "Receiver: navigator.presentation should be available.");
|
ok(navigator.presentation, "Receiver: navigator.presentation should be available.");
|
||||||
// FIXME Sometimes navigator.presentation.receiver is initialized lately.
|
|
||||||
// See bug 1234128 - navigator.presentation.receiver is null in 1-UA use case.
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1234128
|
|
||||||
while (!navigator.presentation.receiver) {
|
|
||||||
info('Receiver: navigator.presentation.receiver is null, see Bug 1234128');
|
|
||||||
}
|
|
||||||
ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available.");
|
ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available.");
|
||||||
navigator.presentation.receiver.getConnection()
|
navigator.presentation.receiver.getConnection()
|
||||||
.then((aConnection) => {
|
.then((aConnection) => {
|
||||||
|
@ -95,14 +89,14 @@ function testIncomingMessage() {
|
||||||
|
|
||||||
function testSendMessage() {
|
function testSendMessage() {
|
||||||
return new Promise(function(aResolve, aReject) {
|
return new Promise(function(aResolve, aReject) {
|
||||||
window.addEventListener('message', function messageHandler(evt) {
|
window.addEventListener('hashchange', function hashchangeHandler(evt) {
|
||||||
var message = evt.data;
|
var message = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
|
||||||
if (message.type === 'trigger-message-from-receiver') {
|
if (message.type === 'trigger-message-from-receiver') {
|
||||||
info('Receiver: --- testSendMessage ---');
|
info('Receiver: --- testSendMessage ---');
|
||||||
connection.send('msg-receiver-to-sender');
|
connection.send('msg-receiver-to-sender');
|
||||||
}
|
}
|
||||||
if (message.type === 'message-from-receiver-received') {
|
if (message.type === 'message-from-receiver-received') {
|
||||||
window.removeEventListener('message', messageHandler);
|
window.removeEventListener('hashchange', hashchangeHandler);
|
||||||
aResolve();
|
aResolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,137 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for B2G PresentationReceiver at receiver side</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="content"></div>
|
|
||||||
<script type="application/javascript;version=1.7">
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function is(a, b, msg) {
|
|
||||||
if (a === b) {
|
|
||||||
alert('OK ' + msg);
|
|
||||||
} else {
|
|
||||||
alert('KO ' + msg + ' | reason: ' + a + ' != ' + b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ok(a, msg) {
|
|
||||||
alert((a ? 'OK ' : 'KO ') + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function info(msg) {
|
|
||||||
alert('INFO ' + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function command(name, data) {
|
|
||||||
alert('COMMAND ' + JSON.stringify({name: name, data: data}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function finish() {
|
|
||||||
alert('DONE');
|
|
||||||
}
|
|
||||||
|
|
||||||
var connection;
|
|
||||||
|
|
||||||
function testConnectionAvailable() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
info('Receiver: --- testConnectionAvailable ---');
|
|
||||||
ok(navigator.presentation, "Receiver: navigator.presentation should be available.");
|
|
||||||
// FIXME Sometimes navigator.presentation.receiver is initialized lately.
|
|
||||||
// See bug 1234128 - navigator.presentation.receiver is null in 1-UA use case.
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1234128
|
|
||||||
while (!navigator.presentation.receiver) {
|
|
||||||
info('Receiver: navigator.presentation.receiver is null, see Bug 1234128');
|
|
||||||
}
|
|
||||||
ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available.");
|
|
||||||
navigator.presentation.receiver.getConnection()
|
|
||||||
.then((aConnection) => {
|
|
||||||
connection = aConnection;
|
|
||||||
ok(connection.id, "Receiver: Connection ID should be set: " + connection.id);
|
|
||||||
is(connection.state, "closed", "Connection state at receiver side should be closed by default.");
|
|
||||||
aResolve();
|
|
||||||
})
|
|
||||||
.catch((aError) => {
|
|
||||||
ok(false, "Receiver: Error occurred when getting the connection: " + aError);
|
|
||||||
finish();
|
|
||||||
aReject();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testConnectionReady() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
info('Receiver: --- testConnectionReady ---');
|
|
||||||
connection.onstatechange = function() {
|
|
||||||
connection.onstatechange = null;
|
|
||||||
is(connection.state, "connected", "Receiver: Connection state should become connected.");
|
|
||||||
aResolve();
|
|
||||||
};
|
|
||||||
if (connection.state === "connected") {
|
|
||||||
connection.onstatechange = null;
|
|
||||||
is(connection.state, "connected", "Receiver: Connection state should become connected.");
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testIncomingMessage() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
info('Receiver: --- testIncomingMessage ---');
|
|
||||||
connection.addEventListener('message', function messageHandler(evt) {
|
|
||||||
connection.removeEventListener('message', messageHandler);
|
|
||||||
let msg = evt.data;
|
|
||||||
is(msg, 'msg-sender-to-receiver', 'Receiver: Receiver should receive message from sender.');
|
|
||||||
command('forward-command', JSON.stringify({ name: 'message-from-sender-received' }));
|
|
||||||
aResolve();
|
|
||||||
});
|
|
||||||
command('forward-command', JSON.stringify({ name: 'trigger-message-from-sender' }));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSendMessage() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
window.addEventListener('hashchange', function hashchangeHandler(evt) {
|
|
||||||
var message = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
|
|
||||||
if (message.type === 'trigger-message-from-receiver') {
|
|
||||||
info('Receiver: --- testSendMessage ---');
|
|
||||||
connection.send('msg-receiver-to-sender');
|
|
||||||
}
|
|
||||||
if (message.type === 'message-from-receiver-received') {
|
|
||||||
window.removeEventListener('hashchange', hashchangeHandler);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTerminateConnection() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
info('Receiver: --- testTerminateConnection ---');
|
|
||||||
connection.onstatechange = function() {
|
|
||||||
connection.onstatechange = null;
|
|
||||||
is(connection.state, "terminated", "Receiver: Connection should be terminated.");
|
|
||||||
aResolve();
|
|
||||||
};
|
|
||||||
connection.terminate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function runTests() {
|
|
||||||
testConnectionAvailable()
|
|
||||||
.then(testConnectionReady)
|
|
||||||
.then(testIncomingMessage)
|
|
||||||
.then(testSendMessage)
|
|
||||||
.then(testTerminateConnection)
|
|
||||||
.then(finish);
|
|
||||||
}
|
|
||||||
|
|
||||||
runTests();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Test for B2G PresentationReceiver at receiver side</title>
|
<title>Test for B2G PresentationReceiver at receiver side (OOP)</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content"></div>
|
<div id="content"></div>
|
||||||
|
@ -11,31 +11,31 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function is(a, b, msg) {
|
function is(a, b, msg) {
|
||||||
window.parent.postMessage((a === b ? 'OK ' : 'KO ') + msg, '*');
|
alert((a === b ? 'OK ' : 'KO ') + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ok(a, msg) {
|
function ok(a, msg) {
|
||||||
window.parent.postMessage((a ? 'OK ' : 'KO ') + msg, '*');
|
alert((a ? 'OK ' : 'KO ') + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function info(msg) {
|
function info(msg) {
|
||||||
window.parent.postMessage('INFO ' + msg, '*');
|
alert('INFO ' + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function command(msg) {
|
function command(msg) {
|
||||||
window.parent.postMessage('COMMAND ' + JSON.stringify(msg), '*');
|
alert('COMMAND ' + JSON.stringify(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
window.parent.postMessage('DONE', '*');
|
alert('DONE');
|
||||||
}
|
}
|
||||||
|
|
||||||
var connection;
|
var connection;
|
||||||
|
|
||||||
function testConnectionAvailable() {
|
function testConnectionAvailable() {
|
||||||
return new Promise(function(aResolve, aReject) {
|
return new Promise(function(aResolve, aReject) {
|
||||||
ok(navigator.presentation, "navigator.presentation should be available.");
|
ok(navigator.presentation, "navigator.presentation should be available in OOP receiving pages.");
|
||||||
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available.");
|
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available in OOP receiving pages.");
|
||||||
|
|
||||||
navigator.presentation.receiver.getConnection().then(
|
navigator.presentation.receiver.getConnection().then(
|
||||||
function(aConnection) {
|
function(aConnection) {
|
||||||
|
@ -54,6 +54,26 @@ function testConnectionAvailable() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testConnectionAvailableSameOriginInnerIframe() {
|
||||||
|
return new Promise(function(aResolve, aReject) {
|
||||||
|
var iframe = document.createElement('iframe');
|
||||||
|
iframe.setAttribute('src', './file_presentation_receiver_inner_iframe.html');
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
aResolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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.html');
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
aResolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function testConnectionReady() {
|
function testConnectionReady() {
|
||||||
return new Promise(function(aResolve, aReject) {
|
return new Promise(function(aResolve, aReject) {
|
||||||
connection.onstatechange = function() {
|
connection.onstatechange = function() {
|
||||||
|
@ -77,7 +97,7 @@ function testIncomingMessage() {
|
||||||
});
|
});
|
||||||
|
|
||||||
command({ name: 'trigger-incoming-message',
|
command({ name: 'trigger-incoming-message',
|
||||||
data: incomingMessage });
|
data: incomingMessage });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +114,8 @@ function testTerminateConnection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
testConnectionAvailable().
|
testConnectionAvailable().
|
||||||
|
then(testConnectionAvailableSameOriginInnerIframe).
|
||||||
|
then(testConnectionUnavailableDiffOriginInnerIframe).
|
||||||
then(testConnectionReady).
|
then(testConnectionReady).
|
||||||
then(testIncomingMessage).
|
then(testIncomingMessage).
|
||||||
then(testTerminateConnection).
|
then(testTerminateConnection).
|
||||||
|
|
|
@ -11,23 +11,27 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function is(a, b, msg) {
|
function is(a, b, msg) {
|
||||||
window.parent.postMessage((a === b ? 'OK ' : 'KO ') + msg, '*');
|
if (a === b) {
|
||||||
|
alert('OK ' + msg);
|
||||||
|
} else {
|
||||||
|
alert('KO ' + msg + ' | reason: ' + a + ' != ' + b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ok(a, msg) {
|
function ok(a, msg) {
|
||||||
window.parent.postMessage((a ? 'OK ' : 'KO ') + msg, '*');
|
alert((a ? 'OK ' : 'KO ') + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function info(msg) {
|
function info(msg) {
|
||||||
window.parent.postMessage('INFO ' + msg, '*');
|
alert('INFO ' + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function command(msg) {
|
function command(name, data) {
|
||||||
window.parent.postMessage('COMMAND ' + JSON.stringify(msg), '*');
|
alert('COMMAND ' + JSON.stringify({name: name, data: data}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
window.parent.postMessage('DONE', '*');
|
alert('DONE');
|
||||||
}
|
}
|
||||||
|
|
||||||
var connection;
|
var connection;
|
||||||
|
@ -63,7 +67,7 @@ function testUnexpectedControlChannelClose() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Trigger the control channel to be closed with error code.
|
// Trigger the control channel to be closed with error code.
|
||||||
command({ name: 'trigger-control-channel-close', data: 0x80004004 /* NS_ERROR_ABORT */ });
|
command('trigger-control-channel-close', 0x80004004 /* NS_ERROR_ABORT */);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Test for B2G PresentationReceiver at receiver side (OOP)</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="content"></div>
|
|
||||||
<script type="application/javascript;version=1.7">
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function is(a, b, msg) {
|
|
||||||
alert((a === b ? 'OK ' : 'KO ') + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ok(a, msg) {
|
|
||||||
alert((a ? 'OK ' : 'KO ') + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function info(msg) {
|
|
||||||
alert('INFO ' + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function command(msg) {
|
|
||||||
alert('COMMAND ' + JSON.stringify(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
function finish() {
|
|
||||||
alert('DONE');
|
|
||||||
}
|
|
||||||
|
|
||||||
var connection;
|
|
||||||
|
|
||||||
function testConnectionAvailable() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
ok(navigator.presentation, "navigator.presentation should be available in OOP receiving pages.");
|
|
||||||
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available in OOP receiving pages.");
|
|
||||||
|
|
||||||
navigator.presentation.receiver.getConnection().then(
|
|
||||||
function(aConnection) {
|
|
||||||
connection = aConnection;
|
|
||||||
|
|
||||||
ok(connection.id, "Connection ID should be set: " + connection.id);
|
|
||||||
is(connection.state, "closed", "Connection state at receiver side should be closed by default.");
|
|
||||||
aResolve();
|
|
||||||
},
|
|
||||||
function(aError) {
|
|
||||||
ok(false, "Error occurred when getting the connection: " + aError);
|
|
||||||
finish();
|
|
||||||
aReject();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testConnectionAvailableSameOriginInnerIframe() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
var iframe = document.createElement('iframe');
|
|
||||||
iframe.setAttribute('src', './file_presentation_receiver_inner_iframe_oop.html');
|
|
||||||
document.body.appendChild(iframe);
|
|
||||||
|
|
||||||
aResolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
|
||||||
connection.onstatechange = null;
|
|
||||||
is(connection.state, "connected", "Connection state should become connected.");
|
|
||||||
aResolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
command({ name: 'trigger-incoming-offer' });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testIncomingMessage() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
const incomingMessage = "test incoming message";
|
|
||||||
|
|
||||||
connection.addEventListener('message', function messageHandler(aEvent) {
|
|
||||||
connection.removeEventListener('message', messageHandler);
|
|
||||||
is(aEvent.data, incomingMessage, "An incoming message should be received.");
|
|
||||||
aResolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
command({ name: 'trigger-incoming-message',
|
|
||||||
data: incomingMessage });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTerminateConnection() {
|
|
||||||
return new Promise(function(aResolve, aReject) {
|
|
||||||
connection.onstatechange = function() {
|
|
||||||
connection.onstatechange = null;
|
|
||||||
is(connection.state, "terminated", "Connection should be terminated.");
|
|
||||||
aResolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
connection.terminate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
testConnectionAvailable().
|
|
||||||
// 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).
|
|
||||||
then(finish);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -4,13 +4,11 @@ support-files =
|
||||||
PresentationSessionChromeScript.js
|
PresentationSessionChromeScript.js
|
||||||
PresentationSessionChromeScript1UA.js
|
PresentationSessionChromeScript1UA.js
|
||||||
file_presentation_1ua_receiver.html
|
file_presentation_1ua_receiver.html
|
||||||
file_presentation_1ua_receiver_oop.html
|
file_presentation_non_receiver_inner_iframe.html
|
||||||
file_presentation_non_receiver_inner_iframe_oop.html
|
file_presentation_non_receiver.html
|
||||||
file_presentation_non_receiver_oop.html
|
|
||||||
file_presentation_receiver.html
|
file_presentation_receiver.html
|
||||||
file_presentation_receiver_establish_connection_error.html
|
file_presentation_receiver_establish_connection_error.html
|
||||||
file_presentation_receiver_inner_iframe_oop.html
|
file_presentation_receiver_inner_iframe.html
|
||||||
file_presentation_receiver_oop.html
|
|
||||||
|
|
||||||
[test_presentation_dc_sender.html]
|
[test_presentation_dc_sender.html]
|
||||||
skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
|
skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
|
||||||
|
|
|
@ -26,26 +26,9 @@ var request;
|
||||||
var connection;
|
var connection;
|
||||||
var receiverIframe;
|
var receiverIframe;
|
||||||
|
|
||||||
// This event is triggered when the iframe calls "postMessage".
|
|
||||||
window.addEventListener('message', function messageHandler(evt) {
|
|
||||||
var message = evt.data;
|
|
||||||
if (/^OK /.exec(message)) {
|
|
||||||
ok(true, message.replace(/^OK /, ''));
|
|
||||||
} else if (/^KO /.exec(message)) {
|
|
||||||
ok(false, message.replace(/^KO /, ''));
|
|
||||||
} else if (/^INFO /.exec(message)) {
|
|
||||||
info(message.replace(/^INFO /, ''));
|
|
||||||
} else if (/^COMMAND /.exec(message)) {
|
|
||||||
var command = JSON.parse(message.replace(/^COMMAND /, ''));
|
|
||||||
gScript.sendAsyncMessage(command.name, command.data);
|
|
||||||
} else if (/^DONE$/.exec(message)) {
|
|
||||||
window.removeEventListener('message', messageHandler);
|
|
||||||
teardown();
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
function postMessageToIframe(aType) {
|
function postMessageToIframe(aType) {
|
||||||
receiverIframe.contentWindow.postMessage({ type: aType }, '*');
|
receiverIframe.src = receiverUrl + "#" +
|
||||||
|
encodeURIComponent(JSON.stringify({ type: aType }));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
|
@ -61,11 +44,33 @@ function setup() {
|
||||||
gScript.removeMessageListener('control-channel-established', controlChannelEstablishedHandler);
|
gScript.removeMessageListener('control-channel-established', controlChannelEstablishedHandler);
|
||||||
receiverIframe = document.createElement('iframe');
|
receiverIframe = document.createElement('iframe');
|
||||||
receiverIframe.setAttribute('src', receiverUrl);
|
receiverIframe.setAttribute('src', receiverUrl);
|
||||||
|
receiverIframe.setAttribute("mozbrowser", "true");
|
||||||
|
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||||
receiverIframe.onload = function() {
|
receiverIframe.onload = function() {
|
||||||
info('Receiver loaded.');
|
info('Receiver loaded.');
|
||||||
gScript.sendAsyncMessage('trigger-control-channel-open');
|
gScript.sendAsyncMessage('trigger-control-channel-open');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This event is triggered when the iframe calls "alert".
|
||||||
|
receiverIframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
|
||||||
|
var message = evt.detail.message;
|
||||||
|
debug('Got iframe message: ' + message);
|
||||||
|
if (/^OK /.exec(message)) {
|
||||||
|
ok(true, message.replace(/^OK /, ""));
|
||||||
|
} else if (/^KO /.exec(message)) {
|
||||||
|
ok(false, message.replace(/^KO /, ""));
|
||||||
|
} else if (/^INFO /.exec(message)) {
|
||||||
|
info(message.replace(/^INFO /, ""));
|
||||||
|
} else if (/^COMMAND /.exec(message)) {
|
||||||
|
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||||
|
gScript.sendAsyncMessage(command.name, command.data);
|
||||||
|
} else if (/^DONE$/.exec(message)) {
|
||||||
|
receiverIframe.removeEventListener("mozbrowsershowmodalprompt",
|
||||||
|
receiverListener);
|
||||||
|
teardown();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
var promise = new Promise(function(aResolve, aReject) {
|
var promise = new Promise(function(aResolve, aReject) {
|
||||||
document.body.appendChild(receiverIframe);
|
document.body.appendChild(receiverIframe);
|
||||||
aResolve(receiverIframe);
|
aResolve(receiverIframe);
|
||||||
|
@ -200,10 +205,12 @@ SimpleTest.waitForExplicitFinish();
|
||||||
SpecialPowers.pushPermissions([
|
SpecialPowers.pushPermissions([
|
||||||
{type: 'presentation-device-manage', allow: false, context: document},
|
{type: 'presentation-device-manage', allow: false, context: document},
|
||||||
{type: 'presentation', allow: true, context: document},
|
{type: 'presentation', allow: true, context: document},
|
||||||
|
{type: "browser", allow: true, context: document},
|
||||||
], () => {
|
], () => {
|
||||||
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
||||||
["dom.presentation.test.enabled", true],
|
["dom.presentation.test.enabled", true],
|
||||||
["dom.presentation.test.stage", 0]]},
|
["dom.presentation.test.stage", 0],
|
||||||
|
["dom.mozBrowserFramesEnabled", true]]},
|
||||||
runTests);
|
runTests);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript1UA.js'));
|
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript1UA.js'));
|
||||||
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_1ua_receiver_oop.html');
|
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_1ua_receiver.html');
|
||||||
var request;
|
var request;
|
||||||
var connection;
|
var connection;
|
||||||
var receiverIframe;
|
var receiverIframe;
|
||||||
|
@ -46,6 +46,7 @@ function setup() {
|
||||||
receiverIframe = document.createElement('iframe');
|
receiverIframe = document.createElement('iframe');
|
||||||
receiverIframe.setAttribute("remote", "true");
|
receiverIframe.setAttribute("remote", "true");
|
||||||
receiverIframe.setAttribute("mozbrowser", "true");
|
receiverIframe.setAttribute("mozbrowser", "true");
|
||||||
|
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||||
receiverIframe.setAttribute('src', receiverUrl);
|
receiverIframe.setAttribute('src', receiverUrl);
|
||||||
receiverIframe.addEventListener("mozbrowserloadend", function mozbrowserloadendHander() {
|
receiverIframe.addEventListener("mozbrowserloadend", function mozbrowserloadendHander() {
|
||||||
receiverIframe.removeEventListener("mozbrowserloadend", mozbrowserloadendHander);
|
receiverIframe.removeEventListener("mozbrowserloadend", mozbrowserloadendHander);
|
||||||
|
|
|
@ -29,23 +29,24 @@ function setup() {
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.setAttribute('src', receiverUrl);
|
iframe.setAttribute('src', receiverUrl);
|
||||||
|
iframe.setAttribute("mozbrowser", "true");
|
||||||
|
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||||
|
|
||||||
// This event is triggered when the iframe calls "postMessage".
|
// This event is triggered when the iframe calls "alert".
|
||||||
window.addEventListener('message', function listener(aEvent) {
|
iframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
|
||||||
var message = aEvent.data;
|
var message = evt.detail.message;
|
||||||
if (/^OK /.exec(message)) {
|
if (/^OK /.exec(message)) {
|
||||||
ok(true, "Message from iframe: " + message);
|
ok(true, message.replace(/^OK /, ""));
|
||||||
} else if (/^KO /.exec(message)) {
|
} else if (/^KO /.exec(message)) {
|
||||||
ok(false, "Message from iframe: " + message);
|
ok(false, message.replace(/^KO /, ""));
|
||||||
} else if (/^INFO /.exec(message)) {
|
} else if (/^INFO /.exec(message)) {
|
||||||
info("Message from iframe: " + message);
|
info(message.replace(/^INFO /, ""));
|
||||||
} else if (/^COMMAND /.exec(message)) {
|
} else if (/^COMMAND /.exec(message)) {
|
||||||
var command = JSON.parse(message.replace(/^COMMAND /, ''));
|
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||||
gScript.sendAsyncMessage(command.name, command.data);
|
gScript.sendAsyncMessage(command.name, command.data);
|
||||||
} else if (/^DONE$/.exec(message)) {
|
} else if (/^DONE$/.exec(message)) {
|
||||||
ok(true, "Messaging from iframe complete.");
|
iframe.removeEventListener("mozbrowsershowmodalprompt",
|
||||||
window.removeEventListener('message', listener);
|
receiverListener);
|
||||||
|
|
||||||
teardown();
|
teardown();
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -125,9 +126,11 @@ SimpleTest.waitForExplicitFinish();
|
||||||
SpecialPowers.pushPermissions([
|
SpecialPowers.pushPermissions([
|
||||||
{type: 'presentation-device-manage', allow: false, context: document},
|
{type: 'presentation-device-manage', allow: false, context: document},
|
||||||
{type: 'presentation', allow: true, context: document},
|
{type: 'presentation', allow: true, context: document},
|
||||||
|
{type: "browser", allow: true, context: document},
|
||||||
], function() {
|
], function() {
|
||||||
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
||||||
["dom.presentation.session_transport.data_channel.enable", true]]},
|
["dom.presentation.session_transport.data_channel.enable", true],
|
||||||
|
["dom.mozBrowserFramesEnabled", true]]},
|
||||||
runTests);
|
runTests);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,13 @@ function setup() {
|
||||||
gScript.sendAsyncMessage('trigger-device-add');
|
gScript.sendAsyncMessage('trigger-device-add');
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
|
iframe.setAttribute('mozbrowser', 'true');
|
||||||
|
iframe.setAttribute('mozpresentation', receiverUrl);
|
||||||
iframe.setAttribute('src', receiverUrl);
|
iframe.setAttribute('src', receiverUrl);
|
||||||
|
|
||||||
// This event is triggered when the iframe calls "postMessage".
|
// This event is triggered when the iframe calls "postMessage".
|
||||||
window.addEventListener('message', function listener(aEvent) {
|
iframe.addEventListener('mozbrowsershowmodalprompt', function listener(aEvent) {
|
||||||
var message = aEvent.data;
|
var message = aEvent.detail.message;
|
||||||
if (/^OK /.exec(message)) {
|
if (/^OK /.exec(message)) {
|
||||||
ok(true, "Message from iframe: " + message);
|
ok(true, "Message from iframe: " + message);
|
||||||
} else if (/^KO /.exec(message)) {
|
} else if (/^KO /.exec(message)) {
|
||||||
|
@ -44,7 +46,7 @@ function setup() {
|
||||||
gScript.sendAsyncMessage(command.name, command.data);
|
gScript.sendAsyncMessage(command.name, command.data);
|
||||||
} else if (/^DONE$/.exec(message)) {
|
} else if (/^DONE$/.exec(message)) {
|
||||||
ok(true, "Messaging from iframe complete.");
|
ok(true, "Messaging from iframe complete.");
|
||||||
window.removeEventListener('message', listener);
|
iframe.removeEventListener('mozbrowsershowmodalprompt', listener);
|
||||||
|
|
||||||
teardown();
|
teardown();
|
||||||
}
|
}
|
||||||
|
@ -120,8 +122,10 @@ SimpleTest.waitForExplicitFinish();
|
||||||
SpecialPowers.pushPermissions([
|
SpecialPowers.pushPermissions([
|
||||||
{type: 'presentation-device-manage', allow: false, context: document},
|
{type: 'presentation-device-manage', allow: false, context: document},
|
||||||
{type: 'presentation', allow: true, context: document},
|
{type: 'presentation', allow: true, context: document},
|
||||||
|
{type: 'browser', allow: true, context: document},
|
||||||
], function() {
|
], function() {
|
||||||
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
||||||
|
["dom.mozBrowserFramesEnabled", true],
|
||||||
["dom.presentation.session_transport.data_channel.enable", false]]},
|
["dom.presentation.session_transport.data_channel.enable", false]]},
|
||||||
runTests);
|
runTests);
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,23 +26,24 @@ function setup() {
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.setAttribute('src', receiverUrl);
|
iframe.setAttribute('src', receiverUrl);
|
||||||
|
iframe.setAttribute("mozbrowser", "true");
|
||||||
|
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||||
|
|
||||||
// This event is triggered when the iframe calls "postMessage".
|
// This event is triggered when the iframe calls "alert".
|
||||||
window.addEventListener('message', function listener(aEvent) {
|
iframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
|
||||||
var message = aEvent.data;
|
var message = evt.detail.message;
|
||||||
if (/^OK /.exec(message)) {
|
if (/^OK /.exec(message)) {
|
||||||
ok(true, "Message from iframe: " + message);
|
ok(true, message.replace(/^OK /, ""));
|
||||||
} else if (/^KO /.exec(message)) {
|
} else if (/^KO /.exec(message)) {
|
||||||
ok(false, "Message from iframe: " + message);
|
ok(false, message.replace(/^KO /, ""));
|
||||||
} else if (/^INFO /.exec(message)) {
|
} else if (/^INFO /.exec(message)) {
|
||||||
info("Message from iframe: " + message);
|
info(message.replace(/^INFO /, ""));
|
||||||
} else if (/^COMMAND /.exec(message)) {
|
} else if (/^COMMAND /.exec(message)) {
|
||||||
var command = JSON.parse(message.replace(/^COMMAND /, ''));
|
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||||
gScript.sendAsyncMessage(command.name, command.data);
|
gScript.sendAsyncMessage(command.name, command.data);
|
||||||
} else if (/^DONE$/.exec(message)) {
|
} else if (/^DONE$/.exec(message)) {
|
||||||
ok(true, "Messaging from iframe complete.");
|
iframe.removeEventListener("mozbrowsershowmodalprompt",
|
||||||
window.removeEventListener('message', listener);
|
receiverListener);
|
||||||
|
|
||||||
teardown();
|
teardown();
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -95,9 +96,11 @@ SimpleTest.waitForExplicitFinish();
|
||||||
SpecialPowers.pushPermissions([
|
SpecialPowers.pushPermissions([
|
||||||
{type: 'presentation-device-manage', allow: false, context: document},
|
{type: 'presentation-device-manage', allow: false, context: document},
|
||||||
{type: 'presentation', allow: true, context: document},
|
{type: 'presentation', allow: true, context: document},
|
||||||
|
{type: "browser", allow: true, context: document},
|
||||||
], function() {
|
], function() {
|
||||||
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
||||||
["dom.presentation.session_transport.data_channel.enable", false]]},
|
["dom.presentation.session_transport.data_channel.enable", false],
|
||||||
|
["dom.mozBrowserFramesEnabled", true]]},
|
||||||
runTests);
|
runTests);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
|
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
|
||||||
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_receiver_oop.html');
|
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_receiver.html');
|
||||||
var nonReceiverUrl = SimpleTest.getTestFileURL('file_presentation_non_receiver_oop.html');
|
var nonReceiverUrl = SimpleTest.getTestFileURL('file_presentation_non_receiver.html');
|
||||||
|
|
||||||
var isReceiverFinished = false;
|
var isReceiverFinished = false;
|
||||||
var isNonReceiverFinished = false;
|
var isNonReceiverFinished = false;
|
||||||
|
@ -35,6 +35,7 @@ function setup() {
|
||||||
var receiverIframe = document.createElement('iframe');
|
var receiverIframe = document.createElement('iframe');
|
||||||
receiverIframe.setAttribute('remote', 'true');
|
receiverIframe.setAttribute('remote', 'true');
|
||||||
receiverIframe.setAttribute('mozbrowser', 'true');
|
receiverIframe.setAttribute('mozbrowser', 'true');
|
||||||
|
receiverIframe.setAttribute('mozpresentation', receiverUrl);
|
||||||
receiverIframe.setAttribute('src', receiverUrl);
|
receiverIframe.setAttribute('src', receiverUrl);
|
||||||
|
|
||||||
// This event is triggered when the iframe calls "alert".
|
// This event is triggered when the iframe calls "alert".
|
||||||
|
|
Загрузка…
Ссылка в новой задаче