Bug 1617887 part 1 follow-up - Fix tests that depend on isMac or isWindows. rs=bustage-fix
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 09 Mar 2020 15:03:58 +1300
changeset 37514 22c665f600c7085b3149a9246ef6b87aff7e2957
parent 37513 15b43b265eb46cbfcd989bb9e817cdead267fef1
child 37515 7d7596b594c302f882acb50ebe5d98d971ceb1a2
push id2566
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:20:31 +0000
treeherdercomm-beta@a352facfa0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1617887
Bug 1617887 part 1 follow-up - Fix tests that depend on isMac or isWindows. rs=bustage-fix
mail/test/browser/attachment/browser_attachment.js
mail/test/browser/composition/browser_attachment.js
mail/test/browser/composition/browser_drafts.js
mail/test/browser/folder-tree-modes/browser_modeSwitching.js
--- a/mail/test/browser/attachment/browser_attachment.js
+++ b/mail/test/browser/attachment/browser_attachment.js
@@ -560,17 +560,17 @@ add_task(function test_attachments_compo
   // On Linux and OSX, focus events don't seem to be sent to child elements properly if
   // the parent window is not focused.  This causes some random oranges for us.
   // We use the force_focus function to "cheat" a bit, and trigger the function
   // that focusing normally would fire.  We do normal focusing for Windows.
   function force_focus(aId) {
     let element = cwc.e(aId);
     element.focus();
 
-    if (!mc.mozmillModule.isWindows) {
+    if (["linux", "macosx"].includes(AppConstants.platform)) {
       // First, call the window's default controller's function.
       cwc.window.defaultController.isCommandEnabled("cmd_delete");
 
       // Walk up the DOM tree and call isCommandEnabled on the first controller
       // that supports "cmd_delete".
       while (element != cwc.window.document) {
         for (let i = 0; i < element.controllers.getControllerCount(); i++) {
           let currController = element.controllers.getControllerAt(i);
--- a/mail/test/browser/composition/browser_attachment.js
+++ b/mail/test/browser/composition/browser_attachment.js
@@ -39,17 +39,16 @@ var { plan_for_modal_dialog, wait_for_mo
 var { AppConstants } = ChromeUtils.import(
   "resource://gre/modules/AppConstants.jsm"
 );
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var messenger;
 var folder;
 var epsilon;
-var isWindows;
 var filePrefix;
 
 var rawAttachment =
   "Can't make the frug contest, Helen; stomach's upset. I'll fix you, " +
   "Ubik! Ubik drops you back in the thick of things fast. Taken as " +
   "directed, Ubik speeds relief to head and stomach. Remember: Ubik is " +
   "only seconds away. Avoid prolonged use.";
 
@@ -60,28 +59,26 @@ var b64Attachment =
   "SNQAAlmAY+71EgFoAAAAASUVORK5CYII=";
 var b64Size = 188;
 
 add_task(function setupModule(module) {
   folder = create_folder("ComposeAttachmentA");
 
   messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
 
-  isWindows = "@mozilla.org/windows-registry-key;1" in Cc;
-
   /* Today's gory details (thanks to Jonathan Protzenko): libmime somehow
    * counts the trailing newline for an attachment MIME part. Most of the time,
    * assuming attachment has N bytes (no matter what's inside, newlines or
    * not), libmime will return N + 1 bytes. On Linux and Mac, this always
    * holds. However, on Windows, if the attachment is not encoded (that is, is
    * inline text), libmime will return N + 2 bytes. Since we're dealing with
    * forwarded message data here, the bonus byte(s) appear twice.
    */
-  epsilon = isWindows ? 4 : 2;
-  filePrefix = isWindows ? "file:///C:/" : "file:///";
+  epsilon = AppConstants.platform == "win" ? 4 : 2;
+  filePrefix = AppConstants.platform == "win" ? "file:///C:/" : "file:///";
 
   // create some messages that have various types of attachments
   let messages = [
     // no attachment
     {},
     // raw attachment
     {
       attachments: [{ body: rawAttachment, filename: "ubik.txt", format: "" }],
--- a/mail/test/browser/composition/browser_drafts.js
+++ b/mail/test/browser/composition/browser_drafts.js
@@ -101,17 +101,17 @@ function internal_check_delivery_format(
   setup_msg_contents(
     cwc,
     "test@example.invalid",
     "Testing storing of the composition properties in the draft!",
     "Hello!"
   );
 
   // Select our wanted format.
-  if (!mc.mozmillModule.isMac) {
+  if (["linux", "win"].includes(AppConstants.platform)) {
     cwc.click(cwc.eid("optionsMenu"));
     cwc.click_menus_in_sequence(cwc.e("optionsMenuPopup"), [
       { id: "outputFormatMenu" },
       { id: "format_both" },
     ]);
   } else {
     // On OS X the main menu seems not accessible for clicking from mozmill.
     Assert.ok(
@@ -125,17 +125,17 @@ function internal_check_delivery_format(
 
   /**
    * Check if the right format is selected in the menu.
    *
    * @param aMenuItemId  The id of the menuitem expected to be selected.
    * @param aValue       A value of nsIMsgCompSendFormat constants of the expected selected format.
    */
   function assert_format_value(aMenuItemId, aValue) {
-    if (!mc.mozmillModule.isMac) {
+    if (["linux", "win"].includes(AppConstants.platform)) {
       cwc.click(cwc.eid("optionsMenu"));
       let formatMenu = cwc.click_menus_in_sequence(
         cwc.e("optionsMenuPopup"),
         [{ id: "outputFormatMenu" }],
         true
       );
       let formatItem = cwc
         .e("outputFormatMenuPopup")
--- a/mail/test/browser/folder-tree-modes/browser_modeSwitching.js
+++ b/mail/test/browser/folder-tree-modes/browser_modeSwitching.js
@@ -87,17 +87,17 @@ function assert_compact_state(aChecked, 
  *
  * @param aMode  The name of the expected mode.
  */
 function assert_mode_selected(aMode) {
   Assert.equal(tree.mode, aMode);
   let baseMode = tree.baseMode();
   assert_compact_state(baseMode != tree.mode);
   // We need to open the menu because only then the right mode is set in them.
-  if (!mc.mozmillModule.isMac) {
+  if (["linux", "win"].includes(AppConstants.platform)) {
     // On OS X the main menu seems not accessible for clicking from mozmill.
     mc.click(view_menu);
     let popuplist = mc.click_menus_in_sequence(
       view_menupopup,
       [{ id: modeList_menu.parentNode.id }],
       true
     );
     Assert.ok(