defaultRequest_success-manual.https.html (2908B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>[Optional] Starting a presentation from the browser using a default presentation request.</title> 4 <link rel="author" title="Marius Wessel" href="http://www.fokus.fraunhofer.de"> 5 <link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs"> 6 <link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentation-defaultrequest"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="common.js"></script> 10 11 <p> 12 Click the button or the menu item for presentation on your browser (for example, "Cast"), <br> 13 to start the manual test, and select a presentation display when prompted to do so.<br> 14 The test passes if a "PASS" result appears. 15 </p> 16 <p id="notice"> 17 If your browser does not support <code>defaultRequest</code>, please click this button: <button id="notsupported">Not Supported</button> 18 </p> 19 20 <script> 21 // disable the timeout function for the tests 22 // and call 'done()' when the tests cases are finished. 23 setup({explicit_timeout: true}); 24 25 // ----------- 26 // DOM Element 27 // ----------- 28 var button = document.getElementById('notsupported'), 29 notice = document.getElementById('notice'); 30 31 // ------------------------------ 32 // Start New Presentation with 33 // 'default request' Test - BEGIN 34 // ------------------------------ 35 async_test(function(t) { 36 // clean up the presentation and the instruction notice when the test ends 37 var connection; 38 t.add_cleanup(function() { 39 notice.parentNode.removeChild(notice); 40 if(connection) 41 connection.terminate(); 42 }); 43 // set an event handler to make the test fail when the button is clicked 44 button.onclick = t.step_func_done(function() { 45 assert_unreached('This browser does not support defaultRequest.'); 46 }); 47 // set up a default presentation request 48 var request = new PresentationRequest(presentationUrls); 49 navigator.presentation.defaultRequest = request; 50 request.onconnectionavailable = t.step_func_done(function (evt) { 51 connection = evt.connection; 52 // check the presentation connection and its attributes 53 assert_equals(connection.state, 'connecting', 'The initial state of the presentation connection is "connecting".'); 54 assert_true(!!connection.id, 'The connection ID is set.'); 55 assert_equals(typeof connection.id, 'string', 'The connection ID is a string.'); 56 assert_true(connection instanceof PresentationConnection, 'The connection is an instance of PresentationConnection.'); 57 }); 58 }); 59 // ---------------------------- 60 // Start New Presentation with 61 // 'default request' Test - END 62 // ---------------------------- 63 </script>