Bug 1212702 - [Presentation WebAPI] Rename to PresentationConnection. Part 2 - Tests. r=smaug

--HG--
rename : dom/presentation/tests/mochitest/file_presentation_receiver_start_session_error.html => dom/presentation/tests/mochitest/file_presentation_receiver_establish_connection_error.html
rename : dom/presentation/tests/mochitest/test_presentation_receiver_start_session_error.html => dom/presentation/tests/mochitest/test_presentation_receiver_establish_connection_error.html
rename : dom/presentation/tests/mochitest/test_presentation_receiver_start_session_timeout.html => dom/presentation/tests/mochitest/test_presentation_receiver_establish_connection_timeout.html
rename : dom/presentation/tests/mochitest/test_presentation_sender_start_session_error.html => dom/presentation/tests/mochitest/test_presentation_sender_establish_connection_error.html
This commit is contained in:
Sean Lin 2015-10-12 10:39:20 +08:00
parent 734f22b0e0
commit 871f8e8820
13 changed files with 150 additions and 151 deletions

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test for B2G Presentation Session API on a non-receiver page at receiver side (OOP)</title>
<title>Test for B2G PresentationReceiver on a non-receiver page at receiver side (OOP)</title>
</head>
<body>
<div id="content"></div>
@ -26,7 +26,7 @@ function finish() {
alert('DONE');
}
function testSessionAvailable() {
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(navigator.presentation, "navigator.presentation should be available in OOP pages.");
ok(!navigator.presentation.receiver, "Non-receiving OOP pages shouldn't get a presentation receiver instance.");
@ -34,7 +34,7 @@ function testSessionAvailable() {
});
}
testSessionAvailable().
testConnectionAvailable().
then(finish);
</script>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test for B2G Presentation Session API at receiver side</title>
<title>Test for B2G PresentationReceiver at receiver side</title>
</head>
<body>
<div id="content"></div>
@ -30,23 +30,23 @@ function finish() {
window.parent.postMessage('DONE', '*');
}
var session;
var connection;
function testSessionAvailable() {
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(navigator.presentation, "navigator.presentation should be available.");
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available.");
navigator.presentation.receiver.getSession().then(
function(aSession) {
session = aSession;
navigator.presentation.receiver.getConnection().then(
function(aConnection) {
connection = aConnection;
ok(session.id, "Session ID should be set: " + session.id);
is(session.state, "closed", "Session state at receiver side should be closed by default.");
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 session: " + aError);
ok(false, "Error occurred when getting the connection: " + aError);
finish();
aReject();
}
@ -54,11 +54,11 @@ function testSessionAvailable() {
});
}
function testSessionReady() {
function testConnectionReady() {
return new Promise(function(aResolve, aReject) {
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "connected", "Session state should become connected.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "connected", "Connection state should become connected.");
aResolve();
};
@ -70,8 +70,8 @@ function testIncomingMessage() {
return new Promise(function(aResolve, aReject) {
const incomingMessage = "test incoming message";
session.addEventListener('message', function messageHandler(aEvent) {
session.removeEventListener('message', messageHandler);
connection.addEventListener('message', function messageHandler(aEvent) {
connection.removeEventListener('message', messageHandler);
is(aEvent.data, incomingMessage, "An incoming message should be received.");
aResolve();
});
@ -81,22 +81,22 @@ function testIncomingMessage() {
});
}
function testTerminateSession() {
function testTerminateConnection() {
return new Promise(function(aResolve, aReject) {
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "terminated", "Session should be terminated.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "terminated", "Connection should be terminated.");
aResolve();
};
session.terminate();
connection.terminate();
});
}
testSessionAvailable().
then(testSessionReady).
testConnectionAvailable().
then(testConnectionReady).
then(testIncomingMessage).
then(testTerminateSession).
then(testTerminateConnection).
then(finish);
</script>

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test for startSession errors of B2G Presentation API at receiver side</title>
<title>Test for connection establishing errors of B2G Presentation API at receiver side</title>
</head>
<body>
<div id="content"></div>
@ -30,23 +30,23 @@ function finish() {
window.parent.postMessage('DONE', '*');
}
var session;
var connection;
function testSessionAvailable() {
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(navigator.presentation, "navigator.presentation should be available.");
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available.");
navigator.presentation.receiver.getSession().then(
function(aSession) {
session = aSession;
navigator.presentation.receiver.getConnection().then(
function(aConnection) {
connection = aConnection;
ok(session.id, "Session ID should be set: " + session.id);
is(session.state, "closed", "Session state at receiver side should be closed by default.");
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 session: " + aError);
ok(false, "Error occurred when getting the connection: " + aError);
finish();
aReject();
}
@ -56,9 +56,9 @@ function testSessionAvailable() {
function testUnexpectedControlChannelClose() {
return new Promise(function(aResolve, aReject) {
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "terminated", "Session state should become terminated.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "terminated", "Connection state should become terminated.");
aResolve();
};
@ -67,7 +67,7 @@ function testUnexpectedControlChannelClose() {
});
}
testSessionAvailable().
testConnectionAvailable().
then(testUnexpectedControlChannelClose).
then(finish);

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test for B2G Presentation Session API at receiver side (OOP)</title>
<title>Test for B2G PresentationReceiver at receiver side (OOP)</title>
</head>
<body>
<div id="content"></div>
@ -30,23 +30,23 @@ function finish() {
alert('DONE');
}
var session;
var connection;
function testSessionAvailable() {
function testConnectionAvailable() {
return new Promise(function(aResolve, aReject) {
ok(navigator.presentation, "navigator.presentation should be available.");
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available.");
navigator.presentation.receiver.getSession().then(
function(aSession) {
session = aSession;
navigator.presentation.receiver.getConnection().then(
function(aConnection) {
connection = aConnection;
ok(session.id, "Session ID should be set: " + session.id);
is(session.state, "closed", "Session state at receiver side should be closed by default.");
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 session: " + aError);
ok(false, "Error occurred when getting the connection: " + aError);
finish();
aReject();
}
@ -54,11 +54,11 @@ function testSessionAvailable() {
});
}
function testSessionReady() {
function testConnectionReady() {
return new Promise(function(aResolve, aReject) {
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "connected", "Session state should become connected.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "connected", "Connection state should become connected.");
aResolve();
};
@ -70,8 +70,8 @@ function testIncomingMessage() {
return new Promise(function(aResolve, aReject) {
const incomingMessage = "test incoming message";
session.addEventListener('message', function messageHandler(aEvent) {
session.removeEventListener('message', messageHandler);
connection.addEventListener('message', function messageHandler(aEvent) {
connection.removeEventListener('message', messageHandler);
is(aEvent.data, incomingMessage, "An incoming message should be received.");
aResolve();
});
@ -81,22 +81,22 @@ function testIncomingMessage() {
});
}
function testTerminateSession() {
function testTerminateConnection() {
return new Promise(function(aResolve, aReject) {
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "terminated", "Session should be terminated.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "terminated", "Connection should be terminated.");
aResolve();
};
session.terminate();
connection.terminate();
});
}
testSessionAvailable().
then(testSessionReady).
testConnectionAvailable().
then(testConnectionReady).
then(testIncomingMessage).
then(testTerminateSession).
then(testTerminateConnection).
then(finish);
</script>

View File

@ -5,21 +5,21 @@ support-files =
file_presentation_receiver.html
file_presentation_receiver_oop.html
file_presentation_non_receiver_oop.html
file_presentation_receiver_start_session_error.html
file_presentation_receiver_establish_connection_error.html
[test_presentation_device_info.html]
[test_presentation_device_info_permission.html]
[test_presentation_sender_disconnect.html]
skip-if = toolkit == 'android' # Bug 1129785
[test_presentation_sender_start_session_error.html]
[test_presentation_sender_establish_connection_error.html]
skip-if = toolkit == 'android' # Bug 1129785
[test_presentation_sender.html]
skip-if = toolkit == 'android' # Bug 1129785
[test_presentation_sender_default_request.html]
skip-if = toolkit == 'android' # Bug 1129785
[test_presentation_receiver_start_session_error.html]
[test_presentation_receiver_establish_connection_error.html]
skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android' || os == 'mac' || os == 'win' || buildapp == 'mulet') # Bug 1129785, Bug 1204709
[test_presentation_receiver_start_session_timeout.html]
[test_presentation_receiver_establish_connection_timeout.html]
skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785
[test_presentation_receiver.html]
skip-if = (e10s || toolkit == 'gonk' || toolkit == 'android') # Bug 1129785

View File

@ -4,12 +4,12 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for B2G Presentation Session API at receiver side</title>
<title>Test for B2G PresentationConnection API at receiver side</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for B2G Presentation Session API at receiver side</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for B2G PresentationConnection API at receiver side</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>

View File

@ -4,22 +4,21 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for startSession errors of B2G Presentation API at receiver side</title>
<title>Test for connection establishing errors of B2G Presentation API at receiver side</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for startSession errors of B2G Presentation API at receiver side</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for connection establishing errors of B2G Presentation API at receiver side</a>
<script type="application/javascript;version=1.8">
'use strict';
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_receiver_start_session_error.html');
var receiverUrl = SimpleTest.getTestFileURL('file_presentation_receiver_establish_connection_error.html');
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(SpecialPowers.Ci.nsIObserverService);
var session;
function setup() {
return new Promise(function(aResolve, aReject) {

View File

@ -4,12 +4,12 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for startSession timeout of B2G Presentation API at receiver side</title>
<title>Test for connection establishing timeout of B2G Presentation API at receiver side</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for startSession timeout of B2G Presentation API at receiver side</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for connection establishing timeout of B2G Presentation API at receiver side</a>
<script type="application/javascript;version=1.8">
'use strict';

View File

@ -4,12 +4,12 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for B2G Presentation Session API at receiver side (OOP)</title>
<title>Test for B2G PresentationConnection API at receiver side (OOP)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test B2G Presentation Session API at receiver side (OOP)</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test B2G PresentationConnection API at receiver side (OOP)</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>

View File

@ -16,7 +16,7 @@
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
var request;
var session;
var connection;
function testSetup() {
return new Promise(function(aResolve, aReject) {
@ -41,7 +41,7 @@ function testSetup() {
});
}
function testStartSession() {
function testStartConnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -87,32 +87,32 @@ function testStartSession() {
info("Data notification is enabled for data transport channel.");
});
var sessionFromEvent;
request.onsessionconnect = function(aEvent) {
request.onsessionconnect = null;
sessionFromEvent = aEvent.session;
ok(sessionFromEvent, "|sessionconnect| event is fired with a session.");
var connectionFromEvent;
request.onconnectionavailable = function(aEvent) {
request.onconnectionavailable = null;
connectionFromEvent = aEvent.connection;
ok(connectionFromEvent, "|connectionavailable| event is fired with a connection.");
if (session) {
is(session, sessionFromEvent, "The session from promise and the one from |sessionconnect| event should be the same.");
if (connection) {
is(connection, connectionFromEvent, "The connection from promise and the one from |connectionavailable| event should be the same.");
aResolve();
}
};
request.start().then(
function(aSession) {
session = aSession;
ok(session, "Session should be availlable.");
ok(session.id, "Session ID should be set.");
is(session.state, "connected", "Session state at sender side should be connected by default.");
function(aConnection) {
connection = aConnection;
ok(connection, "Connection should be available.");
ok(connection.id, "Connection ID should be set.");
is(connection.state, "connected", "Connection state at sender side should be connected by default.");
if (sessionFromEvent) {
is(session, sessionFromEvent, "The session from promise and the one from |sessionconnect| event should be the same.");
if (connectionFromEvent) {
is(connection, connectionFromEvent, "The connection from promise and the one from |connectionavailable| event should be the same.");
aResolve();
}
},
function(aError) {
ok(false, "Error occurred when starting session: " + aError);
ok(false, "Error occurred when establishing a connection: " + aError);
teardown();
aReject();
}
@ -130,7 +130,7 @@ function testSend() {
aResolve();
});
session.send(outgoingMessage);
connection.send(outgoingMessage);
});
}
@ -138,8 +138,8 @@ function testIncomingMessage() {
return new Promise(function(aResolve, aReject) {
const incomingMessage = "test incoming message";
session.addEventListener('message', function messageHandler(aEvent) {
session.removeEventListener('message', messageHandler);
connection.addEventListener('message', function messageHandler(aEvent) {
connection.removeEventListener('message', messageHandler);
is(aEvent.data, incomingMessage, "An incoming message should be received.");
aResolve();
});
@ -148,20 +148,20 @@ function testIncomingMessage() {
});
}
function testTerminateSession() {
function testTerminateConnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
info("The data transport is closed. " + aReason);
});
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "terminated", "Session should be terminated.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "terminated", "Connection should be terminated.");
aResolve();
};
session.terminate();
connection.terminate();
});
}
@ -179,10 +179,10 @@ function runTests() {
ok(window.PresentationRequest, "PresentationRequest should be available.");
testSetup().
then(testStartSession).
then(testStartConnection).
then(testSend).
then(testIncomingMessage).
then(testTerminateSession).
then(testTerminateConnection).
then(teardown);
}

View File

@ -15,7 +15,7 @@
'use strict';
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
var session;
var connection;
function testSetup() {
return new Promise(function(aResolve, aReject) {
@ -40,7 +40,7 @@ function testSetup() {
});
}
function testStartSession() {
function testStartConnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -83,12 +83,12 @@ function testStartSession() {
ok(!navigator.presentation.receiver, "Sender shouldn't get a presentation receiver instance.");
navigator.presentation.defaultRequest.onsessionconnect = function(aEvent) {
navigator.presentation.defaultRequest.onsessionconnect = null;
session = aEvent.session;
ok(session, "|sessionconnect| event is fired with a session.");
ok(session.id, "Session ID should be set.");
is(session.state, "connected", "Session state at sender side should be connected by default.");
navigator.presentation.defaultRequest.onconnectionavailable = function(aEvent) {
navigator.presentation.defaultRequest.onconnectionavailable = null;
connection = aEvent.connection;
ok(connection, "|connectionavailable| event is fired with a connection.");
ok(connection.id, "Connection ID should be set.");
is(connection.state, "connected", "Connection state at sender side should be connected by default.");
aResolve();
};
@ -97,20 +97,20 @@ function testStartSession() {
});
}
function testTerminateSession() {
function testTerminateConnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
info("The data transport is closed. " + aReason);
});
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "terminated", "Session should be terminated.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "terminated", "Connection should be terminated.");
aResolve();
};
session.terminate();
connection.terminate();
});
}
@ -129,8 +129,8 @@ function runTests() {
ok(navigator.presentation, "navigator.presentation should be available.");
testSetup().
then(testStartSession).
then(testTerminateSession).
then(testStartConnection).
then(testTerminateConnection).
then(teardown);
}

View File

@ -4,19 +4,19 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for session disconnection of B2G Presentation API at sender side</title>
<title>Test for disconnection of B2G Presentation API at sender side</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for session disconnection of B2G Presentation API at sender side</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for disconnection of B2G Presentation API at sender side</a>
<script type="application/javascript;version=1.8">
'use strict';
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
var request;
var session;
var connection;
function testSetup() {
return new Promise(function(aResolve, aReject) {
@ -41,7 +41,7 @@ function testSetup() {
});
}
function testStartSession() {
function testStartConnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -88,15 +88,15 @@ function testStartSession() {
});
request.start().then(
function(aSession) {
session = aSession;
ok(session, "Session should be availlable.");
ok(session.id, "Session ID should be set.");
is(session.state, "connected", "Session state at sender side should be connected by default.");
function(aConnection) {
connection = aConnection;
ok(connection, "Connection should be available.");
ok(connection.id, "Connection ID should be set.");
is(connection.state, "connected", "Connection state at sender side should be connected by default.");
aResolve();
},
function(aError) {
ok(false, "Error occurred when starting session: " + aError);
ok(false, "Error occurred when establishing a connection: " + aError);
teardown();
aReject();
}
@ -104,16 +104,16 @@ function testStartSession() {
});
}
function testSessionDisconnection() {
function testDisconnection() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) {
gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler);
info("The data transport is closed. " + aReason);
});
session.onstatechange = function() {
session.onstatechange = null;
is(session.state, "closed", "Session should be closed.");
connection.onstatechange = function() {
connection.onstatechange = null;
is(connection.state, "closed", "Connection should be closed.");
aResolve();
};
@ -135,8 +135,8 @@ function runTests() {
ok(window.PresentationRequest, "PresentationRequest should be available.");
testSetup().
then(testStartSession).
then(testSessionDisconnection).
then(testStartConnection).
then(testDisconnection).
then(teardown);
}

View File

@ -4,12 +4,12 @@
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<head>
<meta charset="utf-8">
<title>Test for startSession errors of B2G Presentation API at sender side</title>
<title>Test for connection establishing errors of B2G Presentation API at sender side</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for startSession errors of B2G Presentation API at sender side</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for connection establishing errors of B2G Presentation API at sender side</a>
<script type="application/javascript;version=1.8">
'use strict';
@ -51,7 +51,7 @@ function testCreateRequestWithEmptyURL() {
});
}
function testStartSessionCancelPrompt() {
function testStartConnectionCancelPrompt() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -60,7 +60,7 @@ function testStartSessionCancelPrompt() {
});
request.start().then(
function(aSession) {
function(aConnection) {
ok(false, "|start| shouldn't succeed in this case.");
aReject();
},
@ -72,7 +72,7 @@ function testStartSessionCancelPrompt() {
});
}
function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportInit() {
function testStartConnectionUnexpectedControlChannelCloseBeforeDataTransportInit() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -103,19 +103,19 @@ function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportInit()
});
request.start().then(
function(aSession) {
function(aConnection) {
ok(false, "|start| shouldn't succeed in this case.");
aReject();
},
function(aError) {
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during starting session.");
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during establishing a connection.");
aResolve();
}
);
});
}
function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportReady() {
function testStartConnectionUnexpectedControlChannelCloseBeforeDataTransportReady() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -157,19 +157,19 @@ function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportReady()
});
request.start().then(
function(aSession) {
function(aConnection) {
ok(false, "|start| shouldn't succeed in this case.");
aReject();
},
function(aError) {
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during starting session.");
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during establishing a connection.");
aResolve();
}
);
});
}
function testStartSessionUnexpectedDataTransportClose() {
function testStartConnectionUnexpectedDataTransportClose() {
return new Promise(function(aResolve, aReject) {
gScript.addMessageListener('device-prompt', function devicePromptHandler() {
gScript.removeMessageListener('device-prompt', devicePromptHandler);
@ -211,12 +211,12 @@ function testStartSessionUnexpectedDataTransportClose() {
});
request.start().then(
function(aSession) {
function(aConnection) {
ok(false, "|start| shouldn't succeed in this case.");
aReject();
},
function(aError) {
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during starting session.");
is(aError.name, "OperationError", "OperationError is expected when a connection error happens during establishing a connection.");
aResolve();
}
);
@ -238,10 +238,10 @@ function runTests() {
testCreateRequestWithEmptyURL().
then(setup).
then(testStartSessionCancelPrompt).
then(testStartSessionUnexpectedControlChannelCloseBeforeDataTransportInit).
then(testStartSessionUnexpectedControlChannelCloseBeforeDataTransportReady).
then(testStartSessionUnexpectedDataTransportClose).
then(testStartConnectionCancelPrompt).
then(testStartConnectionUnexpectedControlChannelCloseBeforeDataTransportInit).
then(testStartConnectionUnexpectedControlChannelCloseBeforeDataTransportReady).
then(testStartConnectionUnexpectedDataTransportClose).
then(teardown);
}