Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: third_party/WebKit/LayoutTests/presentation/presentation-controller-close-connection.html

Issue 2874483002: [Presentation API] Remove closed connections from PresentationConnectionList (Closed)
Patch Set: rebase with master Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../resources/testharness.js"></script> 4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script> 5 <script src="../resources/testharnessreport.js"></script>
6 <script src="../resources/mojo-helpers.js"></script> 6 <script src="../resources/mojo-helpers.js"></script>
7 <script src="resources/presentation-service-mock.js"></script> 7 <script src="resources/presentation-service-mock.js"></script>
8 <button>click me</button> 8 <button>click me</button>
9 <script> 9 <script>
10 10
11 var button = document.querySelector('button'); 11 var button = document.querySelector('button');
12 var receiverConnectionClosed = false; 12 var receiverConnectionClosed = false;
13 var connection = null; 13 var connection = null;
14 14
15 async_test(t => { 15 async_test(t => {
16 presentationServiceMock.then(service => { 16 presentationServiceMock.then(service => {
17 // This is receiving the user gesture and runs the callback. 17 // This is receiving the user gesture and runs the callback.
18 waitForClick(() => { 18 waitForClick(() => {
19 new PresentationRequest("https://example.com/").start().then( 19 new PresentationRequest("https://example.com/").start().then(
20 theConnection => { 20 theConnection => {
21 connection = theConnection; 21 connection = theConnection;
22 connection.onclose = (closeEvent) => { 22 connection.onclose = (closeEvent) => {
23 assert_equals(closeEvent.reason, "closed"); 23 assert_equals(closeEvent.reason, "closed");
24 assert_equals(closeEvent.message, ""); 24 assert_equals(closeEvent.message, "");
25 assert_equals(connection.state, "closed"); 25 assert_equals(connection.state, "closed");
26 assert_true(receiverConnectionClosed);
27 t.done();
28 }; 26 };
29 connection.onconnect = () => { 27 connection.onconnect = () => {
30 // Open a receiver page and pass controller connection's 28 // Open a receiver page and pass controller connection's
31 // controllerConnectionPtr and receiverConnectionRequest to it. 29 // controllerConnectionPtr and receiverConnectionRequest to it.
32 w = window.open("resources/presentation-receiver-close-connection.ht ml"); 30 w = window.open("resources/presentation-receiver-close-connection.ht ml");
33 w.controllerConnectionPtr = service.getControllerConnectionPtr(); 31 w.controllerConnectionPtr = service.getControllerConnectionPtr();
34 w.receiverConnectionRequest = service.getReceiverConnectionRequest() ; 32 w.receiverConnectionRequest = service.getReceiverConnectionRequest() ;
35 w.shouldCallClose = false; 33 w.shouldCallClose = false;
36 }; 34 };
37 }); 35 });
38 }, button); 36 }, button);
39 }); 37 });
40 38
41 window.addEventListener("message", t.step_func(e => { 39 window.addEventListener("message", t.step_func(e => {
42 if (e.data == "receiver connection closed") { 40 if (e.data == "receiver connection closed") {
43 receiverConnectionClosed = true; 41 receiverConnectionClosed = true;
42 t.done();
44 } else if (e.data == "receiver connection ready") { 43 } else if (e.data == "receiver connection ready") {
45 assert_not_equals(connection, null); 44 assert_not_equals(connection, null);
46 connection.close(); 45 connection.close();
47 } 46 }
48 })); 47 }));
49 }, "controller connection.close() should fire both controller's and receiver's o nclose event handler"); 48 }, "controller connection.close() should fire both controller's and receiver's o nclose event handler");
50 49
51 </script> 50 </script>
52 </body> 51 </body>
53 </html> 52 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698