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

Side by Side Diff: third_party/WebKit/LayoutTests/presentation/resources/embedded-smoke-tests.html

Issue 2655073007: Revert of [Presentation API] Allow PresentationConnection state change to "Connecting" (Closed)
Patch Set: Created 3 years, 10 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> 4 <script>
5 5
6 const FAKE_SESSION_ID = 'fake'; 6 var FAKE_SESSION_ID = 'fake';
7 let gCurrentConnection = null; 7 var gCurrentConnection = null;
8 8
9 // Returns the test runner used to run this test.. 9 // Returns the test runner used to run this test..
10 // Current possible values are 'blink' and 'manual'. 10 // Current possible values are 'blink' and 'manual'.
11 function getTestRunner() { 11 function getTestRunner() {
12 if ('internals' in window) 12 if ('internals' in window)
13 return 'blink'; 13 return 'blink';
14 return 'manual'; 14 return 'manual';
15 } 15 }
16 16
17 // Returns a promise that is resolved when the user press a 'click me' button or 17 // Returns a promise that is resolved when the user press a 'click me' button or
18 // is automatically resolved if a supported test runner is detected. 18 // is automatically resolved if a supported test runner is detected.
19 function getUserGesture() { 19 function getUserGesture() {
20 return new Promise(function (resolve) { 20 return new Promise(function (resolve) {
21 switch (getTestRunner()) { 21 switch (getTestRunner()) {
22 case 'blink': 22 case 'blink':
23 internals.settings.setPresentationRequiresUserGesture(false); 23 internals.settings.setPresentationRequiresUserGesture(false);
24 setTimeout(resolve); 24 setTimeout(resolve);
25 break; 25 break;
26 case 'manual': 26 case 'manual':
27 const button = document.createElement('button'); 27 var button = document.createElement('button');
28 button.textContent = 'click me'; 28 button.textContent = 'click me';
29 button.onclick = function() { 29 button.onclick = function() {
30 document.body.removeChild(button); 30 document.body.removeChild(button);
31 resolve(); 31 resolve();
32 }; 32 };
33 document.body.appendChild(button); 33 document.body.appendChild(button);
34 break; 34 break;
35 default: 35 default:
36 parent.window.postMessage({ error: 'unknown test runner' }, '*'); 36 parent.window.postMessage({ error: 'unknown test runner' }, '*');
37 } 37 }
38 }); 38 });
39 } 39 }
40 40
41 const results = []; 41 var results = [];
42 42
43 // start() 43 // start()
44 getUserGesture().then(function() { 44 getUserGesture().then(function() {
45 if (getTestRunner() == 'manual') { 45 if (getTestRunner() == 'manual') {
46 const description = document.createElement('div'); 46 var description = document.createElement('div');
47 description.id = 'description'; 47 description.id = 'description';
48 description.textContent = 'Pick a device if asked for it'; 48 description.textContent = 'Pick a device if asked for it';
49 document.body.appendChild(description); 49 document.body.appendChild(description);
50 } 50 }
51 51
52 const p = new PresentationRequest('https://example.com'); 52 var p = new PresentationRequest('https://example.com');
53 return p.start().then(function(connection) { 53 return p.start().then(function(connection) {
54 gCurrentConnection = connection; 54 gCurrentConnection = connection;
55 results.push({ test: 'start', status: 'success' }) 55 results.push({ test: 'start', status: 'success' })
56 }, function(e) { 56 }, function(e) {
57 results.push({ test: 'start', status: 'failure', name: e.name }); 57 results.push({ test: 'start', status: 'failure', name: e.name });
58 }).then(function() { 58 }).then(function() {
59 if (getTestRunner() == 'manual') 59 if (getTestRunner() == 'manual')
60 document.body.removeChild(document.querySelector('#description')); 60 document.body.removeChild(document.querySelector('#description'));
61 }); 61 });
62 }).then(function() { 62 }).then(function() {
63 // reconnect() 63 // reconnect()
64 return getUserGesture().then(function() { 64 return getUserGesture().then(function() {
65 const p = new PresentationRequest('https://example.com'); 65 var p = new PresentationRequest('https://example.com');
66 return p.reconnect(gCurrentConnection ? 66 return p.reconnect(gCurrentConnection ? gCurrentConnection.id : FAKE_SESSION _ID).then(function() {
67 gCurrentConnection.id :
68 FAKE_SESSION_ID).then(function() {
69 results.push({ test: 'reconnect', status: 'success' }) 67 results.push({ test: 'reconnect', status: 'success' })
70 }, function(e) { 68 }, function(e) {
71 results.push({ test: 'reconnect', status: 'failure', name: e.name }); 69 results.push({ test: 'reconnect', status: 'failure', name: e.name });
72 }); 70 });
73 }); 71 });
74 }).then(function() { 72 }).then(function() {
75 // getAvailability() 73 // getAvailability()
76 return getUserGesture().then(function() { 74 return getUserGesture().then(function() {
77 const p = new PresentationRequest('https://example.com'); 75 var p = new PresentationRequest('https://example.com');
78 return p.getAvailability().then(function() { 76 return p.getAvailability().then(function() {
79 results.push({ test: 'getAvailability', status: 'success' }) 77 results.push({ test: 'getAvailability', status: 'success' })
80 }, function(e) { 78 }, function(e) {
81 results.push({ test: 'getAvailability', status: 'failure', name: e.name }) ; 79 results.push({ test: 'getAvailability', status: 'failure', name: e.name }) ;
82 }); 80 });
83 }); 81 });
84 }).then(function() { 82 }).then(function() {
85 parent.window.postMessage(results, '*'); 83 parent.window.postMessage(results, '*');
86 }); 84 });
87 85
88 </script> 86 </script>
89 </body> 87 </body>
90 </html> 88 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698