dom/tests/mochitest/general/test_clipboard_events.html
author Randell Jesup <rjesup@wgate.com>
Wed, 28 Sep 2022 02:10:18 +0000
changeset 636504 388419886525a4b8d6be986bc890f09e6c16052d
parent 585384 cce06fb4125178801004736e739ede6c0dc62a2d
permissions -rw-r--r--
Bug 1791332: Add an OPFS-specific synchronous ordered cleanup queue r=asuth,dom-storage-reviewers The default test.add_cleanup() code from testharness.js in wpt executes the cleanups in parallel, and even if it wasn't in parallel it would be in FIFO order (the wrong order). This adds an OPFS-specific cleanup queue called once from the test cleanup list, and we process the list synchronously in LIFO order. Depends on D146203 Differential Revision: https://phabricator.services.mozilla.com/D157606

<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Clipboard Events</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<script>
"use strict";

// The clipboard event tests require `GlobalEventHandlers.onbeforeinput`
// attribute which is available only when `beforeinput` event is enabled.
// For ensuring it's available with any element in the document, we need
// to enable it in this window and then, create elements in the new
// document in a child window.

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [
      // NOTE: The tests operate under the assumption that the protected mode of
      // DataTransfer is enabled.
      ["dom.events.dataTransfer.protected.enabled", true],
    ]
  });
  let childWindow =
    window.open("window_clipboard_events.html", "_blank", "width=500,height=800");
  ok(childWindow, "A child window should've been opened");
  childWindow.onclose = () => {
    SimpleTest.finish();
  };
});
</script>
</body>
</html>