From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sun, 7 Apr 2024 21:33:14 +0200
Subject: Adding upstream version 115.7.0esr.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 .../tests/clipboard-apis/resources/copied-file.txt |   1 +
 .../tests/clipboard-apis/resources/greenbox.png    | Bin 0 -> 95 bytes
 .../tests/clipboard-apis/resources/page.html       |  26 +++++++++++++++++++++
 .../clipboard-apis/resources/user-activation.js    |  25 ++++++++++++++++++++
 4 files changed, 52 insertions(+)
 create mode 100644 testing/web-platform/tests/clipboard-apis/resources/copied-file.txt
 create mode 100644 testing/web-platform/tests/clipboard-apis/resources/greenbox.png
 create mode 100644 testing/web-platform/tests/clipboard-apis/resources/page.html
 create mode 100644 testing/web-platform/tests/clipboard-apis/resources/user-activation.js

(limited to 'testing/web-platform/tests/clipboard-apis/resources')

diff --git a/testing/web-platform/tests/clipboard-apis/resources/copied-file.txt b/testing/web-platform/tests/clipboard-apis/resources/copied-file.txt
new file mode 100644
index 0000000000..56a2838b7d
--- /dev/null
+++ b/testing/web-platform/tests/clipboard-apis/resources/copied-file.txt
@@ -0,0 +1 @@
+copied-file-contents
diff --git a/testing/web-platform/tests/clipboard-apis/resources/greenbox.png b/testing/web-platform/tests/clipboard-apis/resources/greenbox.png
new file mode 100644
index 0000000000..6e555e3b19
Binary files /dev/null and b/testing/web-platform/tests/clipboard-apis/resources/greenbox.png differ
diff --git a/testing/web-platform/tests/clipboard-apis/resources/page.html b/testing/web-platform/tests/clipboard-apis/resources/page.html
new file mode 100644
index 0000000000..35bde8e501
--- /dev/null
+++ b/testing/web-platform/tests/clipboard-apis/resources/page.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-action.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="user-activation.js"></script>
+
+<div style="width: 10px; height: 10px"></div>
+<script>
+window.addEventListener("message", async (e) => {
+  if (e.data && e.data[0] == "write") {
+    test_driver.set_test_context(window.parent);
+    await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+    await waitForUserActivation();
+    await navigator.clipboard.write([
+      new ClipboardItem({
+        "text/plain":  e.data[1],
+      }),
+    ]).catch(() => {
+      assert_true(false, `should not fail`);
+    });
+    window.parent.postMessage("done", "*");
+  }
+});
+</script>
+</html>
diff --git a/testing/web-platform/tests/clipboard-apis/resources/user-activation.js b/testing/web-platform/tests/clipboard-apis/resources/user-activation.js
new file mode 100644
index 0000000000..ed294bb9cb
--- /dev/null
+++ b/testing/web-platform/tests/clipboard-apis/resources/user-activation.js
@@ -0,0 +1,25 @@
+'use strict';
+
+// In order to use this function, please import testdriver.js and
+// testdriver-vendor.js, and include a <body> element.
+async function waitForUserActivation() {
+  if (window.opener) {
+    throw new Error(
+        "waitForUserActivation() only works in the top-level frame");
+  }
+  const loadedPromise = new Promise(resolve => {
+    if(document.readyState == 'complete') {
+      resolve();
+      return;
+    }
+    window.addEventListener('load', resolve, {once: true});
+  });
+  await loadedPromise;
+
+  const clickedPromise = new Promise(resolve => {
+    document.body.addEventListener('click', resolve, {once: true});
+  });
+
+  test_driver.click(document.body);
+  await clickedPromise;
+}
-- 
cgit v1.2.3