From b4479e705ddbfcc69d87c43c652dd7dc9c0bc05c Mon Sep 17 00:00:00 2001 From: Sean Lin Date: Thu, 8 Oct 2015 10:54:25 +0800 Subject: [PATCH] Bug 1205219 - [Presentation WebAPI] Support terminate semantics. Part 2 - Tests. r=smaug --- .../mochitest/file_presentation_receiver.html | 10 +++++----- .../mochitest/file_presentation_receiver_oop.html | 10 +++++----- ...presentation_receiver_start_session_error.html | 4 ++-- .../tests/mochitest/test_presentation_sender.html | 6 +++--- .../test_presentation_sender_default_request.html | 6 +++--- .../test_presentation_sender_disconnect.html | 15 +-------------- 6 files changed, 19 insertions(+), 32 deletions(-) diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver.html b/dom/presentation/tests/mochitest/file_presentation_receiver.html index 7f5e868a4301..fa1a71848a9f 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver.html @@ -42,12 +42,12 @@ function testSessionAvailable() { session = aSession; ok(session.id, "Session ID should be set: " + session.id); - is(session.state, "disconnected", "Session state at receiver side should be disconnected by default."); + is(session.state, "closed", "Session state at receiver side should be closed by default."); aResolve(); }, function(aError) { ok(false, "Error occurred when getting the session: " + aError); - teardown(); + finish(); aReject(); } ); @@ -81,7 +81,7 @@ function testIncomingMessage() { }); } -function testCloseSession() { +function testTerminateSession() { return new Promise(function(aResolve, aReject) { session.onstatechange = function() { session.onstatechange = null; @@ -89,14 +89,14 @@ function testCloseSession() { aResolve(); }; - session.close(); + session.terminate(); }); } testSessionAvailable(). then(testSessionReady). then(testIncomingMessage). -then(testCloseSession). +then(testTerminateSession). then(finish); diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver_oop.html b/dom/presentation/tests/mochitest/file_presentation_receiver_oop.html index 47a9977f8551..52a6e768826a 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver_oop.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver_oop.html @@ -42,12 +42,12 @@ function testSessionAvailable() { session = aSession; ok(session.id, "Session ID should be set: " + session.id); - is(session.state, "disconnected", "Session state at receiver side should be disconnected by default."); + is(session.state, "closed", "Session state at receiver side should be closed by default."); aResolve(); }, function(aError) { ok(false, "Error occurred when getting the session: " + aError); - teardown(); + finish(); aReject(); } ); @@ -81,7 +81,7 @@ function testIncomingMessage() { }); } -function testCloseSession() { +function testTerminateSession() { return new Promise(function(aResolve, aReject) { session.onstatechange = function() { session.onstatechange = null; @@ -89,14 +89,14 @@ function testCloseSession() { aResolve(); }; - session.close(); + session.terminate(); }); } testSessionAvailable(). then(testSessionReady). then(testIncomingMessage). -then(testCloseSession). +then(testTerminateSession). then(finish); diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver_start_session_error.html b/dom/presentation/tests/mochitest/file_presentation_receiver_start_session_error.html index ead1e5a3c22d..ad185218d676 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver_start_session_error.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver_start_session_error.html @@ -42,12 +42,12 @@ function testSessionAvailable() { session = aSession; ok(session.id, "Session ID should be set: " + session.id); - is(session.state, "disconnected", "Session state at receiver side should be disconnected by default."); + is(session.state, "closed", "Session state at receiver side should be closed by default."); aResolve(); }, function(aError) { ok(false, "Error occurred when getting the session: " + aError); - teardown(); + finish(); aReject(); } ); diff --git a/dom/presentation/tests/mochitest/test_presentation_sender.html b/dom/presentation/tests/mochitest/test_presentation_sender.html index cd20395096c7..5202ceb50fd7 100644 --- a/dom/presentation/tests/mochitest/test_presentation_sender.html +++ b/dom/presentation/tests/mochitest/test_presentation_sender.html @@ -148,7 +148,7 @@ function testIncomingMessage() { }); } -function testCloseSession() { +function testTerminateSession() { return new Promise(function(aResolve, aReject) { gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) { gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler); @@ -161,7 +161,7 @@ function testCloseSession() { aResolve(); }; - session.close(); + session.terminate(); }); } @@ -182,7 +182,7 @@ function runTests() { then(testStartSession). then(testSend). then(testIncomingMessage). - then(testCloseSession). + then(testTerminateSession). then(teardown); } diff --git a/dom/presentation/tests/mochitest/test_presentation_sender_default_request.html b/dom/presentation/tests/mochitest/test_presentation_sender_default_request.html index 55921070ab95..26a35ec25cf8 100644 --- a/dom/presentation/tests/mochitest/test_presentation_sender_default_request.html +++ b/dom/presentation/tests/mochitest/test_presentation_sender_default_request.html @@ -97,7 +97,7 @@ function testStartSession() { }); } -function testCloseSession() { +function testTerminateSession() { return new Promise(function(aResolve, aReject) { gScript.addMessageListener('data-transport-closed', function dataTransportClosedHandler(aReason) { gScript.removeMessageListener('data-transport-closed', dataTransportClosedHandler); @@ -110,7 +110,7 @@ function testCloseSession() { aResolve(); }; - session.close(); + session.terminate(); }); } @@ -130,7 +130,7 @@ function runTests() { testSetup(). then(testStartSession). - then(testCloseSession). + then(testTerminateSession). then(teardown); } diff --git a/dom/presentation/tests/mochitest/test_presentation_sender_disconnect.html b/dom/presentation/tests/mochitest/test_presentation_sender_disconnect.html index 5f20bc9146ff..16453906ce70 100644 --- a/dom/presentation/tests/mochitest/test_presentation_sender_disconnect.html +++ b/dom/presentation/tests/mochitest/test_presentation_sender_disconnect.html @@ -113,7 +113,7 @@ function testSessionDisconnection() { session.onstatechange = function() { session.onstatechange = null; - is(session.state, "disconnected", "Session should be disconnected."); + is(session.state, "closed", "Session should be closed."); aResolve(); }; @@ -121,18 +121,6 @@ function testSessionDisconnection() { }); } -function testCloseSession() { - return new Promise(function(aResolve, aReject) { - session.onstatechange = function() { - session.onstatechange = null; - is(session.state, "terminated", "Session should be terminated."); - aResolve(); - }; - - session.close(); - }); -} - function teardown() { gScript.addMessageListener('teardown-complete', function teardownCompleteHandler() { gScript.removeMessageListener('teardown-complete', teardownCompleteHandler); @@ -149,7 +137,6 @@ function runTests() { testSetup(). then(testStartSession). then(testSessionDisconnection). - then(testCloseSession). then(teardown); }