OLD | NEW |
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/gc.js"></script> | 6 <script src="../resources/gc.js"></script> |
7 <script> | 7 <script> |
8 | 8 |
9 async_test(function(t) { | 9 var presentationUrl = "http://example.com"; |
10 var request = new PresentationRequest("http://example.com"); | 10 var presentationUrls = [presentationUrl, "cast://google.com/app_id=deadbeef"]; |
| 11 |
| 12 var testUserGesture = function(t, requestArgument) { |
| 13 var request = new PresentationRequest(requestArgument); |
11 request.start().catch(t.step_func(function(e) { | 14 request.start().catch(t.step_func(function(e) { |
12 assert_true(e instanceof DOMException); | 15 assert_true(e instanceof DOMException); |
13 assert_equals(e.name, "InvalidAccessError"); | 16 assert_equals(e.name, "InvalidAccessError"); |
14 assert_equals(e.message, "PresentationRequest::start() requires user gesture
."); | 17 assert_equals(e.message, "PresentationRequest::start() requires user gesture
."); |
15 t.done(); | 18 t.done(); |
16 })); | 19 })); |
17 }, "Test that the PresentationRequest.start() requires user gesture.") | 20 }; |
18 | 21 |
19 test(function() { | 22 async_test(function(t) { |
20 navigator.presentation.defaultRequest = new PresentationRequest("http://exampl
e.com"); | 23 testUserGesture(t, presentationUrl); |
| 24 }, "Test that the PresentationRequest.start() with one URL requires user gesture
.") |
| 25 |
| 26 async_test(function(t) { |
| 27 testUserGesture(t, presentationUrls); |
| 28 }, "Test that the PresentationRequest.start() with multiple URLs requires user g
esture.") |
| 29 |
| 30 var testGarbageCollection = function(requestArgument) { |
| 31 navigator.presentation.defaultRequest = new PresentationRequest(requestArgumen
t); |
21 navigator.presentation.defaultRequest.onconnectionavailable = function() { }; | 32 navigator.presentation.defaultRequest.onconnectionavailable = function() { }; |
22 gc(); | 33 gc(); |
23 assert_not_equals(navigator.presentation.defaultRequest.onconnectionavailable,
undefined); | 34 assert_not_equals(navigator.presentation.defaultRequest.onconnectionavailable,
undefined); |
24 }, "Test that navigator.presentation.defaultRequest.onconnectionavailable isn't
reset after gc()"); | 35 }; |
| 36 |
| 37 test(function() { |
| 38 testGarbageCollection(presentationUrl); |
| 39 }, "Test that navigator.presentation.defaultRequest.onconnectionavailable with o
ne URL isn't reset after gc()."); |
| 40 |
| 41 test(function() { |
| 42 testGarbageCollection(presentationUrls); |
| 43 }, "Test that navigator.presentation.defaultRequest.onconnectionavailable with m
ultiple URLs isn't reset after gc()."); |
25 | 44 |
26 </script> | 45 </script> |
27 </body> | 46 </body> |
28 </html> | 47 </html> |
OLD | NEW |