manifest-sandbox.rst (4387B)
1 Adding Context to ``manifestparser`` based Manifests 2 ---------------------------------------------------- 3 4 Suites that use ``manifestparser``, like Mochitest and XPCShell, have test 5 manifests that denote whether a given test should be skipped or not based 6 on a set of context. 7 8 Gecko builds generate a ``target.mozinfo.json`` with metadata about the build. 9 An example ``target.mozinfo.json`` might look like :download:`this 10 <target.mozinfo.json>`. These keys can then be used ``skip-if`` in test manifests: 11 12 .. code-block:: 13 14 skip-if = e10s && os == 'win' 15 16 In this case, ``e10s`` is a boolean. 17 18 The test will download the build's ``target.mozinfo.json``, then update the 19 mozinfo dictionary with additional runtime information based on the task or 20 runtime environment. This logic lives in `mozinfo 21 <https://hg.mozilla.org/mozilla-central/file/default/testing/mozbase/mozinfo/mozinfo/mozinfo.py>`__. 22 23 How to Add a Keyword 24 ~~~~~~~~~~~~~~~~~~~~ 25 26 Where to add the new key depends on what type of information it is. 27 28 1. If the key is a property of the build, you'll need to patch `this file 29 <https://searchfox.org/mozilla-central/source/python/mozbuild/mozbuild/mozinfo.py>`_. 30 2. If the key is a property of the test environment, you'll need to patch 31 `mozinfo <https://firefox-source-docs.mozilla.org/mozbase/mozinfo.html>`_. 32 3. If the key is a runtime configuration, for example based on a pref that is 33 passed in via mach or the task configuration, then you'll need to update the 34 individual test harnesses. For example, `this location 35 <https://searchfox.org/mozilla-central/rev/a7e33b7f61e7729e2b1051d2a7a27799f11a5de6/testing/mochitest/runtests.py#3341>`_ 36 for Mochitest. Currently there is no shared location to set runtime keys 37 across test harnesses. 38 39 Adding a Context to Reftest Style Manifests 40 ------------------------------------------- 41 42 Reftests and Crashtests use a different kind of manifest, but the general idea 43 is the same. 44 45 As before, Gecko builds generate a ``target.mozinfo.json`` with metadata about 46 the build. An example ``target.mozinfo.json`` might look like :download:`this 47 <target.mozinfo.json>`. This is consumed in the Reftest harness and translated 48 into keywords that can be used like: 49 50 .. code-block:: 51 52 fuzzyIf(cocoaWidget&&isDebugBuild,1-1,85-88) 53 54 In this case, ``cocoaWidget`` and ``isDebugbuild`` are booleans. 55 56 The test will download the build's ``target.mozinfo.json``, then in addition to 57 the mozinfo, will query runtime info from the browser to build a sandbox of 58 keywords. This logic lives in `manifest.sys.mjs 59 <https://searchfox.org/mozilla-central/source/layout/tools/reftest/manifest.sys.mjs#439>`__. 60 61 How to Add a Keyword 62 ~~~~~~~~~~~~~~~~~~~~ 63 64 Where to add the new key depends on what type of information it is. 65 66 1. If the key is a property of the build, you'll need to patch `this file 67 <https://searchfox.org/mozilla-central/source/python/mozbuild/mozbuild/mozinfo.py>`_. 68 2. If the key is a property of the test environment or a runtime configuration, 69 then you'll need need to update manifest sandbox. 70 71 For example, for Apple Silicon, we can add an ``apple_silicon`` keyword with a 72 patch like this: 73 74 .. code-block:: diff 75 76 --- a/layout/tools/reftest/manifest.sys.mjs 77 +++ b/layout/tools/reftest/manifest.sys.mjs 78 @@ -572,16 +572,18 @@ function BuildConditionSandbox(aURL) { 79 80 // Set OSX to be the Mac OS X version, as an integer, or undefined 81 // for other platforms. The integer is formed by 100 times the 82 // major version plus the minor version, so 1006 for 10.6, 1010 for 83 // 10.10, etc. 84 var osxmatch = /Mac OS X (\d+).(\d+)$/.exec(hh.oscpu); 85 sandbox.OSX = osxmatch ? parseInt(osxmatch[1]) * 100 + parseInt(osxmatch[2]) : undefined; 86 87 + sandbox.apple_silicon = sandbox.cocoaWidget && sandbox.OSX>=11; 88 + 89 // Plugins are no longer supported. Don't try to use TestPlugin. 90 sandbox.haveTestPlugin = false; 91 92 // Set a flag on sandbox if the windows default theme is active 93 sandbox.windowsDefaultTheme = g.containingWindow.matchMedia("(-moz-windows-default-theme)").matches; 94 95 try { 96 sandbox.nativeThemePref = !prefs.getBoolPref("widget.disable-native-theme-for-content"); 97 98 99 Then to use this: 100 101 .. code-block:: 102 103 fuzzy-if(apple_silicon,1-1,281-281) == frame_above_rules_none.html frame_above_rules_none_ref.html