2018-09-13 23:04:55 +03:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-03-19 10:48:28 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
2016-10-17 03:19:00 +03:00
|
|
|
*
|
|
|
|
* The origin of this IDL file is
|
|
|
|
* https://w3c.github.io/presentation-api/#interface-presentationconnection
|
2015-03-19 10:48:28 +03:00
|
|
|
*/
|
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
enum PresentationConnectionState
|
2015-03-19 10:48:28 +03:00
|
|
|
{
|
2016-05-29 20:59:00 +03:00
|
|
|
// The initial state when a PresentationConnection is ceated.
|
|
|
|
"connecting",
|
|
|
|
|
2015-03-19 10:48:28 +03:00
|
|
|
// Existing presentation, and the communication channel is active.
|
|
|
|
"connected",
|
|
|
|
|
|
|
|
// Existing presentation, but the communication channel is inactive.
|
2015-10-08 13:11:10 +03:00
|
|
|
"closed",
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
// The presentation is nonexistent anymore. It could be terminated manually,
|
2015-10-08 13:11:10 +03:00
|
|
|
// or either controlling or receiving browsing context is no longer available.
|
2015-03-19 10:48:28 +03:00
|
|
|
"terminated"
|
|
|
|
};
|
|
|
|
|
2016-09-18 02:42:00 +03:00
|
|
|
enum PresentationConnectionBinaryType
|
|
|
|
{
|
|
|
|
"blob",
|
|
|
|
"arraybuffer"
|
|
|
|
};
|
|
|
|
|
2019-09-27 18:26:14 +03:00
|
|
|
[Pref="dom.presentation.enabled",
|
|
|
|
Exposed=Window]
|
2015-10-12 05:36:31 +03:00
|
|
|
interface PresentationConnection : EventTarget {
|
2015-03-19 10:48:28 +03:00
|
|
|
/*
|
2015-10-12 05:36:31 +03:00
|
|
|
* Unique id for all existing connections.
|
2015-03-19 10:48:28 +03:00
|
|
|
*/
|
|
|
|
[Constant]
|
|
|
|
readonly attribute DOMString id;
|
|
|
|
|
2016-08-02 20:11:00 +03:00
|
|
|
/*
|
|
|
|
* Specifies the connection's presentation URL.
|
|
|
|
*/
|
|
|
|
readonly attribute DOMString url;
|
|
|
|
|
2015-03-19 10:48:28 +03:00
|
|
|
/*
|
2015-10-08 13:11:10 +03:00
|
|
|
* @value "connected", "closed", or "terminated".
|
2015-03-19 10:48:28 +03:00
|
|
|
*/
|
2015-10-12 05:36:31 +03:00
|
|
|
readonly attribute PresentationConnectionState state;
|
2015-03-19 10:48:28 +03:00
|
|
|
|
2016-05-30 09:48:00 +03:00
|
|
|
attribute EventHandler onconnect;
|
|
|
|
attribute EventHandler onclose;
|
|
|
|
attribute EventHandler onterminate;
|
2016-09-18 02:42:00 +03:00
|
|
|
attribute PresentationConnectionBinaryType binaryType;
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
/*
|
2015-10-08 13:11:10 +03:00
|
|
|
* After a communication channel has been established between the controlling
|
|
|
|
* and receiving context, this function is called to send message out, and the
|
|
|
|
* event handler "onmessage" will be invoked at the remote side.
|
2015-03-19 10:48:28 +03:00
|
|
|
*
|
2015-10-08 13:11:10 +03:00
|
|
|
* This function only works when the state is "connected".
|
2015-03-19 10:48:28 +03:00
|
|
|
*/
|
|
|
|
[Throws]
|
|
|
|
void send(DOMString data);
|
|
|
|
|
2016-09-18 02:42:00 +03:00
|
|
|
[Throws]
|
|
|
|
void send(Blob data);
|
|
|
|
|
|
|
|
[Throws]
|
|
|
|
void send(ArrayBuffer data);
|
|
|
|
|
|
|
|
[Throws]
|
|
|
|
void send(ArrayBufferView data);
|
|
|
|
|
2015-03-19 10:48:28 +03:00
|
|
|
/*
|
|
|
|
* It is triggered when receiving messages.
|
|
|
|
*/
|
|
|
|
attribute EventHandler onmessage;
|
|
|
|
|
|
|
|
/*
|
2015-10-12 05:36:31 +03:00
|
|
|
* Both the controlling and receiving browsing context can close the
|
|
|
|
* connection. Then the connection state should turn into "closed".
|
2015-10-08 13:11:10 +03:00
|
|
|
*
|
2016-07-13 01:18:00 +03:00
|
|
|
* This function only works when the state is "connected" or "connecting".
|
2015-10-08 13:11:10 +03:00
|
|
|
*/
|
2016-07-13 01:18:00 +03:00
|
|
|
[Throws]
|
|
|
|
void close();
|
2015-10-08 13:11:10 +03:00
|
|
|
|
|
|
|
/*
|
2015-10-12 05:36:31 +03:00
|
|
|
* Both the controlling and receiving browsing context can terminate the
|
|
|
|
* connection. Then the connection state should turn into "terminated".
|
2015-03-19 10:48:28 +03:00
|
|
|
*
|
2015-10-08 13:11:10 +03:00
|
|
|
* This function only works when the state is not "connected".
|
2015-03-19 10:48:28 +03:00
|
|
|
*/
|
2015-10-08 13:11:10 +03:00
|
|
|
[Throws]
|
|
|
|
void terminate();
|
2015-03-19 10:48:28 +03:00
|
|
|
};
|