Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ these entries stays in the GitHub releases and the Git history.
- The test helpers, `webfront_add_jasmine_test` included, export the real `XDG_DATA_HOME` and `XDG_CACHE_HOME` as `WEBFRONT_TEST_REAL_XDG_DATA_HOME` and `WEBFRONT_TEST_REAL_XDG_CACHE_HOME`, so an application under test can keep the throwaway WebKitGTK profile away from the programs it starts ([#664](https://github.com/ambroise-leclerc/WebFront/issues/664), `docs/CONSUMER_TESTING.md`).

### Changed
- Detach and attach an inspector panel with small icons, a frame with an arrow leaving it or entering it, instead of the **Detach** and **Attach** words; their tooltip and accessible name say the action, and a greyed detach icon still says why (#722, `docs/DEVELOPER_ENVIRONMENT.md`).
- `wf test` stopped at its time limit or by Ctrl+C says how far its runner got, in its message and in the report's new `stage`: the last step reached, the spec in progress, and the runner files that never finished loading (#690, `docs/DEVELOPER_ENVIRONMENT.md`).
- Destroying the handle of a watch (`inspect::Watch`) waits for an operation of the inspectors in progress on another thread: destroy it outside every lock its source takes, or declare the watch with the state it owns (#682, ADR-027, `docs/WATCHES.md`).
- `cppFunction` and `Space::cppFunction` take a last, defaulted `std::source_location`, which the inspectors show; existing calls compile unchanged, the explicit `cppFunction<R, Args...>` form included (#681, ADR-027).
Expand Down
15 changes: 9 additions & 6 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,17 @@ environment's `mount`, not to the embedded bootstrap page):
to C++ through the bridge. An entry of the menu opens its panel where the project keeps it: at first, and whenever its
detached container is unavailable, in a **floating window** of the page (moved and resized like the terminal's window,
with the mouse or with the arrow keys on its title bar), whose frame opens no connection of its own and borrows the page's
bridge, since the adapters give the proof of the view to the main frame only. **Detach** moves the panel to a window of its
own, and the next opening of that panel goes there again; **Attach**, in that window, brings it back to the floating
window, where it then opens. The containers follow the access each frontend actually gives, never its name alone:
bridge, since the adapters give the proof of the view to the main frame only. The **detach** icon of its title bar, a frame
with an arrow leaving to the top right (↗, tooltip "Detach this panel to a window of its own"), moves the panel to a
window of its own, and the next opening of that panel goes there again; the **attach** icon of that window's header, an
arrow entering a frame (↙, tooltip "Show this panel in the floating window of the main page"), brings it back to the
floating window, where it then opens. Both icons take the color of the text and carry their action as their accessible
name. The containers follow the access each frontend actually gives, never its name alone:

| Frontend of the page | Inspectors | Panel opens in | Detached container |
| --- | --- | --- | --- |
| WebKitGTK, WKWebView, WebView2 | admitted: the view proves itself | the floating window | a native secondary window (`webfront.inspector.openWindow`, `openSecondaryWindow`), which carries the proof of the view; opening the panel again brings it to the front, and closing the main window closes it |
| CEF | admitted: the view proves itself | the floating window | none: CEF opens no secondary window, and `window.open` there would open a frame without the proof; Detach is greyed, with the reason in its tooltip |
| CEF | admitted: the view proves itself | the floating window | none: CEF opens no secondary window, and `window.open` there would open a frame without the proof; the detach icon is greyed, with the reason in its tooltip |
| System browser (default of `webfront::WebFront`) | **refused by default**: the entries are greyed and say how to enable them | none | none |
| System browser with `trustLoopbackClients` | admitted: any loopback page | the floating window | a tab of the system browser (`window.open`), with its own loopback connection; when the pop-up blocker refuses it, the panel stays in the floating window and a message offers to try again; the tab closes when the page that opened it is gone |

Expand All @@ -475,10 +478,10 @@ environment's `mount`, not to the embedded bootstrap page):
Every loopback connection is then a local client: it reads the inspectors, and it also passes the `ui.isLocalClient()`
check of the application's own callbacks (below). The option is the application's choice; the environment never sets it.

Attach brings the panel back to the page that detached it only, even when other pages of the application are open on
The attach icon brings the panel back to the page that detached it only, even when other pages of the application are open on
the same origin. A page keeps its identifier across a reload through Web Locks; in a browser without them, a reloaded
page has a new one, and a tab detached before the reload asks the old page in vain: it says that the main page did not
answer. Close that tab, open the panel from the menu of the reloaded page, then use Attach in the window it opens. The project keeps the detached panels and the floating window's place in
answer. Close that tab, open the panel from the menu of the reloaded page, then use the attach icon in the window it opens. The project keeps the detached panels and the floating window's place in
`.webfront/developer/inspector-window.json`. A save that reaches C++ completes or releases its transaction there,
even when its page closes. A page closed before the save reaches C++ may lose its latest choice.
With a frontend that proves its view, developer file writes and starting or cancelling native terminal commands
Expand Down
6 changes: 3 additions & 3 deletions js/developer/environment/bundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"js/developer/environment/testing.mjs": "48695dc7c368d5f0671a0549a61d06c732e10604c56e98f7254f3c4dd21a792c",
"js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062",
"js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc",
"js/developer/environment/menu.mjs": "29535371e75ecbb5e402397cf47e0970b664b75d6c663d33915724f6a3fa3af8",
"js/developer/environment/inspector-host.mjs": "304a8a6713026939d66088dd0bb68a96ff4ee14e970c6886d61c82ebde611ac5",
"js/developer/environment/inspector.mjs": "44b6cd4443a3ed55a1bb188be96eafb64fc8b40b9a80500b3c47977740a6b336",
"js/developer/environment/menu.mjs": "a1703bf927058f8641b82c469335fd430a723880a336e16dfbd3a8296287b7fa",
"js/developer/environment/inspector-host.mjs": "4b48bd862cc369ba006990303393ca861e2164627013f464f00de9ac893777ea",
"js/developer/environment/inspector.mjs": "eaacc50bffa03a955324a9a3634a1d92afd1c7962bae88cb982b15cf047cb2b3",
"js/developer/environment/inspector-packages.mjs": "de7ee0bcd85df4eadb434e52bd571951eea3314eb1b0d1fd3ada52cf21a0b14c",
"js/developer/environment/inspector-registry.mjs": "bcc15ef9801ad9a60e377eaa26582febb05c472d5e9b9678ee8b5ec369a2a15e",
"js/developer/environment/inspector-watches.mjs": "d913f20f3b2d36788b6e2d831065a8cccbd242abc7a86d366e27533b91ee56e7",
Expand Down
8 changes: 5 additions & 3 deletions js/developer/environment/inspector-host.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// the floating window's place are kept in the project, as the terminal's place is.
import {readProject, call} from './io.mjs';
import {clampRect, step, minimumSize, windowControls} from './workspace.mjs';
import {inspectorPanels as panels, panelTitle, inspectorChannel} from './menu.mjs';
import {inspectorPanels as panels, panelTitle, inspectorChannel, inspectorMoves, makeMoveButton} from './menu.mjs';
import {createBridgeMonitor, createBridgePublisher} from './inspector-bridge.mjs';

const encoder = new TextEncoder();
Expand Down Expand Up @@ -199,6 +199,7 @@ const styles = `
.webfront-inspector-bar button:hover:not([aria-disabled=true]){background:#2f3a50}
.webfront-inspector-bar button[aria-disabled=true]{color:#8d97aa;cursor:default}
.webfront-inspector-close{font-size:20px!important;line-height:1}
.webfront-inspector-detach>svg{display:block;margin:auto;pointer-events:none}
.webfront-inspector-notice{display:flex;gap:8px;align-items:center;padding:6px 12px;background:#3a2f12;color:#f4e3b5;font:12px system-ui}
.webfront-inspector-notice[hidden]{display:none}
.webfront-inspector-notice button{margin:0 0 0 auto;padding:4px 8px;border:1px solid #f4e3b5;border-radius:4px;background:none;color:inherit;font:inherit;cursor:pointer}
Expand Down Expand Up @@ -290,7 +291,7 @@ export async function createInspectorHost({bridge, page, inspectorUrl, access, e
const detachButton = page.createElement('button');
detachButton.type = 'button';
detachButton.className = 'webfront-inspector-detach';
detachButton.textContent = 'Detach';
makeMoveButton(page, detachButton, 'detach');
const closeButton = page.createElement('button');
closeButton.type = 'button';
closeButton.className = 'webfront-inspector-close';
Expand Down Expand Up @@ -348,7 +349,8 @@ export async function createInspectorHost({bridge, page, inspectorUrl, access, e
panel.setAttribute('aria-label', `WebFront inspector: ${panelTitle(id)}`);
const why = reason();
detachButton.setAttribute('aria-disabled', String(Boolean(why)));
detachButton.title = why || 'Open this panel in a window of its own';
// Greyed, it keeps its name and its tooltip says why it cannot detach.
detachButton.title = why || inspectorMoves.detach;
// The frame opens no connection of its own: the page reads ?frame and borrows this page's bridge.
const url = urlOf(id, {frame: '1'});
if (frame.getAttribute('src') !== url) {
Expand Down
7 changes: 4 additions & 3 deletions js/developer/environment/inspector.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// tree of each is in inspector-watches.mjs (#682). The panels of the functions and of the browsers are in
// inspector-registry.mjs (#681, section 7), the one of the packages in inspector-packages.mjs (#683), the one of the bridge
// in the page in inspector-bridge.mjs (#684).
import {inspectorPanels as panels, panelTitle, inspectorChannel as channelName} from './menu.mjs';
import {inspectorPanels as panels, panelTitle, inspectorChannel as channelName, makeMoveButton} from './menu.mjs';
import {showFunctionsPanel, showBrowsersPanel, registryStyles, periods, formatPeriod, keptPeriod, keepPeriod, createPoller} from './inspector-registry.mjs';
import {showPackagesPanel, packagesStyles} from './inspector-packages.mjs';
import {createWatchTree, createTreeView, watchTreeStyles} from './inspector-watches.mjs';
Expand Down Expand Up @@ -196,6 +196,8 @@ header label{display:flex;align-items:center;gap:4px;color:#a9b3c4;font-size:12p
header button,header select{min-height:26px;padding:0 8px;border:1px solid #46536a;border-radius:4px;background:#2f3a50;color:inherit;font:inherit;cursor:pointer}
header select{padding:0 4px}
header button:focus-visible,header select:focus-visible{outline:2px solid #d7fa85;outline-offset:1px}
header button.attach{min-width:26px;padding:0 4px}
header button.attach>svg{display:block;margin:auto;pointer-events:none}
main{padding:4px 8px}
.status{color:#a9b3c4;font-size:12px;margin:2px 0 4px}
.status:empty{display:none}
Expand Down Expand Up @@ -318,8 +320,7 @@ export async function main(view = window) {
const attach = page.createElement('button');
attach.type = 'button';
attach.className = 'attach';
attach.textContent = 'Attach';
attach.title = 'Show this panel in the floating window of the main page';
makeMoveButton(page, attach, 'attach');
header.append(attach);
// Its own status: the reads of the watches, which clear theirs, never clear why the panel could not be attached.
const attachStatus = page.createElement('p');
Expand Down
33 changes: 33 additions & 0 deletions js/developer/environment/menu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,39 @@ export const panelTitle = id => inspectorPanels.has(id) ? `${inspectorPanels.get
*/
export const inspectorChannel = 'webfront-inspector';

/** What the icon buttons that move a panel say, as their accessible name and their tooltip (#722). */
export const inspectorMoves = {
detach: 'Detach this panel to a window of its own',
attach: 'Show this panel in the floating window of the main page',
};

// A frame open at its top right, and an arrow that leaves it (detach, ↗) or enters it (attach, ↙), drawn in currentColor.
const iconPaths = {
detach: ['M7 3H3v10h10V9', 'M9 3h4v4', 'M13 3 7 9'],
attach: ['M7 3H3v10h10V9', 'M13 3 7 9', 'M7 5v4h4'],
};
const svgSpace = 'http://www.w3.org/2000/svg';

/**
* Makes `button` (of `page`) the icon button `move` ('detach' or 'attach'): a 16 px inline SVG in the color of the text,
* hidden from assistive technologies, the button being named by its aria-label and its tooltip (inspectorMoves).
*/
export function makeMoveButton(page, button, move) {
const svg = page.createElementNS(svgSpace, 'svg');
const attributes = {viewBox: '0 0 16 16', width: '16', height: '16', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5',
'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true', focusable: 'false'};
for (const [name, value] of Object.entries(attributes)) svg.setAttribute(name, value);
for (const d of iconPaths[move]) {
const path = page.createElementNS(svgSpace, 'path');
path.setAttribute('d', d);
svg.append(path);
}
button.replaceChildren(svg);
button.setAttribute('aria-label', inspectorMoves[move]);
button.title = inspectorMoves[move];
return button;
}

// --- Access to the inspectors ----------------------------------------------------------------------------------

/** The reserved function that says which containers would reach the inspectors; the only one that checks no access. */
Expand Down
30 changes: 29 additions & 1 deletion test/developer/specs/inspector-specs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {detachedContainer, containerFor, hostReasons, parsePreferences, formatPr
preferencesStore, applyPreferenceChanges} from '../../../js/developer/environment/inspector-host.mjs';
import {readDescriptor, readPage, listWatches, listingAttempts, reconcile, watchOpener, createWatchDiscovery, renderWatches, pageBridge, attachAgain,
watchesFunction, reloadWhenRestored} from '../../../js/developer/environment/inspector.mjs';
import {inspectorChannel, inspectorPanels} from '../../../js/developer/environment/menu.mjs';
import {inspectorChannel, inspectorPanels, inspectorMoves, makeMoveButton} from '../../../js/developer/environment/menu.mjs';
import {LineEditor} from '../../../js/developer/environment/terminal.mjs';
import {memoryBridge} from '../memory-bridge.mjs';

Expand Down Expand Up @@ -281,11 +281,39 @@ describe('The inspectors', () => {
expect(host.frame.hasAttribute('src')).toBeFalse();
});

it('draws Detach and Attach as icons named by their action (#722)', () => {
for (const move of ['detach', 'attach']) {
const button = makeMoveButton(document, document.createElement('button'), move);
expect(button.textContent).toBe('');
expect(button.getAttribute('aria-label')).toBe(inspectorMoves[move]);
expect(button.title).toBe(inspectorMoves[move]);
const svg = button.firstElementChild;
expect(button.children.length).toBe(1);
expect(svg.namespaceURI).toBe('http://www.w3.org/2000/svg');
expect(svg.getAttribute('stroke')).toBe('currentColor');
expect(svg.getAttribute('aria-hidden')).toBe('true');
expect(svg.querySelectorAll('path').length).toBeGreaterThan(1);
}
expect(inspectorMoves.detach).toBe('Detach this panel to a window of its own');
expect(inspectorMoves.attach).toBe('Show this panel in the floating window of the main page');
});

it('names the Detach icon by its action, and its tooltip too when it can detach', async () => {
const {host} = await testHost({containers: admitted(true)});
await host.open('cpp.watches');
expect(host.detachButton.textContent).toBe('');
expect(host.detachButton.querySelector('svg')).not.toBeNull();
expect(host.detachButton.getAttribute('aria-label')).toBe(inspectorMoves.detach);
expect(host.detachButton.title).toBe(inspectorMoves.detach);
expect(host.closeButton.getAttribute('aria-label')).toBe('Close the inspector');
});

it('greys Detach with the reason when no detached container would reach the inspectors', async () => {
const {host, calls, opened} = await testHost({containers: admitted(false, true), embedded: true});
await host.open('cpp.watches');
expect(host.detachButton.getAttribute('aria-disabled')).toBe('true');
expect(host.detachButton.title).toBe(hostReasons.noDetached);
expect(host.detachButton.getAttribute('aria-label')).toBe(inspectorMoves.detach);
host.detachButton.click();
await host.saved();
expect(calls.some(([name]) => name === 'webfront.inspector.openWindow')).toBeFalse();
Expand Down
13 changes: 12 additions & 1 deletion test/web/developer-specs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ try {
await eventually(() => /No installed packages/.test(panel()?.querySelector('.status:not(.attach-status)')?.textContent ?? ''),
() => `The Packages panel must say that a project without a lock has no package: ${shown()}`, slowly);
assert(tree().length === 0, `A project without a lock has no tree: ${shown()}`);
// Detached, the panel offers to go back to the floating window with an icon named by its action (#722).
const attach = panel().querySelector('header button.attach');
assert(attach && attach.textContent === '' && attach.querySelector('svg[aria-hidden="true"]'),
`A detached panel must offer Attach as an icon: ${attach?.outerHTML}`);
assert(attach.getAttribute('aria-label') === 'Show this panel in the floating window of the main page' && attach.title === attach.getAttribute('aria-label'),
`The Attach icon must be named by its action: ${attach.getAttribute('aria-label')} / ${attach.title}`);

await execute(['install', 'react@19.3.1', 'react-dom@19.3.1'], context);
lock = await runtime.readLock(webFront);
Expand Down Expand Up @@ -1063,10 +1069,15 @@ try {
await webFront.cppFunction('test.unwatchLife')();
await until(() => !listed().includes('grid'), `The watches of Life must disappear once removed: ${listed()}`);
const detach = floating().querySelector('.webfront-inspector-detach');
// An icon named by its action, whether it can detach or not (#722).
assert(detach.textContent === '' && detach.querySelector('svg[aria-hidden="true"]')
&& detach.getAttribute('aria-label') === 'Detach this panel to a window of its own',
`Detach must be an icon named by its action: ${detach.outerHTML}`);
if (secondaryWindow) {
// A frontend that opens windows: Detach moves the panel to a native window with its own proven connection.
const views = await webFront.cppFunction('test.views')();
assert(detach.getAttribute('aria-disabled') === 'false', 'A frontend that opens windows must offer to detach the panel');
assert(detach.getAttribute('aria-disabled') === 'false' && detach.title === detach.getAttribute('aria-label'),
`A frontend that opens windows must offer to detach the panel: ${detach.title}`);
detach.click();
await until(() => floating().hidden, 'A detached panel must leave the floating window');
await until(async () => await webFront.cppFunction('test.views')() === views + 1,
Expand Down
Loading