summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_notfound_error-manual.https.html
blob: f92ab80f730f59a8e0cd2cb578a87239b99a7347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<meta charset="utf-8">
<title>Calling "reconnect" with a wrong presentation ID fails with a NotFoundError exception</title>
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de">
<link rel="author" title="Louay Bassbouss" href="http://www.fokus.fraunhofer.de">
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-reconnect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>

<p>Click the button below to start the manual test. Select a presentation device after the selection dialog is prompted.
  The test assumes that at least one presentation device is available. The test passes if a "PASS" result appears.</p>
<button id="startBtn">Start Test</button>

<script>
  promise_test(async t => {
    const startBtn = document.getElementById('startBtn');
    const wrongPresentationId = "wrongPresentationId";
    const request1 = new PresentationRequest(presentationUrls);
    const request2 = new PresentationRequest('https://www.w3.org');
    let connection1, eventWatcher1;

    t.add_cleanup(() => {
      if (connection1) {
        connection1.onconnect = () => { connection1.terminate(); }
        if (connection1.state === 'closed')
          request1.reconnect(connection1.id);
        else
          connection1.terminate();
      }
    });

    await promise_rejects_dom(t, 'NotFoundError', request1.reconnect(wrongPresentationId),
      'Reconnecting with an unknown presentation ID fails with a NotFoundError exception.');

    setup({explicit_timeout: true});
    const clickWatcher = new EventWatcher(t, startBtn, 'click');
    await clickWatcher.wait_for('click');
    connection1 = await request1.start();

    t.step_timeout(() => {
      t.force_timeout();
      t.done();
    }, 5000);

    startBtn.disabled = true;
    eventWatcher1 = new EventWatcher(t, connection1, ['connect', 'close', 'terminate']);
    await eventWatcher1.wait_for('connect');
    connection1.close();
    await eventWatcher1.wait_for('close');

    await promise_rejects_dom(t, 'NotFoundError', request2.reconnect(connection1.id),
      'Reconnecting with a presentation ID on a presentation request with a different URL fails with a NotFoundError exception.');

    await request1.reconnect(connection1.id);
    await eventWatcher1.wait_for('connect');
    connection1.terminate();
    await eventWatcher1.wait_for('terminate');
  });
</script>