diff options
Diffstat (limited to 'testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html')
-rw-r--r-- | testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html new file mode 100644 index 000000000..de6ca2b74 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html @@ -0,0 +1,83 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Presentation API - monitor screen availability tests for Controlling User Agent</title> +<link rel="author" title="Marius Wessel" href="http://www.fokus.fraunhofer.de"> +<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> + // --------------------------------- + // Helper Function + // --------------------------------- + var createRequestObject = function () { + var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)), + presUrl = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=" + validUnixDate, + request = new PresentationRequest(presUrl); + return request; + } + + // --------------------------------- + // Screen Availability Tests - begin + // --------------------------------- + + // Instance of Promise Test + test(function () { + var request = createRequestObject(); + assert_true(request.getAvailability() instanceof Promise); + }, 'The request is an Promise.') + + // Instance of PresentationRequest Test + test(function () { + var request = createRequestObject(); + assert_true(request instanceof PresentationRequest); + }, 'The request is an instance of PresentationRequest.') + + // Instance of PresentationAvailability Test + promise_test(function () { + var request = createRequestObject(); + + return request.getAvailability() + .then(function (availability) { + assert_true(availability instanceof PresentationAvailability); + }); + }, "The promise is an instance of PresentationAvailability"); + + // Availability.value is set Test + promise_test(function () { + var request = createRequestObject(); + + return request.getAvailability() + .then(function (availability) { + assert_true(typeof availability.value == 'boolean'); + }); + }, "The availability has an boolean value."); + + + // Best Case Scenario Test + // ----------------------- + promise_test(function () { + var request = createRequestObject(); + + return request.getAvailability() + .then(function (availability) { + assert_true(availability.value); + }); + }, "There is an availability."); + + + // Invalid Presentation URL Test + promise_test(function () { + var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)), + invalidPresUrl = "../receiving-ua/idlharness.html#__castAppId__=3445E44B/__castClientId__=" + validUnixDate, + request = new PresentationRequest(invalidPresUrl); + + return request.getAvailability() + .then(function (availability) { + assert_false(availability.value); + }); + }, "There is no availability for an invalid presentation URL."); + // ------------------------------- + // Screen Availability Tests - end + // ------------------------------- +</script> |