summaryrefslogtreecommitdiffstats
path: root/widget/tests/test_clipboard_cache.xhtml
blob: 39cf8113dd65dde6d61dddd3e3245b77840bbfe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1812543
-->
<window title="Mozilla Bug 1812543"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="clipboard_helper.js"/>

<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>

<!-- test code goes here -->
<script class="testbody" type="application/javascript">
<![CDATA[

let supportOtherClipboardTypes = false;
clipboardTypes.forEach(function(type) {
  if (clipboard.kGlobalClipboard != type && clipboard.isClipboardTypeSupported(type)) {
    supportOtherClipboardTypes = true;
    add_task(function test_clipboard_hasDataMatchingFlavors() {
      info(`Test write data to clipboard type ${type}`);

      // Write text/plain data to main clipboard.
      writeRandomStringToClipboard("text/plain", clipboard.kGlobalClipboard);
      ok(clipboard.hasDataMatchingFlavors(["text/plain"], clipboard.kGlobalClipboard),
         "Should have text/plain flavor");
      ok(!clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard),
         "Should not have text/html flavor");

      // Write text/html data to other clipboard.
      writeRandomStringToClipboard("text/html", type);
      ok(clipboard.hasDataMatchingFlavors(["text/plain"], clipboard.kGlobalClipboard),
         "Should have text/plain flavor");
      ok(!clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard),
         "Should not have text/html flavor");

      // Clean clipboard data.
      cleanupAllClipboard();
    });
  }
});

if (!supportOtherClipboardTypes) {
  ok(true, "Don't support other clipboard types, skip tests");
}

]]>
</script>
</window>