[Presentation API] Fix getAvailability tests.

1. Replace PresentationBrowserTest, which was broken and failing, with an
equivalent layout test.

2. Fix timeout in getAvailabilty.https.html WPT.  It was waiting for an
availability state change that may never come (because displays are already
available, or will never become available).

3. Fixing the timeout in the WPT revealed a spec issue filed as
crbug.com/958104.  Updated TestExpectations to note this.

Bug: 626703,653131,940503,958104
Change-Id: I51bd439f42d08f0b9d00d4c9be7a35eaee681fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1590444
Commit-Queue: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#655754}
diff --git a/presentation-api/controlling-ua/getAvailability.https.html b/presentation-api/controlling-ua/getAvailability.https.html
index b6d8736..71b19e6 100644
--- a/presentation-api/controlling-ua/getAvailability.https.html
+++ b/presentation-api/controlling-ua/getAvailability.https.html
@@ -17,6 +17,10 @@
     // Presentation Availability Tests - begin
     // ---------------------------------------
 
+    const catchNotSupported = err => {
+      assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.')
+    };
+
     promise_test(t => {
         let availability;
 
@@ -24,39 +28,27 @@
         assert_true(request instanceof PresentationRequest, 'The request is an instance of PresentationRequest.');
 
         const promise = request.getAvailability();
-        assert_equals(promise, request.getAvailability(), 'If the PresentationRequest object has an unsettled Promise, getAvailability returns that Promise.');
-
-        function catchNotSupported(err) {
-            assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.')
-        }
+        assert_true(promise instanceof Promise, 'PresentationRequest.getAvailability() returns a Promise.');
+        const samePromise = request.getAvailability();
+        assert_true(samePromise instanceof Promise, 'PresentationRequest.getAvailabilty() returns a Promise.');
+        assert_equals(promise, samePromise, 'If the PresentationRequest object has an unsettled Promise, getAvailability returns that Promise.');
 
         return promise.then(a => {
-            availability = a;
+          availability = a;
+          assert_true(availability instanceof PresentationAvailability, 'The promise is resolved with an instance of PresentationAvailability.');
+          assert_equals(typeof availability.value, 'boolean', 'The availability has an boolean value.');
 
-            assert_true(availability instanceof PresentationAvailability, 'The promise is resolved with an instance of PresentationAvailability.');
-            assert_equals(typeof availability.value, 'boolean', 'The availability has an boolean value.');
+          const request2 = new PresentationRequest('https://example.com');
+          return request2.getAvailability();
+        }).then(a => {
+          assert_not_equals(availability, a, 'A presentation availability object is newly created if the presentation request has a newly added presentation URLs.');
 
-            // The value of the presentation availability object is set to false, when the object is newly created.
-            const waitForChange = () => {
-                const eventWatcher = new EventWatcher(t, availability, 'change');
-                return eventWatcher.wait_for('change');
-            };
+          const newPromise = request.getAvailability();
+          assert_not_equals(promise, newPromise, 'If the Promise from a previous call to getAvailability has already been settled, getAvailability returns a new Promise.');
 
-            return (availability.value ? Promise.resolve() : waitForChange()).then(() => {
-                assert_true(availability.value, 'The availability value is true when any presentation display is available.');
-
-                const request2 = new PresentationRequest('https://example.com');
-                return request2.getAvailability();
-            }).then(a => {
-                assert_not_equals(availability, a, 'A presentation availability object is newly created if the presentation request has a newly added presentation URLs.');
-
-                const newPromise = request.getAvailability();
-                assert_not_equals(promise, newPromise, 'If the Promise from a previous call to getAvailability has already been settled, getAvailability returns a new Promise.');
-
-                return newPromise.then(newAvailability => {
-                    assert_equals(availability, newAvailability, 'Promises from a PresentationRequest\'s getAvailability are resolved with the same PresentationAvailability object.');
-                }, catchNotSupported);
-            }, catchNotSupported);
+          return newPromise.then(newAvailability => {
+            assert_equals(availability, newAvailability, 'Promises from a PresentationRequest\'s getAvailability are resolved with the same PresentationAvailability object.');
+          }, catchNotSupported);
         }, catchNotSupported);
     });
 </script>