Bug 1332166 - Wait for the clipboard to be updated before checking it. r=enndeakin, a=test-only
authorMichael Layzell <michael@thelayzells.com>
Tue, 14 Mar 2017 13:48:51 -0400
changeset 379068 7c80fd53c63940df375009ae109807cd88b0c021
parent 379067 8eefcde96334ddb87f76ce97cb21d18b7096f017
child 379069 7f5193633d2e8420c49d0d22c703d1c5f30018c7
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, test-only
bugs1332166
milestone53.0
Bug 1332166 - Wait for the clipboard to be updated before checking it. r=enndeakin, a=test-only MozReview-Commit-ID: Ea6jZCYjuaY
dom/plugins/test/mochitest/test_copyText.html
--- a/dom/plugins/test/mochitest/test_copyText.html
+++ b/dom/plugins/test/mochitest/test_copyText.html
@@ -6,24 +6,29 @@
   <script type="text/javascript" src="plugin-utils.js"></script>
 
   <script class="testbody" type="text/javascript">
 function runTests() {
   var text = " some text \n to copy 'n paste "
   var textElt = document.getElementById("input");
   var plugin = document.getElementById("plugin1");
 
-  textElt.focus();
-  textElt.value = text;
-  textElt.select();
-  SpecialPowers.wrap(textElt).editor.copy();
-
-  is(plugin.getClipboardText(), text);
-
-  SimpleTest.finish();
+  // Make sure we wait for the clipboard
+  SimpleTest.waitForClipboard(text, () => {
+    textElt.focus();
+    textElt.value = text;
+    textElt.select();
+    SpecialPowers.wrap(textElt).editor.copy();
+  }, () => {
+    is(plugin.getClipboardText(), text);
+    SimpleTest.finish();
+  }, () => {
+    ok(false, "Failed to set the clipboard text!");
+    SimpleTest.finish();
+  });
 }
 
 SimpleTest.waitForExplicitFinish();
 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   </script>
 </head>