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

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

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

Powered by Google App Engine
This is Rietveld 408576698