1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * https://w3c.github.io/clipboard-apis/
9 * Copyright © 2018 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
10 * liability, trademark and document use rules apply.
13 typedef sequence<ClipboardItem> ClipboardItems;
17 InstrumentedProps=(read,readText,write)]
18 interface Clipboard : EventTarget {
19 [Pref="dom.events.asyncClipboard.clipboardItem", NewObject, NeedsSubjectPrincipal]
20 Promise<ClipboardItems> read();
21 [Func="Clipboard::ReadTextEnabled", NewObject, NeedsSubjectPrincipal]
22 Promise<DOMString> readText();
24 [Pref="dom.events.asyncClipboard.clipboardItem", NewObject, NeedsSubjectPrincipal]
25 Promise<undefined> write(ClipboardItems data);
27 [NewObject, NeedsSubjectPrincipal]
28 Promise<undefined> writeText(DOMString data);
31 typedef (DOMString or Blob) ClipboardItemDataType;
32 typedef Promise<ClipboardItemDataType> ClipboardItemData;
33 // callback ClipboardItemDelayedCallback = ClipboardItemData ();
35 [SecureContext, Exposed=Window, Pref="dom.events.asyncClipboard.clipboardItem"]
36 interface ClipboardItem {
38 constructor(record<DOMString, ClipboardItemData> items,
39 optional ClipboardItemOptions options = {});
41 // static ClipboardItem createDelayed(
42 // record<DOMString, ClipboardItemDelayedCallback> items,
43 // optional ClipboardItemOptions options = {});
45 readonly attribute PresentationStyle presentationStyle;
46 // readonly attribute long long lastModified;
47 // readonly attribute boolean delayed;
49 // TODO: Use FrozenArray once available. (Bug 1236777)
50 // readonly attribute FrozenArray<DOMString> types;
51 [Frozen, Cached, Pure]
52 readonly attribute sequence<DOMString> types;
55 Promise<Blob> getType(DOMString type);
58 enum PresentationStyle { "unspecified", "inline", "attachment" };
60 dictionary ClipboardItemOptions {
61 PresentationStyle presentationStyle = "unspecified";