Revision d74cfc00f15092d6491b01b27616520d5beb5c13 authored by Domenic Denicola on 02 April 2018, 18:58:09 UTC, committed by Domenic Denicola on 02 April 2018, 18:58:09 UTC
See https://github.com/w3c/web-platform-tests/pull/9869#issuecomment-378002725.
1 parent af485dc
Raw File
idlharness_receiving-ua.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API IDL tests for Receiving User Agent</title>
<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/#dfn-receiving-user-agent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<script src="../common.js"></script>
<script src="stash.js"></script>

<script id="untested_idl" type="text/plain">
interface Navigator {
};
interface EventTarget {
};
interface EventHandler {
};
interface Event {
};
dictionary EventInit {
};
</script>

<script id='idl' type="text/plain">
partial interface Navigator {
    [SecureContext,
     SameObject]
    readonly attribute Presentation presentation;
};

[SecureContext,
 Exposed=Window]
interface Presentation {
};

partial interface Presentation {
    readonly attribute PresentationReceiver? receiver;
};

[Constructor(DOMString type, PresentationConnectionAvailableEventInit eventInitDict),
 SecureContext,
 Exposed=Window]
interface PresentationConnectionAvailableEvent : Event {
    [SameObject]
    readonly attribute PresentationConnection connection;
};

dictionary PresentationConnectionAvailableEventInit : EventInit {
    required PresentationConnection connection;
};

enum PresentationConnectionState {
    "connecting",
    "connected",
    "closed",
    "terminated"
};

enum BinaryType {
    "blob",
    "arraybuffer"
};

[SecureContext,
 Exposed=Window]
interface PresentationConnection : EventTarget {
    readonly attribute USVString                   id;
    readonly attribute USVString                   url;
    readonly attribute PresentationConnectionState state;
    void close();
    void terminate();
             attribute EventHandler                onconnect;
             attribute EventHandler                onclose;
             attribute EventHandler                onterminate;

    // Communication
             attribute BinaryType                  binaryType;
             attribute EventHandler                onmessage;
    void send(DOMString message);
    void send(Blob data);
    void send(ArrayBuffer data);
    void send(ArrayBufferView data);
};

enum PresentationConnectionCloseReason {
    "error",
    "closed",
    "wentaway"
};

[Constructor(DOMString type, PresentationConnectionCloseEventInit eventInitDict),
 SecureContext,
 Exposed=Window]
interface PresentationConnectionCloseEvent : Event {
    readonly attribute PresentationConnectionCloseReason reason;
    readonly attribute DOMString                         message;
};

dictionary PresentationConnectionCloseEventInit : EventInit {
    required PresentationConnectionCloseReason reason;
             DOMString                         message = "";
};

[SecureContext,
 Exposed=Window]
interface PresentationReceiver {
    readonly attribute Promise<PresentationConnectionList> connectionList;
};

[SecureContext,
 Exposed=Window]
interface PresentationConnectionList : EventTarget {
    readonly attribute FrozenArray<PresentationConnection> connections;
             attribute EventHandler                        onconnectionavailable;
};
</script>

<script>
    (() => {
        'use strict';
        const idl_array = new IdlArray();
        const idls = document.getElementById('idl').textContent;
        idl_array.add_untested_idls(document.getElementById('untested_idl').textContent);
        idl_array.add_idls(idls);
        idl_array.add_objects({
            Presentation: ['navigator.presentation'],
            PresentationReceiver: ['navigator.presentation.receiver']
        });
        add_completion_callback((tests, status) => {
            const stash = new Stash(stashIds.toReceiver, stashIds.toController);
            const log = document.getElementById('log');
            stash.send(JSON.stringify({ tests: tests, status: status, log: log.innerHTML }));
        });
        idl_array.test();
    })();
</script>
back to top