Bug 1273371 - Don't use the searchbar for this test, instead use a separate textbox. r=gijs, a=test-only
authorNeil Deakin <neil@mozilla.com>
Mon, 17 Oct 2016 13:55:16 -0400
changeset 350715 7219e6b8ae728507b485e59490301bbbb38deba6
parent 350714 64bffdab3d1e819b44dc05dc6e5bb63e8dafff6c
child 350716 0eb418434f75ee9fdde015cc30dad119e1023ac8
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs, test-only
bugs1273371
milestone50.0
Bug 1273371 - Don't use the searchbar for this test, instead use a separate textbox. r=gijs, a=test-only
browser/base/content/test/general/browser_clipboard_pastefile.js
--- a/browser/base/content/test/general/browser_clipboard_pastefile.js
+++ b/browser/base/content/test/general/browser_clipboard_pastefile.js
@@ -1,21 +1,22 @@
 // This test is used to check that pasting files removes all non-file data from
 // 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");
       event.preventDefault();
       resolve();
     }, true)
 
     EventUtils.synthesizeKey("c", { accelKey: true });
@@ -31,29 +32,31 @@ add_task(function*() {
 
   yield BrowserTestUtils.synthesizeKey("v", { accelKey: true }, browser);
 
   let output = yield ContentTask.spawn(browser, { }, function* (arg) {
     return content.document.getElementById("output").textContent;
   });
   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");
       ok(dt.types.contains("text/plain"), "text/plain exists in types");
       ok(dt.mozTypesAt(0).contains("text/plain"), "text/plain exists in mozTypesAt");
       is(dt.getData("text/plain"), "Alternate", "text/plain returned in getData");
       is(dt.mozGetDataAt("text/plain", 0), "Alternate", "text/plain returned in mozGetDataAt");
 
       resolve();
     }, true);
 
     EventUtils.synthesizeKey("v", { accelKey: true });
   });
 
+  document.documentElement.removeChild(textbox);
+
   yield BrowserTestUtils.removeTab(tab);
 });