Name Description Size Coverage
contrast.py 23446 -
pair_walk.py List the foregrounds that leave their background's system-color pair. For each --state, locks the pseudo-classes on the --element through InspectorUtils, which chrome and a system-principal page (e.g. about:preferences) expose and an ordinary web page does not; :hover and :active also lock on every flat-tree ancestor, as a real pointer sets them, as contrast.py does. It finishes the transitions the lock starts, then walks the element and its visible descendants. For each one it finds the surface behind it (the nearest ancestor-or-self with a background, else the canvas as Canvas), maps that background to the system colors it equals, resolved inside the subject so its color-scheme applies, and checks the element's text color (`-webkit-text-fill-color`, which paints the glyphs over `color`), an image's fill, an SVG's stroke, and its border and outline colors against the foregrounds that pair allows. A value outside the pair is a finding. A surface that is translucent or equals no system color is listed as not judged, since a pair check means nothing there. Text means a direct text-node child, the value of an input or textarea, and the `value` of a XUL label or description. Other generated content (`::before`, `::after`, `::marker`), `::placeholder`, `::selection`, text decorations, shadows, the caret and the pixels of a raster image or canvas are not checked. `-moz-context-properties` does not read back from getComputedStyle, so every image (an img, a background-image, a list-style-image) has its fill checked; an image that ignores fill, such as a favicon, can show up as a false finding. Launches through probelib.py, headless, on a throwaway profile, in the high contrast regime unless you pass other prefs: ./mach python --virtualenv wpt pair-walk.py --binary <objdir>/dist/bin/firefox \\ --setup-file open-urlbar.js --element '.urlbarView-row[type=history]' \\ --state default --state :hover On macOS the binary is <objdir>/dist/*.app/Contents/MacOS/firefox. Off Windows those prefs give chrome prefers-contrast, not forced colors; a --setup-file with `window.browsingContext.forcedColorsOverride = "active";` puts the window's chrome under the filter, and adding `document.documentElement.style.setProperty("forced-color-adjust", "none");` approximates Windows chrome, where the filter does not run. --setup-file holds the body of an async function run in the same context first, to bring the UI into the state under test (populate a view, open a panel, toggle an attribute state). It may set globalThis.pairWalkSubjects to an array of elements instead of passing --element. The launch flags, --url, --window-size, --chrome-setup* and --steps work as in firefox-probe.py. --element takes `host >>> inner` to reach into a shadow root, one `>>>` per boundary. The walk judges colors only: it does not read `opacity`, so a state that fades instead of switching pairs walks clean. Read it computed. stdout is the JSON result; the mozversion lines go to stderr, so keep the two streams apart (`2>/dev/null`, or `2>file`) before parsing. A throw in the setup or the walk exits 1 with its message and stack and prints no JSON. The exit status is also 1 when the result has an error: no subject, a --surface that matches nothing, or a state that cannot be locked (any pseudo-class where InspectorUtils is missing, as on an ordinary web page in --context content, or a name InspectorUtils does not know); and when an entry judged nothing (`checked: 0`, with a `warning`): no foreground sat on a surface that equals a system color, which in Linux or macOS chrome usually means the chrome is not under forced colors (the setup above). A border whose authored color is transparent but which paints under forced colors is a finding (a spacer border reverts to the element color; the authored colors are read with `forced-color-adjust: none` set temporarily on each element). A border equal to its own surface is listed under `invisibleBorders`, not judged against the pair. --print-js prints the probe as an `async () => {...}` function for the devtools MCP's evaluate_privileged_script (or evaluate_script in content, where a state other than default needs InspectorUtils, so a system-principal page) and exits; pass the setup to it the same way. The surface is the nearest ancestor with a background. Where a positioned sibling paints it instead, the walk climbs past it to an outer ancestor; --surface names the element to use once the walk leaves the subject. It takes `>>>` like --element. 18665 -
pixel_diff.py Count the pixels that differ between two captures and print their bounding box. Run under `./mach python --virtualenv wpt`, the mach virtualenv with Pillow (plain `./mach python` does not): ./mach python --virtualenv wpt pixel-diff.py after.png before.png [--rect X,Y,W,H] Like cmp, it exits 0 when no pixels differ, 1 when some do and 2 on an error. A pixel differs when any one channel, alpha included, differs by more than --threshold (default 20, out of 255; 0 counts every difference), so a hue shift counts as much as a brightness one. --rect confines the count and the bounding box to a rect in CSS px measured from the PNG's own top-left corner, not the window's: for a capture.js frame, subtract the SHOT line's origin= from a window rect. --dpr scales the rect to device pixels and --offset shifts it by X,Y CSS px, the page's mozInnerScreenX/Y when the captures are screen grabs rather than page screenshots. The rect covers every device pixel it touches, and is clipped to the image. The printed bbox is (left, top, right, bottom) in device pixels of the whole image, the rect's position and --offset included. Two captures of different sizes differ in every pixel only one of them has. A screen grab includes the browser chrome, so a hit at the window's bottom edge may be the link-target status panel. --lines N also prints the device-pixel rows and columns holding at least N differing pixels, merged into runs, and the most common color pairs among the differing pixels as png -> other, so a 1px border change reads as "row 84" with its before and after colors. 8159 -
probelib.py Launch a Firefox build under Marionette for the probe scripts. Not a command. `contrast.py` and `pair_walk.py` beside it import it, and so do `desktop-theme-probing`'s `firefox-probe.py` and `marker-probe.py`: `add_launch_arguments()` gives a parser the launch flags, and `run(args, prog, body)` launches the binary, verifies the prefs, calls `body(client)` and tears the browser down, returning the process exit code. `add_page_arguments()` adds the flags that bring the window to the state under test (--url, --window-size, --settle, --chrome-setup*, --steps), `open_page()` and `run_steps()` act on them, and `evaluate()` runs a snippet, wrapping an async body as `--async` describes. `PRELUDE` is JS the state-locking probes share. Exit codes: 0 on success; 1 when `body` raised (a JS error or timeout is printed without the driver's traceback); 2 when `--binary` is not an executable file, the browser did not come up, `--port` is taken (the holder is named, never killed) or a `--setpref` did not take; 3 when the run otherwise succeeded but quitting the browser or removing its profile failed; 128 plus the signal number when SIGINT, SIGTERM or SIGHUP stopped the run, after the browser was torn down. `--setpref name=value` is named and typed as mochitest's (mozprofile's `Preferences.cast`): true/false and integers by shape, a single-quoted value as the string inside the quotes, anything else as a string. A user.js value of another type than the pref's own is dropped without a word, and the application rewrites some prefs at startup, so every pref is read back after startup and a mismatch is exit 2 with a message naming which happened, or a warning under `--allow-dropped-pref`. 35982 -
screen-grab.py Grab the screen to a PNG and print its pixel size as "W H". What the compositor put on screen, not a fresh paint: a Marionette or `--screenshot` capture re-renders the page by default (Marionette reads back the widget's layers only under `remote.screenshot.use_readback`), so a retained-display-list or compositor paint bug is invisible to it and visible here. firefox-probe.py's `grab` step runs it; you never call it directly. It grabs with Pillow's ImageGrab under the interpreter that runs firefox-probe.py (`./mach python --virtualenv wpt`, which pins Pillow). screen-grab.py out.png [--crop X,Y,W,H] [--any-display] --crop takes four integers in screen pixels; write a negative X or Y as `--crop=-1920,0,800,600`, since argparse reads a bare `-1920,...` as a flag. Linux: it grabs the X root window of $DISPLAY, and refuses unless the X server owning that display (the PID in /tmp/.X<n>-lock) is Xvfb, since any other server is usually the user's live desktop; --any-display skips that check for an isolated server of another kind. Run it inside a private display: env -u WAYLAND_DISPLAY GDK_BACKEND=x11 MOZ_ENABLE_WAYLAND=0 \ xvfb-run -a -s "-screen 0 1600x1000x24" <driver that calls this> A crop must lie inside the root window. macOS: it grabs the logged-in desktop. A grab without --crop covers the main display in device pixels (2x on Retina), and all_screens has no effect there. A --crop is in points, and Pillow returns the cropped region at 1x, so a Retina crop is downsampled. Without the Screen Recording permission for the terminal the grab returns the wallpaper alone, with no windows, and still exits 0. Windows: it grabs every screen. An uncropped grab's (0, 0) is the virtual desktop's top-left corner, so when a monitor sits left of or above the primary one, screen coordinates (mozInnerScreenX/Y included) are offset from PNG coordinates by that monitor's extent. The page's content origin on that screen is `mozInnerScreenX/Y` (read it from the page) in CSS pixels; desktop-theme-screenshots' pixel-diff.py takes it unscaled as `--offset X,Y` together with `--dpr`, and scales both itself. 5350 -
token_resolve.py 30035 -