imported patch mozmill-prefs draft
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 10 May 2019 20:16:55 +1200
changeset 73556 0586c2229b7eac14f6d176c32f386c7c9d25dc6b
parent 73555 840dd94ba5e7abafdb641a8eb3d479455e94c07e
child 73557 d970d8b64353b1c2511aaa3db67cad93d731bf12
push id8426
push usergeoff@darktrojan.net
push dateFri, 10 May 2019 08:18:22 +0000
treeherdertry-comm-central@d970d8b64353 [default view] [failures only]
imported patch mozmill-prefs
.eslintignore
mail/test/mozmill/content-policy/prefs.js
mail/test/mozmill/content-policy/wrapper.py
mail/test/mozmill/content-tabs/prefs.js
mail/test/mozmill/content-tabs/wrapper.py
mail/test/mozmill/instrumentation/prefs.js
mail/test/mozmill/instrumentation/wrapper.py
mail/test/mozmill/override-main-menu-collapse/prefs.js
mail/test/mozmill/override-main-menu-collapse/wrapper.py
mail/test/mozmill/pref-window/linux-prefs.js
mail/test/mozmill/pref-window/mac-prefs.js
mail/test/mozmill/pref-window/windows-prefs.js
mail/test/mozmill/pref-window/wrapper.py
mail/test/mozmill/runtest.py
mail/test/mozmill/startup-firstrun/prefs.js
mail/test/mozmill/startup-firstrun/wrapper.py
--- a/.eslintignore
+++ b/.eslintignore
@@ -70,24 +70,16 @@ mailnews/mime/*
 mail/app/profile/all-thunderbird.js
 mail/app/profile/channel-prefs.js
 mail/app/profile/prefs.js
 mail/base/content/protovis-r2.6-modded.js
 mail/branding/nightly/thunderbird-branding.js
 mail/branding/thunderbird/thunderbird-branding.js
 mail/components/im/all-im.js
 mail/locales/en-US/all-l10n.js
-mail/test/mozmill/content-policy/prefs.js
-mail/test/mozmill/content-tabs/prefs.js
-mail/test/mozmill/instrumentation/prefs.js
-mail/test/mozmill/override-main-menu-collapse/prefs.js
-mail/test/mozmill/pref-window/linux-prefs.js
-mail/test/mozmill/pref-window/mac-prefs.js
-mail/test/mozmill/pref-window/windows-prefs.js
-mail/test/mozmill/startup-firstrun/prefs.js
 
 # calendar/ exclusions
 
 # prefs files
 calendar/lightning/content/lightning.js
 calendar/providers/gdata/defaults/preferences.js
 calendar/timezones/preferences.js
 
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/prefs.js
+++ /dev/null
@@ -1,1 +0,0 @@
-pref("plugin.load_flash_only", false);
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/wrapper.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-import os
-import shutil
-
-
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies *-prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in.
-    preffile = os.path.join(os.path.dirname(__file__), "prefs.js")
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/prefs.js
+++ /dev/null
@@ -1,2 +0,0 @@
-pref("extensions.blocklist.url", "http://localhost:43336/dummy.xml");
-pref("plugin.load_flash_only", false);
--- a/mail/test/mozmill/content-tabs/wrapper.py
+++ b/mail/test/mozmill/content-tabs/wrapper.py
@@ -1,17 +1,8 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-import os
-import shutil
-
-
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies *-prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in.
-    preffile = os.path.join(os.path.dirname(__file__), "prefs.js")
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
+PREFS = {
+    "extensions.blocklist.url": "http://localhost:43336/dummy.xml",
+    "plugin.load_flash_only": False,
+}
deleted file mode 100644
--- a/mail/test/mozmill/instrumentation/prefs.js
+++ /dev/null
@@ -1,1 +0,0 @@
-pref("mail.provider.enabled", false);
--- a/mail/test/mozmill/instrumentation/wrapper.py
+++ b/mail/test/mozmill/instrumentation/wrapper.py
@@ -1,24 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # For test-instrumentation.js, we need to disable the account provisioner, or
 # else it will spawn immediately and block before we have a chance to run
 # any Mozmill tests.
 
-import os
-import shutil
-
 # We don't want any accounts for these tests.
 NO_ACCOUNTS = True
 
-
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies *-prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in.
-    preffile = os.path.join(os.path.dirname(__file__), "prefs.js")
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
+PREFS = {
+    "mail.provider.enabled": False,
+}
deleted file mode 100644
--- a/mail/test/mozmill/override-main-menu-collapse/prefs.js
+++ /dev/null
@@ -1,2 +0,0 @@
-pref("mail.provider.enabled", false);
-pref("mail.main_menu.collapse_by_default", false);
--- a/mail/test/mozmill/override-main-menu-collapse/wrapper.py
+++ b/mail/test/mozmill/override-main-menu-collapse/wrapper.py
@@ -9,18 +9,12 @@
 import os
 import shutil
 
 # We don't want any accounts for these tests.
 NO_ACCOUNTS = True
 # Do not force enable main menu bar, we'll set our own value in prefs.js.
 DEFAULT_MENUBAR = True
 
-
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in.
-    preffile = os.path.join(os.path.dirname(__file__), "prefs.js")
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
+PREFS = {
+    "mail.provider.enabled": False,
+    "mail.main_menu.collapse_by_default": False,
+}
deleted file mode 100644
--- a/mail/test/mozmill/pref-window/linux-prefs.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Default preferences used for test-font-chooser.js on Linux. The UUIDs here
-// should be kept in sync with kFakeFonts in test-font-chooser.js.
-pref("font.name-list.serif.x-western", "bc7e8c62-0634-467f-a029-fe6abcdf1582, serif");
-pref("font.name-list.sans-serif.x-western", "419129aa-43b7-40c4-b554-83d99b504b89, sans-serif");
-pref("font.name-list.monospace.x-western", "348df6e5-e874-4d21-ad4b-359b530a33b7, monospace");
deleted file mode 100644
--- a/mail/test/mozmill/pref-window/mac-prefs.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Default preferences used for test-font-chooser.js on Mac. The UUIDs here
-// should be kept in sync with kFakeFonts in test-font-chooser.js.
-pref("font.name-list.serif.x-western", "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times");
-pref("font.name-list.sans-serif.x-western", "419129aa-43b7-40c4-b554-83d99b504b89, Helvetica");
-pref("font.name-list.monospace.x-western", "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier");
deleted file mode 100644
--- a/mail/test/mozmill/pref-window/windows-prefs.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Default preferences used for test-font-chooser.js on Windows. The UUIDs here
-// should be kept in sync with kFakeFonts in test-font-chooser.js.
-pref("font.name-list.serif.x-western", "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times New Roman");
-pref("font.name-list.sans-serif.x-western", "419129aa-43b7-40c4-b554-83d99b504b89, Arial");
-pref("font.name-list.monospace.x-western", "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier New");
--- a/mail/test/mozmill/pref-window/wrapper.py
+++ b/mail/test/mozmill/pref-window/wrapper.py
@@ -1,29 +1,32 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # For test-font-chooser.js we need a few default prefs -- this module does that.
 
-import os
-import shutil
 import sys
 
-_pref_file_names = {
-    "win32": "windows-prefs.js",
-    "darwin": "mac-prefs.js",
-    "linux2": "linux-prefs.js",
-}
+# Default preferences used for test-font-chooser.js. The UUIDs here
+# should be kept in sync with kFakeFonts in test-font-chooser.js.
 
+if sys.platform == "win32":
+    PREFS = {
+        "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times New Roman",
+        "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, Arial",
+        "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier New",
+    }
 
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies *-prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in.
-    # Fallback to Linux prefs for anything not in the dictionary -- we're
-    # assuming that they're other unixes.
-    preffile = os.path.join(os.path.dirname(__file__),
-                            _pref_file_names.get(sys.platform, "linux-prefs.js"))
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
+elif sys.platform == "darwin":
+    PREFS = {
+        "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times",
+        "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, Helvetica",
+        "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier",
+    }
+
+else:
+    # Fallback to Linux prefs -- we're assuming that they're other unixes.
+    PREFS = {
+        "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, serif",
+        "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, sans-serif",
+        "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, monospace",
+    }
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -215,20 +215,35 @@ class ThunderTestProfile(mozprofile.Thun
 
         if PLUGINS_PATH:
             if not os.path.exists(PLUGINS_PATH):
                 raise Exception('Plugins path "%s" does not exist.' % PLUGINS_PATH)
 
             dest = os.path.join(PROFILE_DIR, "plugins")
             shutil.copytree(PLUGINS_PATH, dest)
 
-        if wrapper is not None and hasattr(wrapper, "on_profile_created"):
-            # It's a little dangerous to allow on_profile_created access to the
-            # profile object, because it isn't fully initialized yet
-            wrapper.on_profile_created(PROFILE_DIR)
+        if wrapper is not None:
+            if hasattr(wrapper, "on_profile_created"):
+                # It's a little dangerous to allow on_profile_created access to the
+                # profile object, because it isn't fully initialized yet
+                wrapper.on_profile_created(PROFILE_DIR)
+
+            if hasattr(wrapper, "PREFS"):
+                with open(os.path.join(PROFILE_DIR, "user.js"), "w") as user_js:
+                    for key, value in wrapper.PREFS.iteritems():
+                        if value is True:
+                            value = "true"
+                        elif value is False:
+                            value = "false"
+                        elif not isinstance(value, int):
+                            value = "\"%s\"" % value
+                        user_js.write("pref(\"%s\", %s);\n" % (key, value))
+
+                with open(os.path.join(PROFILE_DIR, "user.js")) as user_js:
+                    print user_js.read()
 
         return PROFILE_DIR
 
     def cleanup(self):
         '''
         Do not cleanup at all.  The next iteration will cleanup for us, but
         until that time it's useful for debugging failures to leave everything
         around.
deleted file mode 100644
--- a/mail/test/mozmill/startup-firstrun/prefs.js
+++ /dev/null
@@ -1,1 +0,0 @@
-pref("mail.provider.enabled", false);
--- a/mail/test/mozmill/startup-firstrun/wrapper.py
+++ b/mail/test/mozmill/startup-firstrun/wrapper.py
@@ -1,26 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # For these tests, we need to disable the account provisioner, or
 # else it will spawn immediately and block before we have a chance to run
 # any Mozmill tests.
 
-import os
-import shutil
-
 # We don't want any accounts for these tests.
 NO_ACCOUNTS = True
 # Do not force enable main menu bar (keep the default).
 DEFAULT_MENUBAR = True
 
-
-def on_profile_created(profiledir):
-    """
-    On profile creation, this copies *-prefs.js from the current folder to
-    profile_dir as a user.js file. These user prefs is interpreted in addition
-    to the standard prefs.js file.
-    """
-    # The pref file is in the same directory this script is in
-    preffile = os.path.join(os.path.dirname(__file__), "prefs.js")
-    shutil.copy(preffile, os.path.join(profiledir, "user.js"))
+PREFS = {
+    "mail.provider.enabled": False,
+}