Skip to navigation

Sessions and surfaces, written as tests

Each example shows one procedure as prose, as detected tests, as inline tests, and as a standalone spec. For what each tab holds, see Navigation and interaction.

In a detected variant, a step statement holds each step that default detection can’t produce, such as saveCookie or startSurface. Each of those statements also works on its own, because a run with detection off reads only the statements.

The permutation sections, from saveCookie and loadCookie permutations on, vary one setting each. A Varies line names the setting, its value, and its effect.

This procedure uses saveCookie and loadCookie in their name, file path, and object forms, with goTo and find.

prose.md
# Keep a session cookie
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_demo/signed-in). The server sets the `sessions_demo` cookie.
2. Save the `sessions_demo` cookie four ways. Save it to the `sessions_demo` and `SESSIONS_DEMO_COOKIE` environment variables, and to `sessions_demo.txt` in the output folder. Save it to `sessions_demo.txt` in a `tmp` folder next to this file, keeping only the `localhost` cookie.
3. Go to [the sign-out page](http://localhost:8092/cookies/set/sessions_demo/signed-out), which replaces the cookie.
4. Load the cookie from `sessions_demo.txt` in the output folder.
5. Go to [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_demo=signed-in**.
6. Go to [the sign-out page](http://localhost:8092/cookies/set/sessions_demo/signed-out) again, and load the cookie from the `SESSIONS_DEMO_COOKIE` environment variable.
7. Go to [the cookie report](http://localhost:8092/cookies) again, and check that it shows **sessions_demo=signed-in**.
8. Go to [the sign-out page](http://localhost:8092/cookies/set/sessions_demo/signed-out) once more, and load the `localhost` cookie from `tmp/sessions_demo.txt`.
9. Go to [the cookie report](http://localhost:8092/cookies) a last time, and check that it shows **sessions_demo=signed-in**.

Forms in this example

StepWhat it does
"saveCookie": "sessions_demo"Saves the cookie to the sessions_demo environment variable.
"saveCookie": { "name", "variable" }Saves the cookie to the environment variable that variable names.
"saveCookie": { "name", "path", "overwrite" }Saves the cookie to a file in outputDir, replacing an earlier file.
"saveCookie": { "name", "path", "directory", "domain", "overwrite" }Saves only the cookie for domain to a file in directory. A relative directory resolves against the file that holds the test.
"loadCookie": "sessions_demo.txt"Loads the cookie named for the file from outputDir.
"loadCookie": { "name", "variable" }Loads the cookie from an environment variable.
"loadCookie": { "name", "path", "directory", "domain" }Loads the cookie for domain from a file in directory.

"loadCookie": "sessions_demo", a bare cookie name, loads from the environment variable of that name.

Config for the detected run

The detected variants run with this example’s own config, which sets contexts for every test that has no runOn of its own. Here, browsers is an array of browser names, so the test runs in Firefox and then in Chrome:

doc-detective.json
{
"detectSteps": true,
"runOn": [
{
"platforms": ["linux", "mac", "windows"],
"browsers": ["firefox", "chrome"]
}
],
"browserFallback": "explicit",
"retries": 1
}

browserFallback set to explicit falls back to another browser only for a context whose browser Doc Detective picked itself. retries re-runs a context once on a fresh session when its session breaks mid-run. A context’s own browserFallback and retries override these. See config.

What detection finds

Each link becomes a checkLink step, and each link after “Go to” also becomes a goTo step. The bold sessions_demo=signed-in becomes a find step. The first link comes after Sign in at, which isn’t a navigation verb, so detection only checks it, and a goTo statement opens it. No default rule produces saveCookie or loadCookie, so those are statements in every detected variant.

Reuse a signed-in browser state in two browsers

This procedure uses saveState and loadState in their object and string forms, and runs in two contexts: headless Firefox with a set window and viewport, and headless Chrome.

prose.md
# Reuse a signed-in browser state
Run these steps in Firefox and in Chrome.
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_state/signed-in). The server sets the `sessions_state` cookie.
2. Save the browser state to `sessions-state.json` in the output folder, and to `sessions-state.json` in a `tmp` folder next to this file.
3. Go to [the sign-out page](http://localhost:8092/cookies/set/sessions_state/signed-out), which replaces the cookie.
4. Load the browser state from `sessions-state.json` in the output folder.
5. Go to [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_state=signed-in**.
6. Go to [the sign-out page](http://localhost:8092/cookies/set/sessions_state/signed-out) again, and load the browser state from `tmp/sessions-state.json`.
7. Go to [the cookie report](http://localhost:8092/cookies) again, and check that it shows **sessions_state=signed-in**.

Where the contexts live

The test statement carries runOn in the detected and inline variants, so it applies to that test. The standalone specs set runOn on the spec, where it applies to every test in the file. A test’s own runOn overrides the spec’s. Both shapes resolve to the same two contexts here.

The Firefox context sets browserFallback to off, so a run without a working Firefox skips that context rather than running it in another browser. It also sets retries to 2, so a session that breaks mid-run gets two fresh attempts.

The platforms that don’t match the host report SKIPPED, never FAIL.

Forms in this example

  • saveState with path and overwrite writes to outputDir. Adding directory writes next to the file that holds the test instead.
  • loadState takes a path in outputDir as a string, or an object with path and directory.
  • The string form of saveState, such as "saveState": "sessions-state.json", never overwrites a file, so a second run into the same outputDir fails. Use the object form with overwrite for a test that runs more than once.

What detection finds

As in the cookie example, each link becomes a checkLink step, the “Go to” links also become goTo steps, and the bold text becomes a find step. saveState and loadState are statements.

Compare pages in tabs, windows, and sessions

This procedure uses goTo with newTab, newWindow, and surface, startSurface with an array of browser descriptors, find and type with a browser surface, and closeSurface with an array of surfaces.

prose.md
# Compare pages in tabs, windows, and sessions
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Click the Open child in new tab link. The child page opens in a new tab.
3. In the newest tab, check that the page reads "PAGE linked".
4. In a new tab named `report`, load [the report page](http://localhost:8092/multi-tab-child.html?page=report). Then load [the scratch page](http://localhost:8092/multi-tab-child.html?page=scratch) in another new tab.
5. Check that the `report` tab reads "PAGE report", and that the tab showing the scratch page reads "PAGE scratch".
6. In a new window named `settings`, with its first tab named `general`, load [the settings page](http://localhost:8092/multi-tab-child.html?page=settings). Then load [the help page](http://localhost:8092/multi-tab-child.html?page=help) in another new window.
7. Check that the `settings` window and its `general` tab read "PAGE settings", and that the newest window, titled "Child help", reads "PAGE help".
8. In the first window, check that the tab titled "Multi-tab home" still reads "MULTI-TAB HOME".
9. Type `hello` in the echo box of the help window, which is also the newest window, and of the child tab, the second tab opened.
10. Load [the notes page](http://localhost:8092/multi-tab-child.html?page=notes) in a new tab named `notes`, and [the about page](http://localhost:8092/multi-tab-child.html?page=about) in a new window named `about`. Check that each one reads its page name.
11. Start two more Firefox sessions: `reviewer`, with an 800 by 600 viewport, and `editor`, with a 1024 by 768 window. Load [the review page](http://localhost:8092/multi-tab-child.html?page=review) in `reviewer`.
12. In the first session, go back to [the multi-tab page](http://localhost:8092/multi-tab.html), and check that it reads "MULTI-TAB HOME".
13. Close the `report` and `notes` tabs, the scratch tab, the child tab, the help, `settings`, and `about` windows, and the `reviewer` and `editor` sessions.

Opening tabs, windows, and sessions

StepOpens
"newTab": { "name": "report" }, "newTab": "notes"A tab with that name.
"newTab": trueA tab with no name.
"newWindow": { "name": "settings", "tab": "general" }A window named settings, with its first tab named general.
"newWindow": "about"A window with that name.
"newWindow": trueA window with no name.
"startSurface": [ … ]Each browser session in the array: reviewer with a set viewport, and editor with a set window size.

Selecting a surface

A window or tab selector takes a number, a name, or an object.

SelectorPicks
"tab": 1, "tab": { "index": 1 }The tab at that position in creation order.
"tab": { "index": -1 }, "window": -1, "window": { "index": -1 }The newest tab or window.
"window": { "index": 0 }The first window.
"tab": "report", "tab": { "name": "report" }The tab with that name.
"window": "settings", "window": { "name": "settings" }The window with that name.
"tab": { "title": "…" }, "window": { "title": "…" }The tab or window whose title matches.
"tab": { "url": "…" }, "window": { "url": "…" }The tab or window whose URL matches.
"firefox"The default Firefox session, by engine name.
{ "browser": "firefox", "name": "reviewer" }, "reviewer"The session that startSurface named.

Browser surface selectors name the engine, so the test pins its context to headless Firefox with browserFallback set to off. Without Firefox, the test skips rather than addressing an engine that isn’t running.

What detection finds

Each link becomes a checkLink step. None of the links follows a navigation verb, so detection opens no pages, and statements hold every navigation, click, and surface step.

Check what the page sees in an emulated browser

This procedure runs in one context, named with contextId, whose Chrome browser sets colorScheme, locale, timezone, deviceScaleFactor, reducedMotion, and clock. runBrowserScript steps read each setting back from the page.

prose.md
# Check what the page sees in an emulated browser
Run these steps in headless Chrome set to dark mode, German, Berlin time, a 2x display, reduced motion, and a fixed clock.
1. Start at [the test site's home page](http://localhost:8092/index.html).
2. Check that the page prefers the dark color scheme and reduced motion.
3. Check that the page's language is `de-DE` and its time zone is `Europe/Berlin`.
4. Check that the device pixel ratio is `2`, and that the clock reads December 3, 2026, 09:00 UTC.

Chrome sets every one of these keys. Firefox sets all but timezone and clock, and skips a context that asks for either. See Platforms and browsers.

What detection finds

The only link comes after Start at, which isn’t a navigation verb, so detection adds a checkLink step, and a goTo statement opens the page.

Test pages on your own site

This procedure gives goTo paths rather than full URLs. The config’s origin supplies the scheme and host, and originParams adds query parameters to each URL it builds.

prose.md
# Test pages on your own site
These steps use paths, not full URLs. The run's config sets the site's origin.
1. Go to `/cookies/set/sessions_origin/visited`.
2. Go to `/cookies`, and check that the page shows `sessions_origin=visited`.
3. Go to `/api/echo`, and check that the response echoes the `from` parameter that the config adds: `"from":"docs"`.

This example’s config

The example’s folder holds a doc-detective.json and the sessions.env file it loads:

doc-detective.json
{
"detectSteps": true,
"loadVariables": "sessions.env",
"origin": "$SESSIONS_ORIGIN",
"originParams": {
"from": "docs"
}
}
sessions.env
SESSIONS_ORIGIN=http://localhost:8092

loadVariables resolves against the config file’s folder, and origin reads the variable the file sets. The /api/echo endpoint returns the query parameters it gets, so the last check passes only when the config adds from=docs.

The test’s context requires the SESSIONS_ORIGIN variable. A run with another config, which can’t resolve the paths, skips the test rather than failing it.

What detection finds

The paths are code, not links, so detection adds no steps. Statements hold every step.

Evaluate expressions in the Node.js REPL

One procedure starts a process with runShell and background. The others use startSurface with a process descriptor (one of them passes an array of descriptors). Each then sends keys with type to a process surface and closes it with closeSurface. The contexts use requires to skip a test where node isn’t installed.

prose.md
# Evaluate expressions in the Node.js REPL
## Start the REPL as a surface
1. Start `node -i` in a terminal as a process named `sessions-repl`, and wait for the `>` prompt.
2. In the REPL, enter `40 + 2` and press Enter. Wait for the REPL to print `42`.
3. Close the REPL.
## Run the REPL in the background
1. Run `node -i` in the background as a process named `sessions-bg-repl`, and wait for the `>` prompt.
2. In the REPL, enter `Math.pow(2, 10)` and press Enter. Wait at least half a second, and until the REPL prints `1024`.
3. Close the REPL.
## Start a server and a REPL together
1. From the `docs/actions` folder, start `node simple-json-server.cjs` as `sessions-api`, and wait until port `8087` answers. At the same time, start `node -i` in a 100 by 30 terminal as `sessions-client`, and give it a second to start.
2. In the REPL, fetch the server's root URL, and wait for it to print `ok`.
3. Close the REPL and the server.

Forms in this example

  • requires takes a command name ("node"), an array of command names (["node", "npm"]), or an object that lists commands, files, and env variables.
  • tty runs the process in a terminal: true for the default 120 by 30 size, or an object with cols and rows.
  • waitUntil holds the step until the process prints a match (stdio), a port accepts connections, an httpGet URL answers, or delayMs passes. Conditions in one object must all hold.
  • workingDirectory sets where the process starts. A relative path resolves against the file that holds the test.
  • type and closeSurface address a process by its name ("sessions-repl") or with the object form ({ "process": "sessions-bg-repl" }).

What detection finds

The prose has no links, bold text, or quoted text after Type, so detection adds no steps. Code spans aren’t detected, which keeps 40 + 2 from turning into a type step without a surface.

Open a built-in app

These procedures use startSurface with an app descriptor, click, find, and closeSurface with an app surface, on Windows, macOS, Android, and iOS. Each test’s runOn names one platform.

prose.md
# Open a built-in app
## Windows: Character Map
1. Open Character Map, and wait for its Select button.
2. Click **Select**.
3. Check that the window shows the **Copy** button.
4. Check the Copy button again, picking the window by its title, by name, and as the newest window.
5. Close Character Map.
## macOS: Calculator
1. Open Calculator with `SESSIONS_DOCS=1` in its environment, and wait for its `1` button.
2. In the first window, press the `1` button.
3. Close Calculator.
## Android: Settings
1. Open the Settings app, and wait for the Network & internet entry.
2. Tap the Network & internet entry.
3. Check that the screen shows **Internet**.
4. Close the Settings app.
## Android: your own app
1. Install `build/sessions-demo.apk` on a headless Android 14 phone emulator named `sessions-pixel`, open its main activity, and wait for the Welcome screen.
2. Close the app.
## iOS: Settings
1. On the iPhone simulator named `sessions-iphone`, open the Settings app, and wait for the General entry.
2. Tap the General entry.
3. Check that the screen shows **About**.
4. Close the Settings app.

Where each test runs

TestRuns onElsewhere
Character MapWindowsSKIPPED
CalculatormacOS, with Accessibility permission for the process that runs Doc DetectiveSKIPPED
Android SettingsA host with the Android toolchain (doc-detective install android)SKIPPED
Your own Android appA host with the Android toolchain and the app’s build/sessions-demo.apkSKIPPED
iOS SettingsmacOS with Xcode and Simulator toolingSKIPPED

The Android app test needs your own app, so its context requires the APK file and skips without it.

For setup on each platform, see the native app guides, starting with Native Windows apps.

Forms in this example

  • An app window selector takes a title as a string, { "title" } or { "name" } criteria, -1 or { "index": -1 } for the newest window, or a position such as { "index": 0 }. Positions from the start work on macOS only.
  • env sets environment variables for a macOS app.
  • install, activity, and driverOptions install an Android app, open one of its activities, and pass options to the automation driver.
  • device on startSurface names the device as a string, or describes it as a device descriptor with platform, name, deviceType, osVersion, and headless. The context’s own device takes the same two forms and sets the default for the context.

What detection finds

On Windows, Click **Select** becomes a click step and a find step for Select, and the bold Copy, Internet, and About become find steps. The mobile procedures say Tap, and a statement holds that click, because after the tap the screen no longer shows the entry’s label. A detected find for the label would fail.

In DITA, <uicontrol> marks the control to click, as in Navigation and interaction.

saveCookie and loadCookie permutations

"saveCookie": "<name>"

Varies: saveCookie and loadCookie · Value: "sessions_pname" · Effect: a bare cookie name saves the cookie to, and loads it from, the environment variable of the same name.

prose.md
# Keep a cookie in an environment variable
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pname/signed-in). The server sets the `sessions_pname` cookie.
2. Save the `sessions_pname` cookie to the `sessions_pname` environment variable.
3. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pname/signed-out), which replaces the cookie.
4. Load the cookie from the `sessions_pname` environment variable.
5. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pname=signed-in**.

"saveCookie": "<name>.txt"

Varies: saveCookie and loadCookie · Value: "sessions_ptxt.txt" · Effect: a path ending in .txt saves the cookie named for the file to that file in outputDir, and never overwrites one that exists.

prose.md
# Keep a cookie in a file
1. Delete any `sessions_ptxt.txt` that an earlier run left in the output folder.
2. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_ptxt/signed-in). The server sets the `sessions_ptxt` cookie.
3. Save the `sessions_ptxt` cookie to `sessions_ptxt.txt`.
4. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_ptxt/signed-out), which replaces the cookie.
5. Load the cookie from `sessions_ptxt.txt`.
6. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_ptxt=signed-in**.

"overwrite": true

Varies: saveCookie.overwrite · Value: true · Effect: a second save to the same file replaces it, so the later value wins.

prose.md
# Replace a saved cookie
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pover/first). The server sets the `sessions_pover` cookie.
2. Save the `sessions_pover` cookie to `sessions_pover.txt`, replacing any earlier file.
3. Sign in again at [the second sign-in page](http://localhost:8092/cookies/set/sessions_pover/second), and save the cookie to the same file.
4. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pover/signed-out), which replaces the cookie.
5. Load the cookie from `sessions_pover.txt`.
6. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pover=second**.

"domain": "localhost"

Varies: saveCookie.domain and loadCookie.domain · Value: "localhost" · Effect: saves and loads only the cookie set for that domain.

prose.md
# Keep the cookie for one domain
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pdomain/signed-in). The server sets the `sessions_pdomain` cookie.
2. Save the `localhost` cookie named `sessions_pdomain` to `sessions_pdomain.txt`.
3. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pdomain/signed-out), which replaces the cookie.
4. Load the `localhost` cookie from `sessions_pdomain.txt`.
5. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pdomain=signed-in**.

"variable": "SESSIONS_PVAR"

Varies: saveCookie.variable and loadCookie.variable · Value: "SESSIONS_PVAR" · Effect: the cookie goes to an environment variable whose name differs from the cookie’s.

prose.md
# Keep a cookie in a named variable
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pvar/signed-in). The server sets the `sessions_pvar` cookie.
2. Save the `sessions_pvar` cookie to the `SESSIONS_PVAR` environment variable.
3. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pvar/signed-out), which replaces the cookie.
4. Load the cookie from `SESSIONS_PVAR`.
5. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pvar=signed-in**.

saveState and loadState permutations

"saveState": "<file>.json"

Varies: saveState and loadState · Value: "sessions-pstate.json" · Effect: the string form saves to and loads from outputDir, and the save never overwrites a file that exists.

prose.md
# Keep the browser state in a file
1. Delete any `sessions-pstate.json` that an earlier run left in the output folder.
2. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pstate/signed-in). The server sets the `sessions_pstate` cookie.
3. Save the browser state to `sessions-pstate.json`.
4. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pstate/signed-out), which replaces the cookie.
5. Load the browser state from `sessions-pstate.json`.
6. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pstate=signed-in**.

"overwrite": true

Varies: saveState.overwrite · Value: true · Effect: the object form with overwrite replaces an earlier file, so the test can run again into the same outputDir.

prose.md
# Replace a saved browser state
1. Sign in at [the sign-in page](http://localhost:8092/cookies/set/sessions_pstateo/signed-in). The server sets the `sessions_pstateo` cookie.
2. Save the browser state to `sessions-pstateo.json`, replacing any earlier file.
3. Sign out at [the sign-out page](http://localhost:8092/cookies/set/sessions_pstateo/signed-out), which replaces the cookie.
4. Load the browser state from `sessions-pstateo.json`.
5. Open [the cookie report](http://localhost:8092/cookies), and check that it shows **sessions_pstateo=signed-in**.

runOn platforms permutations

"platforms": "windows"

Varies: runOn[].platforms · Value: "windows" · Effect: the test runs on Windows and reports SKIPPED on every other platform.

prose.md
# Check the page on Windows
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

"platforms": ["linux", "mac"]

Varies: runOn[].platforms · Value: ["linux", "mac"] · Effect: an array runs the test on each listed platform the host matches, and skips the rest.

prose.md
# Check the page on Linux and macOS
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

runOn browsers permutations

"browsers": "firefox"

Varies: runOn[].browsers · Value: "firefox" · Effect: a browser name runs the test in that browser, headless by default.

prose.md
# Check the page in Firefox
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

"browsers": ["firefox", "chrome"]

Varies: runOn[].browsers · Value: ["firefox", "chrome"] · Effect: an array runs the whole test once per browser.

prose.md
# Check the page in Firefox and Chrome
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

"headless": false

Varies: runOn[].browsers.headless · Value: false · Effect: the browser opens a visible window, so the context runs only where there’s a display, here Windows and macOS.

prose.md
# Watch the check in a visible Chrome window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

runOn browser option permutations

"colorScheme": "dark"

Varies: runOn[].browsers.colorScheme · Value: "dark" · Effect: the page’s prefers-color-scheme media query matches dark.

prose.md
# Check the page in dark mode
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page prefers the dark color scheme.

"locale": "de-DE"

Varies: runOn[].browsers.locale · Value: "de-DE" · Effect: navigator.language and Intl formatting use German.

prose.md
# Check the page in German
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page's language is `de-DE`.

"timezone": "Europe/Berlin"

Varies: runOn[].browsers.timezone · Value: "Europe/Berlin" · Effect: Date and Intl use Berlin time.

prose.md
# Check the page on Berlin time
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page's time zone is `Europe/Berlin`.

"deviceScaleFactor": 2

Varies: runOn[].browsers.deviceScaleFactor · Value: 2 · Effect: devicePixelRatio is 2, as on a high-density display.

prose.md
# Check the page on a 2x display
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the device pixel ratio is `2`.

"reducedMotion": "reduce"

Varies: runOn[].browsers.reducedMotion · Value: "reduce" · Effect: the page’s prefers-reduced-motion media query matches reduce.

prose.md
# Check the page with reduced motion
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page prefers reduced motion.

"clock": "2026-12-03T09:00:00Z"

Varies: runOn[].browsers.clock · Value: "2026-12-03T09:00:00Z" · Effect: Date.now() and new Date() stay at that instant.

prose.md
# Check the page at a fixed time
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page's clock reads 3 December 2026, 09:00 UTC.

runOn matrix permutations

"matrix": { "locale": ["en-US", "de-DE"] }

Varies: runOn[].matrix · Value: { "locale": ["en-US", "de-DE"] } · Effect: runs the test once per locale. $$matrix.locale in the browser’s locale and in the step’s output becomes the value under test.

prose.md
# Check the page in two languages
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page's language is the locale under test, `en-US` or `de-DE`.

"deviceScaleFactor": "$$matrix.dpr"

Varies: runOn[].browsers.deviceScaleFactor · Value: "$$matrix.dpr", with "matrix": { "dpr": [1, 2] } · Effect: runs the test once per value, and devicePixelRatio is 1, then 2.

prose.md
# Check the page at two pixel densities
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the device pixel ratio is the density under test, `1` or `2`.

runOn requires permutations

"requires": "node"

Varies: runOn[].requires · Value: "node" · Effect: a command name must be on PATH, or the context is SKIPPED.

prose.md
# Check Node.js, if it's installed
1. Run `node --version`.

"requires": ["node", "npm"]

Varies: runOn[].requires · Value: ["node", "npm"] · Effect: every command in the array must be on PATH.

prose.md
# Check Node.js and npm, if both are installed
1. Run `node --version`.
2. Run `npm --version`.

"requires": { "commands": [...], "env": [...] }, unmet

Varies: runOn[].requires · Value: { "commands": ["sessions-missing-tool"], "env": ["PATH"] } · Effect: an object checks commands, files, and environment variables together, and one unmet entry skips the context instead of failing it.

prose.md
# Run a tool only where it's installed
1. Run `sessions-missing-tool --version`.

runOn browserFallback and retries permutations

"browserFallback": "auto"

Varies: runOn[].browserFallback · Value: "auto" · Effect: without a working Firefox, the context runs in another available browser and reports WARNING instead of PASS.

prose.md
# Check the page in Firefox
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

"browserFallback": "explicit" with "retries": 0

Varies: runOn[].browserFallback and runOn[].retries · Value: "explicit", 0 · Effect: without a working Firefox, the context is SKIPPED, because the test names Firefox. retries: 0 also turns off re-runs after a broken session.

prose.md
# Check the page in Firefox
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

"browserFallback": "off"

Varies: runOn[].browserFallback · Value: "off" · Effect: the context never falls back to another browser, and is SKIPPED without a working Firefox.

prose.md
# Check the page in Firefox
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Check that the page reads **MULTI-TAB HOME**.

goTo newTab and newWindow permutations

"newTab": true, "newWindow": true

Varies: goTo.newTab and goTo.newWindow · Value: true · Effect: each opens an unnamed tab or window and makes it active.

prose.md
# Open pages in a new tab and a new window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the tab page](http://localhost:8092/multi-tab-child.html?page=tab) in a new tab.
3. Check that the page reads "PAGE tab".
4. Load [the window page](http://localhost:8092/multi-tab-child.html?page=window) in a new window.
5. Check that the page reads "PAGE window".

"newTab": "notes", "newWindow": "about"

Varies: goTo.newTab and goTo.newWindow · Value: "notes", "about" · Effect: a string names the new tab or window, so later steps can select it by that name.

prose.md
# Open named tabs and windows
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the notes page](http://localhost:8092/multi-tab-child.html?page=notes) in a new tab named `notes`.
3. Check that the `notes` tab reads "PAGE notes".
4. Load [the about page](http://localhost:8092/multi-tab-child.html?page=about) in a new window named `about`.
5. Check that the new window reads "PAGE about".

"newTab": { "name" }, "newWindow": { "name", "tab" }

Varies: goTo.newTab and goTo.newWindow · Value: { "name": "report" }, { "name": "settings", "tab": "general" } · Effect: the object form names the tab, or names the window and its first tab.

prose.md
# Open a named window with a named tab
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the report page](http://localhost:8092/multi-tab-child.html?page=report) in a new tab named `report`.
3. Load [the settings page](http://localhost:8092/multi-tab-child.html?page=settings) in a new window named `settings`, with its first tab named `general`.
4. Check that the `general` tab of the `settings` window reads "PAGE settings".

Surface selector permutations

"tab": 0

Varies: surface.tab · Value: 0 · Effect: a number selects the tab at that position in creation order, and -1 selects the newest.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new tab named `second`.
3. Check that the selected page reads "MULTI-TAB HOME".

"tab": "second"

Varies: surface.tab · Value: "second" · Effect: a string selects the tab with that name.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new tab named `second`.
3. Check that the selected page reads "PAGE second".

"tab": { "index": -1 }

Varies: surface.tab.index · Value: -1 · Effect: the index key works like a number, so -1 selects the newest tab.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new tab named `second`.
3. Check that the selected page reads "PAGE second".

"tab": { "title": "Multi-tab home" }

Varies: surface.tab.title · Value: "Multi-tab home" · Effect: the title key selects the tab whose title matches.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new tab named `second`.
3. Check that the selected page reads "MULTI-TAB HOME".

"tab": { "url": "…" }

Varies: surface.tab.url · Value: "http://localhost:8092/multi-tab-child.html?page=second" · Effect: the url key selects the tab whose URL matches.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new tab named `second`.
3. Check that the selected page reads "PAGE second".

"window": -1

Varies: surface.window · Value: -1 · Effect: a number selects the window at that position in creation order, and -1 selects the newest.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new window named `second`.
3. Check that the selected page reads "PAGE second".

"window": { "name": "second" }

Varies: surface.window.name · Value: "second" · Effect: the name key, like a bare string, selects the window with that name.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new window named `second`.
3. Check that the selected page reads "PAGE second".

"window": { "title": "Child second" }

Varies: surface.window.title · Value: "Child second" · Effect: the title key selects the window whose active tab has that title.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Load [the second page](http://localhost:8092/multi-tab-child.html?page=second) in a new window named `second`.
3. Check that the selected page reads "PAGE second".

"window": 0, "tab": 1 on a tab the page opened

Varies: surface.window and surface.tab · Value: { "window": 0, "tab": 1 } · Effect: a tab that a link opens belongs to the window of the tab that opened it, so window and tab selectors together reach it.

prose.md
# Check a page in another tab or window
1. Start at [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Click the Open child in new tab link. The child page opens in a new tab.
3. In the first window, check that the second tab reads "PAGE linked".

startSurface and closeSurface permutations

Browser descriptor, closed by object

Varies: startSurface (browser descriptor) and closeSurface (object) · Value: { "browser": "firefox", "name": "reviewer" } · Effect: startSurface opens a second, named browser session, and closeSurface ends it by naming the engine and session.

prose.md
# Review a page in a second browser session
1. Start a headless Firefox session named `reviewer`.
2. In that session, load [the review page](http://localhost:8092/multi-tab-child.html?page=review).
3. Check that the page reads "PAGE review".
4. Close the `reviewer` session.

Process descriptor, closed by name

Varies: startSurface (process descriptor) and closeSurface (string) · Value: { "process": "node", "args": ["-i"], "name": "sessions-prepl" } · Effect: startSurface starts a process you can type into, and a bare name closes it.

prose.md
# Evaluate an expression in the Node.js REPL
1. Start `node -i` as a process named `sessions-prepl`, and wait for the `>` prompt.
2. In `sessions-prepl`, enter `40 + 2` and press Enter. Wait for the REPL to print `42`.
3. Close `sessions-prepl`.

Array of descriptors, closed by array

Varies: startSurface (array) and closeSurface (array) · Value: [{ "process": … }, { "process": … }] · Effect: an array starts every surface in one step, and an array closes several at once, by name or by object.

prose.md
# Compare two Node.js REPLs
1. Start two `node -i` processes, `sessions-pleft` and `sessions-pright`, and wait for both prompts.
2. In `sessions-pleft`, enter `40 + 2` and press Enter. Wait for the REPL to print `42`.
3. In `sessions-pright`, enter `6 * 7` and press Enter. Wait for the REPL to print `42`.
4. Close both REPLs.

Config origin and originParams permutations

"origin": "http://localhost:8092"

Varies: config.origin · Value: "http://localhost:8092" · Effect: steps can give a path, and the config supplies the scheme and host.

The example’s own doc-detective.json sets:

doc-detective.json
{
"origin": "http://localhost:8092"
}
prose.md
# Open a page by its path
1. Go to `/multi-tab.html` on the site.
2. Check that the page reads "MULTI-TAB HOME".

"originParams": { "from": "docs" }

Varies: config.originParams · Value: { "from": "docs" } · Effect: every URL built from origin gets the query parameters, so the echo endpoint returns from=docs.

The example’s own doc-detective.json sets:

doc-detective.json
{
"origin": "http://localhost:8092",
"originParams": {
"from": "docs"
}
}
prose.md
# Tag every request with a query parameter
1. Go to `/api/echo` on the site.
2. Check that the response echoes `"from":"docs"`.