| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="../resources/gc.js"></script> |
| <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| <script src="file:///gen/third_party/WebKit/public/platform/modules/presentation/presentation.mojom.js"></script> |
| <script src="resources/presentation-service-mock.js"></script> |
| <script> |
| |
| var presentationUrl = "http://example.com"; |
| var presentationUrls = [presentationUrl, "cast://google.com/app_id=deadbeef"]; |
| |
| var expectedException = new DOMException('PresentationRequest::start() requires user gesture.', 'InvalidAccessError'); |
| |
| promise_test(function(t) { |
| var request = new PresentationRequest(presentationUrl); |
| return promise_rejects(t, expectedException, request.start()); |
| }, "Test that the PresentationRequest.start() with one URL requires user gesture.") |
| |
| promise_test(function(t) { |
| var request = new PresentationRequest(presentationUrls); |
| return promise_rejects(t, expectedException, request.start()); |
| }, "Test that the PresentationRequest.start() with multiple URLs requires user gesture.") |
| |
| var testGarbageCollection = function(requestArgument) { |
| navigator.presentation.defaultRequest = new PresentationRequest(requestArgument); |
| navigator.presentation.defaultRequest.onconnectionavailable = function() { }; |
| gc(); |
| assert_not_equals(navigator.presentation.defaultRequest.onconnectionavailable, undefined); |
| }; |
| |
| test(function() { |
| testGarbageCollection(presentationUrl); |
| }, "Test that navigator.presentation.defaultRequest.onconnectionavailable with one URL isn't reset after gc()."); |
| |
| test(function() { |
| testGarbageCollection(presentationUrls); |
| }, "Test that navigator.presentation.defaultRequest.onconnectionavailable with multiple URLs isn't reset after gc()."); |
| |
| test(function() { |
| var request = new PresentationRequest("http://example.com"); |
| var promise_1 = request.getAvailability(); |
| var promise_2 = request.getAvailability(); |
| assert_true(promise_1 === promise_2); |
| }, "Test that the PresentationRequest.getAvailability() returns same promise object."); |
| |
| </script> |
| </body> |
| </html> |