Commit ce584315 authored by Neil Deakin's avatar Neil Deakin Committed by Georg Koppen
Browse files

Bug 1273371c, don't use the searchbar for this test, instead use a separate textbox, r=gijs

This and the previous two commits fix bug 20442 in our bug tracker.
parent c33bf961
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -2,15 +2,16 @@
// event.clipboardData.

add_task(function*() {
  var searchbar = document.getElementById("searchbar");
  var textbox = document.createElement("textbox");
  document.documentElement.appendChild(textbox);

  searchbar.focus();
  searchbar.value = "Text";
  searchbar.select();
  textbox.focus();
  textbox.value = "Text";
  textbox.select();

  yield new Promise((resolve, reject) => {
    searchbar.addEventListener("copy", function copyEvent(event) {
      searchbar.removeEventListener("copy", copyEvent, true);
    textbox.addEventListener("copy", function copyEvent(event) {
      textbox.removeEventListener("copy", copyEvent, true);
      event.clipboardData.setData("text/plain", "Alternate");
      // For this test, it doesn't matter that the file isn't actually a file.
      event.clipboardData.setData("application/x-moz-file", "Sample");
@@ -36,11 +37,11 @@ add_task(function*() {
  });
  is (output, "Passed", "Paste file");

  searchbar.focus();
  textbox.focus();

  yield new Promise((resolve, reject) => {
    searchbar.addEventListener("paste", function copyEvent(event) {
      searchbar.removeEventListener("paste", copyEvent, true);
    textbox.addEventListener("paste", function copyEvent(event) {
      textbox.removeEventListener("paste", copyEvent, true);

      let dt = event.clipboardData;
      is(dt.types.length, 3, "number of types");
@@ -55,5 +56,7 @@ add_task(function*() {
    EventUtils.synthesizeKey("v", { accelKey: true });
  });

  document.documentElement.removeChild(textbox);

  yield BrowserTestUtils.removeTab(tab);
});