Bug 1551490 - Fix browser_dragdrop.js and fold browser_dragdrop_incompat into it. r=kmag
authorLuca Greco <lgreco@mozilla.com>
Fri, 24 May 2019 16:07:07 +0000
changeset 478024 92b3d4c40e67f9b98e589fabe0b57863520a485d
parent 478023 d316cf637ff946a374708b8c6fbaf977c84a9b83
child 478025 a9b1a1ab0ec51f5ba72ff2f493e18fec73868458
push id87477
push userrob@robwu.nl
push dateMon, 10 Jun 2019 00:06:25 +0000
treeherderautoland@7a44faddc33d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1551490
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551490 - Fix browser_dragdrop.js and fold browser_dragdrop_incompat into it. r=kmag Depends on D31779 Differential Revision: https://phabricator.services.mozilla.com/D31780
toolkit/mozapps/extensions/test/browser/browser.ini
toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
toolkit/mozapps/extensions/test/browser/browser_dragdrop_incompat.js
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -66,17 +66,16 @@ skip-if = os == "linux" && !debug # Bug 
 [browser_bug618502.js]
 [browser_bug679604.js]
 [browser_bug590347.js]
 [browser_checkAddonCompatibility.js]
 [browser_details.js]
 [browser_discovery.js]
 [browser_discovery_clientid.js]
 [browser_dragdrop.js]
-[browser_dragdrop_incompat.js]
 [browser_extension_sideloading_permission.js]
 [browser_file_xpi_no_process_switch.js]
 skip-if = true # Bug 1449071 - Frequent failures
 [browser_globalwarnings.js]
 [browser_gmpProvider.js]
 skip-if = os == 'linux' && !debug # Bug 1398766
 [browser_html_abuse_report.js]
 [browser_html_detail_view.js]
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
@@ -13,17 +13,17 @@
 var gManagerWindow;
 var EventUtils = {};
 Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
 
 async function checkInstallConfirmation(...names) {
   let notificationCount = 0;
   let observer = {
     observe(aSubject, aTopic, aData) {
-      var installInfo = aSubject.wrappedJSObject;
+      let installInfo = aSubject.wrappedJSObject;
       isnot(installInfo.browser, null, "Notification should have non-null browser");
 
       is(installInfo.installs.length, 1, "Got one AddonInstall instance as expected");
 
       Assert.deepEqual(installInfo.installs[0].installTelemetryInfo,
                        {source: "about:addons", method: "drag-and-drop"},
                        "Got the expected installTelemetryInfo");
 
@@ -48,95 +48,116 @@ async function checkInstallConfirmation(
     }
     panel.secondaryButton.click();
   }
 
   Assert.deepEqual(results.sort(), names.sort(), "Got expected installs");
 
   is(notificationCount, names.length, `Saw ${names.length} addon-install-started notification`);
   Services.obs.removeObserver(observer, "addon-install-started");
-
-  executeSoon(run_next_test);
 }
 
-async function test() {
-  waitForExplicitFinish();
-
-  let aWindow = await open_manager("addons://list/extension");
-  gManagerWindow = aWindow;
-  run_next_test();
-}
-
-async function end_test() {
-  await close_manager(gManagerWindow);
-  finish();
+function getViewContainer(gManagerWindow) {
+  if (gManagerWindow.useHtmlViews) {
+    return gManagerWindow.document.getElementById("category-box");
+  }
+  return gManagerWindow.document.getElementById("view-port");
 }
 
 // Simulates dropping a URL onto the manager
-add_test(function test_drop_url() {
-  var url = TESTROOT + "addons/browser_dragdrop1.xpi";
-
-  checkInstallConfirmation("Drag Drop test 1");
-
-  var viewContainer = gManagerWindow.document.getElementById("view-port");
-  var effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
-               [[{type: "text/x-moz-url", data: url}]],
-               "copy", gManagerWindow);
+add_task(async function test_drop_url() {
+  let url = TESTROOT + "addons/browser_dragdrop1.xpi";
+  gManagerWindow = await open_manager("addons://list/extension");
+  let promise = checkInstallConfirmation("Drag Drop test 1");
+  let viewContainer = getViewContainer(gManagerWindow);
+  let effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                                         [[{type: "text/x-moz-url", data: url}]],
+                                         "copy", gManagerWindow);
   is(effect, "copy", "Drag should be accepted");
+  await promise;
+  await close_manager(gManagerWindow);
 });
 
 // Simulates dropping a file onto the manager
-add_test(function test_drop_file() {
-  var fileurl = get_addon_file_url("browser_dragdrop1.xpi");
-
-  checkInstallConfirmation("Drag Drop test 1");
-
-  var viewContainer = gManagerWindow.document.getElementById("view-port");
-  var effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
-               [[{type: "application/x-moz-file", data: fileurl.file}]],
-               "copy", gManagerWindow);
+add_task(async function test_drop_file() {
+  let fileurl = get_addon_file_url("browser_dragdrop1.xpi");
+  gManagerWindow = await open_manager("addons://list/extension");
+  await wait_for_view_load(gManagerWindow);
+  let promise = checkInstallConfirmation("Drag Drop test 1");
+  let viewContainer = getViewContainer(gManagerWindow);
+  let effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                                         [[{type: "application/x-moz-file", data: fileurl.file}]],
+                                         "copy", gManagerWindow);
   is(effect, "copy", "Drag should be accepted");
+  await promise;
+  await close_manager(gManagerWindow);
 });
 
 // Simulates dropping two urls onto the manager
-add_test(function test_drop_multiple_urls() {
-  var url1 = TESTROOT + "addons/browser_dragdrop1.xpi";
-  var url2 = TESTROOT2 + "addons/browser_dragdrop2.xpi";
-
-  checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
-
-  var viewContainer = gManagerWindow.document.getElementById("view-port");
-  var effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
-               [[{type: "text/x-moz-url", data: url1}],
-                [{type: "text/x-moz-url", data: url2}]],
-               "copy", gManagerWindow);
+add_task(async function test_drop_multiple_urls() {
+  let url1 = TESTROOT + "addons/browser_dragdrop1.xpi";
+  let url2 = TESTROOT2 + "addons/browser_dragdrop2.xpi";
+  gManagerWindow = await open_manager("addons://list/extension");
+  await wait_for_view_load(gManagerWindow);
+  let promise = checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
+  let viewContainer = getViewContainer(gManagerWindow);
+  let effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                                         [[{type: "text/x-moz-url", data: url1}],
+                                           [{type: "text/x-moz-url", data: url2}]],
+                                         "copy", gManagerWindow);
   is(effect, "copy", "Drag should be accepted");
+  await promise;
+  await close_manager(gManagerWindow);
 });
 
 // Simulates dropping two files onto the manager
-add_test(function test_drop_multiple_files() {
-  var fileurl1 = get_addon_file_url("browser_dragdrop1.xpi");
-  var fileurl2 = get_addon_file_url("browser_dragdrop2.xpi");
-
-  checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
-
-  var viewContainer = gManagerWindow.document.getElementById("view-port");
-  var effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
-               [[{type: "application/x-moz-file", data: fileurl1.file}],
-                [{type: "application/x-moz-file", data: fileurl2.file}]],
-               "copy", gManagerWindow);
+add_task(async function test_drop_multiple_files() {
+  let fileurl1 = get_addon_file_url("browser_dragdrop1.xpi");
+  let fileurl2 = get_addon_file_url("browser_dragdrop2.xpi");
+  gManagerWindow = await open_manager("addons://list/extension");
+  await wait_for_view_load(gManagerWindow);
+  let promise = checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
+  let viewContainer = getViewContainer(gManagerWindow);
+  let effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                                         [[{type: "application/x-moz-file", data: fileurl1.file}],
+                                           [{type: "application/x-moz-file", data: fileurl2.file}]],
+                                         "copy", gManagerWindow);
   is(effect, "copy", "Drag should be accepted");
+  await promise;
+  await close_manager(gManagerWindow);
 });
 
 // Simulates dropping a file and a url onto the manager (weird, but should still work)
-add_test(function test_drop_file_and_url() {
-  var url = TESTROOT + "addons/browser_dragdrop1.xpi";
-  var fileurl = get_addon_file_url("browser_dragdrop2.xpi");
-
-  checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
+add_task(async function test_drop_file_and_url() {
+  let url = TESTROOT + "addons/browser_dragdrop1.xpi";
+  let fileurl = get_addon_file_url("browser_dragdrop2.xpi");
+  gManagerWindow = await open_manager("addons://list/extension");
+  await wait_for_view_load(gManagerWindow);
+  let promise = checkInstallConfirmation("Drag Drop test 1", "Drag Drop test 2");
+  let viewContainer = getViewContainer(gManagerWindow);
+  let effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                                         [[{type: "text/x-moz-url", data: url}],
+                                           [{type: "application/x-moz-file", data: fileurl.file}]],
+                                         "copy", gManagerWindow);
+  is(effect, "copy", "Drag should be accepted");
+  await promise;
+  await close_manager(gManagerWindow);
+});
 
-  var viewContainer = gManagerWindow.document.getElementById("view-port");
-  var effect = EventUtils.synthesizeDrop(viewContainer, viewContainer,
-               [[{type: "text/x-moz-url", data: url}],
-                [{type: "application/x-moz-file", data: fileurl.file}]],
-               "copy", gManagerWindow);
-  is(effect, "copy", "Drag should be accepted");
+// Test that drag-and-drop of an incompatible addon generates
+// an error.
+add_task(async function test_drop_incompat_file() {
+  let gManagerWindow = await open_manager("addons://list/extension");
+  await wait_for_view_load(gManagerWindow);
+
+  let errorPromise = TestUtils.topicObserved("addon-install-failed");
+
+  let url = `${TESTROOT}/addons/browser_dragdrop_incompat.xpi`;
+  let viewContainer = getViewContainer(gManagerWindow);
+  EventUtils.synthesizeDrop(viewContainer, viewContainer,
+                            [[{type: "text/x-moz-url", data: url}]],
+                            "copy", gManagerWindow);
+
+  await errorPromise;
+  ok(true, "Got addon-install-failed event");
+
+  await close_manager(gManagerWindow);
 });
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop_incompat.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// Test that drag-and-drop of an incompatible addon generates
-// an error.
-add_task(async function() {
-  let window = await open_manager("addons://list/extension");
-
-  let errorPromise = new Promise(resolve => {
-    let observer = {
-      observe(subject, topc, data) {
-        Services.obs.removeObserver(observer, "addon-install-failed");
-        resolve();
-      },
-    };
-    Services.obs.addObserver(observer, "addon-install-failed");
-  });
-
-  let url = `${TESTROOT}/addons/browser_dragdrop_incompat.xpi`;
-  let viewContainer = window.document.getElementById("view-port");
-  EventUtils.synthesizeDrop(viewContainer, viewContainer,
-                            [[{type: "text/x-moz-url", data: url}]],
-                            "copy", window);
-
-  await errorPromise;
-  ok(true, "Got addon-install-failed event");
-
-  await close_manager(window);
-});