ravensight-playtest 0.8.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -66
- package/addons/ravensight_driver/driver.gd +666 -21
- package/docs/ADAPTERS.md +11 -7
- package/docs/NATIVE_RUNNER.md +3 -1
- package/docs/godot-driver.md +127 -13
- package/package.json +8 -6
- package/src/api/client.js +4 -3
- package/src/cli.js +84 -25
- package/src/commands/check.js +30 -4
- package/src/commands/fakeCore.js +1 -0
- package/src/commands/hosted.js +41 -12
- package/src/commands/init.js +17 -1
- package/src/commands/run.js +209 -14
- package/src/commands/upload.js +6 -2
- package/src/commands/validate.js +1 -1
- package/src/commands/validateHosted.js +50 -5
- package/src/config.js +33 -2
- package/src/hosted/archivePreflight.js +7 -7
- package/src/hosted/buildUpload.js +89 -8
- package/src/hosted/recordedRun.js +141 -26
- package/src/hosted/status.js +19 -10
- package/src/run/actionSelector.js +14 -3
- package/src/run/aggregate.js +57 -3
- package/src/run/anygame/controlbook.js +179 -0
- package/src/run/anygame/genre.js +179 -0
- package/src/run/anygame/index.js +258 -0
- package/src/run/anygame/language.js +336 -0
- package/src/run/anygame/memory.js +330 -0
- package/src/run/anygame/shared-hashes.json +10 -0
- package/src/run/anygame/shared.js +24 -0
- package/src/run/anygame/sound.js +342 -0
- package/src/run/args.js +75 -8
- package/src/run/choiceCheck.js +312 -0
- package/src/run/context.js +254 -13
- package/src/run/drivers/godot-observation.js +93 -6
- package/src/run/drivers/godot.js +769 -46
- package/src/run/drivers/recording.js +24 -4
- package/src/run/drivers/web.js +1242 -77
- package/src/run/edgePass.js +731 -0
- package/src/run/fixLoop.js +5 -4
- package/src/run/focus.js +65 -0
- package/src/run/gamepad.js +108 -0
- package/src/run/godotEdgePass.js +235 -0
- package/src/run/godotTesterProbes.js +192 -0
- package/src/run/headings.js +21 -0
- package/src/run/honesty.js +544 -0
- package/src/run/inputs.js +256 -0
- package/src/run/marks.js +142 -0
- package/src/run/personaLoop.js +1000 -79
- package/src/run/phone.js +7 -0
- package/src/run/pixels.js +215 -0
- package/src/run/playClock.js +162 -0
- package/src/run/readiness.js +585 -0
- package/src/run/refusal.js +67 -0
- package/src/run/regions.js +119 -0
- package/src/run/report.js +14 -2
- package/src/run/reportChecks.js +472 -0
- package/src/run/resume.js +3 -2
- package/src/run/screenshots.js +161 -0
- package/src/run/strip.js +114 -0
- package/src/run/testerLedger.js +312 -0
- package/src/run/testerProbes.js +584 -0
- package/src/run/thinRun.js +102 -0
- package/src/run/timeFreeze.js +79 -0
- package/src/run/tools.js +454 -29
- package/src/runDefaults.js +24 -2
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
// The tester probes for the local web driver: what a hired QA tester tries on
|
|
2
|
+
// any game, scripted, on the runner's own clock, with no model call and so no
|
|
3
|
+
// charge. They run on the page play ended on, before the edge behaviour
|
|
4
|
+
// checks (./edgePass.js, which owns focus loss, resize, idle and the reload).
|
|
5
|
+
//
|
|
6
|
+
// Probes: text that does not fit its box, one control clicked many times
|
|
7
|
+
// fast, every button play never named, text fields given nothing, far too
|
|
8
|
+
// much and odd text, a menu opened and closed and backed out of at once,
|
|
9
|
+
// pause and resume, opposite keys held together, the edges of the play area,
|
|
10
|
+
// the buttons in reverse order, and (after the edge checks, when nothing is
|
|
11
|
+
// left to lose) input while the page loads.
|
|
12
|
+
//
|
|
13
|
+
// Oracles: an uncaught error or a console error tied to the probe that
|
|
14
|
+
// raised it, a blank screen, a page that stops answering, a soft lock (a
|
|
15
|
+
// button that changed the screen twice running now changes nothing, and
|
|
16
|
+
// nothing else does), the game's own numbers breaking their rules, a button
|
|
17
|
+
// that does nothing, text cut off, typed text put into the page as markup,
|
|
18
|
+
// a pause the game does not come back from.
|
|
19
|
+
//
|
|
20
|
+
// Reproduce before reporting: a suspected bug is tried again in the session,
|
|
21
|
+
// and (./reportChecks.js replayWebFindings, the run's one replay) the probes
|
|
22
|
+
// that found something are run once more at the end of the replay. Each
|
|
23
|
+
// finding says how often it came back. A probe that could not run says why
|
|
24
|
+
// and is `not_checked`: never a finding, never counted as passed.
|
|
25
|
+
import { pngFingerprint, screenDelta, significant } from './pixels.js';
|
|
26
|
+
import { flatShare, BLANK_SHARE, runnerFinding, stepsBefore } from './honesty.js';
|
|
27
|
+
import { readings, NEVER_NEGATIVE, BOUNDED, NEVER_FALLS } from './testerLedger.js';
|
|
28
|
+
|
|
29
|
+
/** The heading the probes are written under in report.md. */
|
|
30
|
+
export const PROBES_HEADING = '## Tester probes (run by the runner after play, no model call)';
|
|
31
|
+
|
|
32
|
+
export const PROBE_TIMING = Object.freeze({ settleMs: 300, rapidClicks: 15, rapidGapMs: 12, holdMs: 700, edgeHoldMs: 400, edgeMaxMs: 4000, longText: 5000, maxSweep: 6, retries: 2, loadInputMs: 1200, budgetMs: 60000 });
|
|
33
|
+
|
|
34
|
+
/** The probes, in the order they run, with the words the report uses. */
|
|
35
|
+
export const PROBES = Object.freeze([
|
|
36
|
+
['overflow', 'text that overflows or is cut off'],
|
|
37
|
+
['rapid', 'rapid repeated input on one control'],
|
|
38
|
+
['untried', 'every button play never named, pressed once'],
|
|
39
|
+
['text', 'text fields given nothing, far too much and unusual text'],
|
|
40
|
+
['menu', 'a menu left and entered again, and backed out of at once'],
|
|
41
|
+
['pause', 'pause and resume'],
|
|
42
|
+
['opposite', 'opposite keys held together'],
|
|
43
|
+
['edges', 'the edges of the play area'],
|
|
44
|
+
['order', 'buttons pressed out of the expected order'],
|
|
45
|
+
['loading', 'input while the page loads']
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
const RISKY = /\b(delete|erase|reset|wipe|quit|exit|buy|purchase|pay|sign ?out|log ?out|remove|restart|new game|share|download|export|print|install|subscribe|donate)\b/i;
|
|
49
|
+
const UNSEEN_EFFECT = /\b(sounds?|audio|music|mute|unmute|volume|sfx|voice|full ?screen|copy|clipboard)\b/i;
|
|
50
|
+
const MENU = /\b(menu|options|settings|inventory|shop|store|help|about|how to play|instructions|map|stats|credits|upgrades?|skills?|achievements|journal|log|bag|crafting|character)\b/i;
|
|
51
|
+
const LEAVE = /\b(back|close|done|return|resume|ok|okay|cancel|continue|got it)\b|^x$/i;
|
|
52
|
+
const PAUSE = /\bpause\b/i;
|
|
53
|
+
const RESUME = /\b(resume|continue|unpause|play)\b/i;
|
|
54
|
+
const CLOCK = /\b(time|timer|clock|elapsed|fps|seconds?|ms|frames?|ping)\b/i;
|
|
55
|
+
const OPPOSITES = [['ArrowLeft', 'ArrowRight'], ['ArrowUp', 'ArrowDown'], ['a', 'd']];
|
|
56
|
+
const MARKUP_ID = 'rs-tester-markup';
|
|
57
|
+
/** Text a player might paste: markup, quotes, other scripts, an emoji. */
|
|
58
|
+
export const ODD_TEXT = `<b id="${MARKUP_ID}">x</b> "quoted" 'single' \\ %s {0} \u05E9\u05DC\u05D5\u05DD \u65E5\u672C\u8A9E \uD83D\uDE42`;
|
|
59
|
+
|
|
60
|
+
/* c8 ignore start */
|
|
61
|
+
/** Runs in the page: the buttons a player could press, and the text fields. */
|
|
62
|
+
function pageControls() {
|
|
63
|
+
const shown = el => { const r = el.getBoundingClientRect(); if (r.width < 4 || r.height < 4 || r.bottom <= 0 || r.right <= 0 || r.top >= innerHeight || r.left >= innerWidth) return null; const cs = getComputedStyle(el); if (cs.visibility === 'hidden' || cs.display === 'none' || Number(cs.opacity) === 0 || el.closest('[inert]')) return null; return r; };
|
|
64
|
+
const name = el => String(el.getAttribute('aria-label') || el.innerText || el.value || el.getAttribute('title') || '').replace(/\s+/g, ' ').trim().slice(0, 60);
|
|
65
|
+
const buttons = [], fields = [];
|
|
66
|
+
for (const el of document.querySelectorAll('button, [role=button], input[type=button], input[type=submit]')) {
|
|
67
|
+
const r = shown(el);
|
|
68
|
+
if (!r || !name(el)) continue;
|
|
69
|
+
buttons.push({ name: name(el), x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2), disabled: Boolean(el.disabled) || el.getAttribute('aria-disabled') === 'true' });
|
|
70
|
+
}
|
|
71
|
+
for (const el of document.querySelectorAll('input:not([type]), input[type=text], input[type=search], input[type=email], textarea')) {
|
|
72
|
+
const r = shown(el);
|
|
73
|
+
if (!r || el.disabled || el.readOnly) continue;
|
|
74
|
+
fields.push({ name: name(el) || el.name || el.id || 'the text field', x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) });
|
|
75
|
+
}
|
|
76
|
+
const canvas = [...document.querySelectorAll('canvas')].map(shown).filter(Boolean).sort((a, b) => b.width * b.height - a.width * a.height)[0] || null;
|
|
77
|
+
return { buttons: buttons.slice(0, 40), fields: fields.slice(0, 4), text: (document.body ? document.body.innerText : '').slice(0, 4000), canvas: canvas ? { x: canvas.left, y: canvas.top, width: canvas.width, height: canvas.height } : null, keys: Boolean(window.__rsProbeKeys) };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Runs in the page: text that does not fit the box it is drawn in. */
|
|
81
|
+
function pageOverflow(max) {
|
|
82
|
+
const out = [];
|
|
83
|
+
let texts = 0;
|
|
84
|
+
const own = el => [...el.childNodes].filter(n => n.nodeType === 3).map(n => n.nodeValue).join(' ').replace(/\s+/g, ' ').trim();
|
|
85
|
+
for (const el of document.querySelectorAll('body *')) {
|
|
86
|
+
if (out.length >= max) break;
|
|
87
|
+
if (['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'TEXTAREA', 'SELECT', 'OPTION', 'CANVAS', 'INPUT'].includes(el.tagName)) continue;
|
|
88
|
+
const text = own(el);
|
|
89
|
+
if (text.length < 3) continue;
|
|
90
|
+
const r = el.getBoundingClientRect();
|
|
91
|
+
if (r.width < 8 || r.height < 8) continue;
|
|
92
|
+
const cs = getComputedStyle(el);
|
|
93
|
+
if (cs.visibility === 'hidden' || cs.display === 'none' || Number(cs.opacity) === 0 || cs.clipPath !== 'none' || el.closest('[aria-hidden="true"]')) continue;
|
|
94
|
+
texts += 1;
|
|
95
|
+
const hidesX = cs.overflowX === 'hidden' || cs.overflowX === 'clip', hidesY = cs.overflowY === 'hidden' || cs.overflowY === 'clip';
|
|
96
|
+
if (hidesX && cs.textOverflow !== 'ellipsis' && el.scrollWidth - el.clientWidth >= 10) out.push({ text: text.slice(0, 60), px: el.scrollWidth - el.clientWidth, how: 'wider than its box, which hides the rest' });
|
|
97
|
+
else if (hidesY && el.clientHeight > 0 && el.scrollHeight - el.clientHeight >= 10) out.push({ text: text.slice(0, 60), px: el.scrollHeight - el.clientHeight, how: 'taller than its box, which hides the rest' });
|
|
98
|
+
}
|
|
99
|
+
return { found: out, texts, canvas: document.querySelectorAll('canvas').length };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Runs in the page: fill the text field at a point as typing would. */
|
|
103
|
+
function pageFill([x, y, text]) {
|
|
104
|
+
let el = document.elementFromPoint(x, y);
|
|
105
|
+
if (el && !(el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) el = el.querySelector ? el.querySelector('input,textarea') : null;
|
|
106
|
+
if (!(el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) return null;
|
|
107
|
+
el.focus();
|
|
108
|
+
if (el.maxLength > 0) text = text.slice(0, el.maxLength);
|
|
109
|
+
const proto = el instanceof HTMLInputElement ? HTMLInputElement.prototype : HTMLTextAreaElement.prototype;
|
|
110
|
+
Object.getOwnPropertyDescriptor(proto, 'value').set.call(el, text);
|
|
111
|
+
el.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText', data: text }));
|
|
112
|
+
el.dispatchEvent(new Event('change', { bubbles: true }));
|
|
113
|
+
return { length: el.value.length, max: el.maxLength > 0 ? el.maxLength : null };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function pageMarkup(id) { const el = document.getElementById(id); if (!el) return false; el.remove(); return true; }
|
|
117
|
+
function pageRings(on) { const id = 'rs-tester-rings'; const have = document.getElementById(id); if (on && !have) { const st = document.createElement('style'); st.id = id; st.textContent = '*:focus,*:focus-visible{outline:none!important}'; (document.head || document.documentElement).appendChild(st); } else if (!on && have) have.remove(); const a = document.activeElement; if (on && a && a !== document.body && !['CANVAS', 'IFRAME'].includes(a.tagName) && a.blur) a.blur(); }
|
|
118
|
+
/* c8 ignore stop */
|
|
119
|
+
|
|
120
|
+
/** The names an input of the session named, lower case: what play already tried. */
|
|
121
|
+
export function namedInPlay(actionRecords = []) {
|
|
122
|
+
const out = new Set();
|
|
123
|
+
for (const record of actionRecords) {
|
|
124
|
+
if (!record || record.kind !== 'action') continue;
|
|
125
|
+
let text = '';
|
|
126
|
+
try { text = JSON.stringify(record.input || {}); } catch { text = ''; }
|
|
127
|
+
for (const match of text.matchAll(/\\"([^"\\]{1,60})\\"/g)) out.add(match[1].toLowerCase());
|
|
128
|
+
for (const key of ['target', 'text', 'name']) if (record.input && typeof record.input[key] === 'string') out.add(record.input[key].toLowerCase());
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Buttons play pressed that changed the screen, newest first, by name. */
|
|
134
|
+
export function workedButtons(actionRecords = []) {
|
|
135
|
+
const out = [];
|
|
136
|
+
for (const record of [...actionRecords].reverse()) {
|
|
137
|
+
if (!record || record.kind !== 'action' || record.tool !== 'click' || !record.ok || record.changed === false) continue;
|
|
138
|
+
const target = record.input && typeof record.input.target === 'string' ? record.input.target : '';
|
|
139
|
+
const name = (target.match(/"([^"]{1,60})"/) || [])[1] || (record.input && typeof record.input.text === 'string' ? record.input.text : '');
|
|
140
|
+
if (name && !RISKY.test(name) && !out.includes(name)) out.push(name);
|
|
141
|
+
if (out.length >= 3) break;
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** A broken number in a page's text, with no history: `[{ kind, label, to, max }]`. */
|
|
147
|
+
export function brokenNow(text) {
|
|
148
|
+
const out = [];
|
|
149
|
+
for (const reading of readings(text)) {
|
|
150
|
+
if (reading.value < 0 && NEVER_NEGATIVE.has(reading.label)) out.push({ kind: 'negative', label: reading.label, to: reading.value });
|
|
151
|
+
if (reading.max !== null && reading.max > 0 && reading.value > reading.max && BOUNDED.has(reading.label)) out.push({ kind: 'above_max', label: reading.label, to: reading.value, max: reading.max });
|
|
152
|
+
}
|
|
153
|
+
for (const match of String(text || '').matchAll(/([A-Za-z]{2,20})\s*[:=]\s*(NaN|undefined|Infinity)(?![A-Za-z])/g)) out.push({ kind: 'not_a_number', label: match[1].toLowerCase(), to: match[2] });
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** How often a suspect came back, in words for its finding. */
|
|
158
|
+
export function reproducedWords(tries, hits, why = null, { uncounted = false } = {}) {
|
|
159
|
+
if (!tries && uncounted) return `Seen once in the session; a second try there is not counted${why ? ` (${why})` : ''}.`;
|
|
160
|
+
if (!tries) return `Seen once; it was not tried again${why ? ` (${why})` : ''}.`;
|
|
161
|
+
return hits ? `Reproduced ${hits} of ${tries}: tried again in the same session after it was first seen.` : `Not reproduced (0 of ${tries}): tried again in the same session and it did not happen again. Treat it as a one-off.`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const q = value => `"${String(value || '').replace(/"/g, "'").slice(0, 60)}"`;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Run the probes. `only` narrows them to some (the replay's second try);
|
|
168
|
+
* `loading` runs the loading probe alone. Never throws: a probe that fails is
|
|
169
|
+
* recorded as not checked and the pass moves on.
|
|
170
|
+
*
|
|
171
|
+
* @param {Object} args
|
|
172
|
+
* @returns {Promise<{checks: Array<Object>, elapsedMs: number, canaries: Array<string>}>}
|
|
173
|
+
*/
|
|
174
|
+
export async function runTesterProbes({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), timing = PROBE_TIMING, only = null, loading = false, retries = timing.retries, save = true }) {
|
|
175
|
+
const session = driver.edgeSession();
|
|
176
|
+
const page = session.page;
|
|
177
|
+
const started = Date.now();
|
|
178
|
+
const left = () => timing.budgetMs - (Date.now() - started);
|
|
179
|
+
const checks = [];
|
|
180
|
+
const stopped = () => Boolean(signal && signal.aborted) || Boolean(session.gameEnded && session.gameEnded());
|
|
181
|
+
const evaluate = (fn, arg) => { let timer; return Promise.race([Promise.resolve().then(() => page.evaluate(fn, arg)), new Promise((resolve, reject) => { timer = setTimeout(() => reject(new Error('the page did not answer')), 8000); })]).finally(() => clearTimeout(timer)); };
|
|
182
|
+
const controls = () => evaluate(pageControls).catch(() => ({ buttons: [], fields: [], text: '', canvas: null }));
|
|
183
|
+
const print = async () => { try { return pngFingerprint(await page.screenshot({ type: 'png', timeout: 10000 })); } catch { return null; } };
|
|
184
|
+
const look = async () => { const c = await controls(); return { ...c, print: await print(), sig: `${c.text}\n${c.buttons.map(b => `${b.name}|${b.disabled ? 1 : 0}`).join('\n')}` }; };
|
|
185
|
+
const differs = (a, b) => a.sig !== b.sig || (a.print && b.print ? significant(screenDelta(a.print, b.print)) : false);
|
|
186
|
+
const errors = () => (session.drainErrors ? session.drainErrors() : []).filter(entry => entry && (entry.type === 'pageerror' || (entry.type === 'console' && !/favicon|Failed to load resource/i.test(String(entry.text))))).map(entry => ({ thrown: entry.type === 'pageerror', text: String(entry.text || '').slice(0, 200) }));
|
|
187
|
+
const alive = async () => { let timer; try { return await Promise.race([Promise.resolve().then(() => page.evaluate(() => 1)).then(() => true, () => true), new Promise(resolve => { timer = setTimeout(() => resolve(false), 5000); })]); } finally { clearTimeout(timer); } };
|
|
188
|
+
const shot = async (name, reason) => {
|
|
189
|
+
if (!save) return null;
|
|
190
|
+
try {
|
|
191
|
+
const saved = await driver.screenshot(name);
|
|
192
|
+
if (saved && saved.relativePath) { screenshots.push({ ...saved, edge: true, reason: `tester probe: ${reason} (saved by the runner)`, ...(Number.isInteger(observation) ? { observation } : {}), at: Date.now(), order: Number.MAX_SAFE_INTEGER - 200 + screenshots.length }); return saved.relativePath; }
|
|
193
|
+
} catch { /* no picture is still a check */ }
|
|
194
|
+
return null;
|
|
195
|
+
};
|
|
196
|
+
const park = async () => { await page.mouse.move(1, 1).catch(() => {}); await evaluate(pageRings, true).catch(() => {}); };
|
|
197
|
+
/** Click a button by its name as it is on the page now. `{ ok, changed }`. */
|
|
198
|
+
const click = async name => {
|
|
199
|
+
await park();
|
|
200
|
+
const before = await look();
|
|
201
|
+
const button = before.buttons.find(b => b.name === name);
|
|
202
|
+
if (!button) return { ok: false, changed: false, before };
|
|
203
|
+
await page.mouse.click(button.x, button.y).catch(() => {});
|
|
204
|
+
await page.mouse.move(1, 1).catch(() => {});
|
|
205
|
+
await sleep(timing.settleMs);
|
|
206
|
+
const after = await look();
|
|
207
|
+
return { ok: true, disabled: button.disabled, changed: differs(before, after), before, after };
|
|
208
|
+
};
|
|
209
|
+
const press = async (key, ms = 120) => { await park(); const before = await look(); await page.keyboard.down(key).catch(() => {}); await sleep(ms); await page.keyboard.up(key).catch(() => {}); await sleep(timing.settleMs); const after = await look(); return { changed: differs(before, after), before, after }; };
|
|
210
|
+
const pressable = list => list.filter(b => !b.disabled && !RISKY.test(b.name));
|
|
211
|
+
const answered = new Set();
|
|
212
|
+
const names = l => l.buttons.map(b => b.name).join('|');
|
|
213
|
+
const comeBack = async start => {
|
|
214
|
+
for (let i = 0; i < 2; i += 1) {
|
|
215
|
+
const now = await look();
|
|
216
|
+
if (names(now) === names(start)) return true;
|
|
217
|
+
const back = pressable(now.buttons).find(b => LEAVE.test(b.name) || RESUME.test(b.name));
|
|
218
|
+
if (back) await click(back.name); else await press('Escape');
|
|
219
|
+
}
|
|
220
|
+
return names(await look()) === names(start);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// Buttons that change the screen twice running: what shows later that the game stopped answering.
|
|
224
|
+
let canaries = [];
|
|
225
|
+
/** Does the game still answer? The canaries, then any button, then Enter and Space. */
|
|
226
|
+
const responds = async () => {
|
|
227
|
+
const tries = [];
|
|
228
|
+
const since = Date.now();
|
|
229
|
+
for (const name of canaries) { const r = await click(name); if (!r.ok) continue; tries.push({ label: `click ${q(name)}`, canary: true }); if (r.changed) return { responds: true, tries }; }
|
|
230
|
+
const now = await look();
|
|
231
|
+
for (const b of pressable(now.buttons).filter(x => !canaries.includes(x.name)).slice(0, 3)) { const r = await click(b.name); if (!r.ok) continue; tries.push({ label: `click ${q(b.name)}` }); if (r.changed) return { responds: true, tries }; }
|
|
232
|
+
for (const key of ['Enter', ' ']) { const r = await press(key); tries.push({ label: `key ${key === ' ' ? 'Space' : key}` }); if (r.changed) return { responds: true, tries }; }
|
|
233
|
+
return { responds: false, tries, ms: Date.now() - since };
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/** After a probe: what the oracles see. `[{ oracle, key?, severity, category, title, description }]`. */
|
|
237
|
+
const judge = async (what, { before = null, softLock = true } = {}) => {
|
|
238
|
+
const hits = [];
|
|
239
|
+
if (session.gameEnded && session.gameEnded()) { hits.push({ oracle: 'crash', severity: 'blocker', category: 'bug', title: `The page ended after ${what}`, description: `The page running the game ended after ${what}. It had run through play.` }); return hits; }
|
|
240
|
+
if (!(await alive())) { hits.push({ oracle: 'frozen', severity: 'major', category: 'bug', title: `The page stopped answering after ${what}`, description: `After ${what} the page did not answer for five seconds: its main thread is busy or stuck.` }); return hits; }
|
|
241
|
+
for (const e of errors()) hits.push({ oracle: 'error', key: e.text.replace(/\d+/g, '#'), ...(e.thrown ? { thrown: true } : {}), severity: e.thrown ? 'major' : 'minor', category: 'bug', title: e.thrown ? `A script error was raised when ${what}` : `The game logged an error when ${what}`, description: `${e.thrown ? 'The game threw an error that nothing caught' : 'The game wrote an error to the console'} when ${what}: ${q(e.text)}.` });
|
|
242
|
+
const now = await look();
|
|
243
|
+
const share = flatShare(now.print);
|
|
244
|
+
if (share !== null && share >= BLANK_SHARE && before && !(flatShare(before.print) >= BLANK_SHARE)) hits.push({ oracle: 'blank', severity: 'major', category: 'bug', title: `The screen went blank after ${what}`, description: `After ${what} the whole screen showed one flat colour.` });
|
|
245
|
+
for (const b of brokenNow(now.text)) {
|
|
246
|
+
// Already broken before the probe, and no further: not this probe's doing. Broken further counts (a second try of the same probe).
|
|
247
|
+
if (before && brokenNow(before.text).some(x => x.kind === b.kind && x.label === b.label && x.to === b.to)) continue;
|
|
248
|
+
const words = { negative: [`"${b.label}" goes below zero`, `The game showed "${b.label}" at ${b.to} after ${what}. A count of this kind cannot be less than nothing, so something was taken without checking that enough was left.`], above_max: [`"${b.label}" goes above its maximum`, `The game showed "${b.label}" at ${b.to} of ${b.max} after ${what}: past the limit the game itself prints beside it.`], not_a_number: [`"${b.label}" shows "${b.to}" where a number belongs`, `The game printed "${b.label}" as "${b.to}" after ${what}.`] }[b.kind];
|
|
249
|
+
hits.push({ oracle: 'invariant', key: `${b.kind}:${b.label}`, severity: 'major', category: 'bug', title: words[0], description: words[1] });
|
|
250
|
+
}
|
|
251
|
+
if (softLock && canaries.length > 0 && !hits.some(h => h.oracle === 'blank')) {
|
|
252
|
+
const r = await responds();
|
|
253
|
+
// Only a button that changed this screen before can show it stopped answering, and only over real time.
|
|
254
|
+
if (!r.responds && r.tries.some(t => t.canary) && r.tries.length >= 2 && r.ms >= 1500) hits.push({ oracle: 'soft_lock', severity: 'major', category: 'bug', title: `The game stops answering input after ${what}`, description: `After ${what}, none of ${r.tries.length} inputs over ${(r.ms / 1000).toFixed(1)} seconds changed the screen (${r.tries.map(t => t.label).slice(0, 8).join('; ')}), although the page was still answering. Before it, clicking ${q(canaries[0])} changed the screen. A player can no longer do anything: a soft lock.` });
|
|
255
|
+
}
|
|
256
|
+
return hits;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const suspects = [];
|
|
260
|
+
/** One probe: run it, and keep what it found with a way to try it again. */
|
|
261
|
+
const run = async (id, fn) => {
|
|
262
|
+
if (only && !only.includes(id)) return;
|
|
263
|
+
if ((id === 'loading') !== Boolean(loading)) return;
|
|
264
|
+
const title = PROBES.find(p => p[0] === id)[1];
|
|
265
|
+
const add = check => { checks.push({ name: id, title, ...check }); log(`tester probe, ${title}: ${check.status}${check.detail ? ` (${check.detail})` : ''}`); };
|
|
266
|
+
if (stopped()) return add({ status: 'not_checked', detail: 'the page had ended' });
|
|
267
|
+
const stuck = suspects.find(s => ['soft_lock', 'frozen', 'crash', 'blank'].includes(s.oracle));
|
|
268
|
+
if (stuck) return add({ status: 'not_checked', detail: `the game had stopped answering after ${stuck.what}` });
|
|
269
|
+
if (left() < 5000) return add({ status: 'not_checked', detail: 'no time was left for it' });
|
|
270
|
+
try {
|
|
271
|
+
const r = await fn();
|
|
272
|
+
if (r && r.skip) return add({ status: 'not_checked', detail: r.skip });
|
|
273
|
+
const hits = (r && r.hits) || [];
|
|
274
|
+
for (const hit of hits) if (!suspects.some(s => s.oracle === hit.oracle && s.key === hit.key && (hit.key !== undefined || s.probe === id))) suspects.push({ ...hit, probe: id, what: r.what, again: r.again, screenshot: await shot(`probe-${id}-${hit.oracle}`, hit.title) });
|
|
275
|
+
add({ status: hits.length ? 'problem' : 'ok', detail: hits.length ? hits.map(h => h.title).join('; ') : (r && r.detail) || 'nothing went wrong in this check' });
|
|
276
|
+
} catch (error) {
|
|
277
|
+
add({ status: 'not_checked', detail: `the probe itself failed (${String(error && error.message).split('\n')[0].slice(0, 80)})` });
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
await session.releaseClock();
|
|
282
|
+
if (session.dismissDialogs) session.dismissDialogs(true);
|
|
283
|
+
// The element play left focused gets the focus back afterwards: the edge
|
|
284
|
+
// checks that follow press the session's keys where play left them, not on
|
|
285
|
+
// the last button a probe clicked.
|
|
286
|
+
const focusMark = loading ? false : await evaluate(() => { const el = document.activeElement; if (!el || el === document.body) return false; el.setAttribute('data-ravensight-play-focus', '1'); return true; }).catch(() => false);
|
|
287
|
+
try {
|
|
288
|
+
errors();
|
|
289
|
+
await evaluate(pageRings, true).catch(() => {});
|
|
290
|
+
const start = await look();
|
|
291
|
+
const keyboard = Boolean(start.canvas) || actionRecords.some(r => r && r.kind === 'action' && r.tool === 'key' && r.ok);
|
|
292
|
+
if (!only || !loading) for (const name of workedButtons(actionRecords)) { const a = await click(name); const b = a.ok && a.changed ? await click(name) : null; if (b && b.ok && b.changed) canaries.push(name); }
|
|
293
|
+
|
|
294
|
+
await run('overflow', async () => {
|
|
295
|
+
const r = await evaluate(pageOverflow, 6).catch(() => null);
|
|
296
|
+
if (!r) return { skip: 'the page could not be measured' };
|
|
297
|
+
if (!r.texts) return { skip: r.canvas ? 'the game draws its text on a canvas, which the runner cannot measure' : 'the page shows no text to measure' };
|
|
298
|
+
const what = 'the page was measured';
|
|
299
|
+
const hits = r.found.length ? [{ oracle: 'overflow', key: r.found[0].text, severity: 'minor', category: 'ux', title: `Text is cut off: ${q(r.found[0].text)}`, description: `${r.found.slice(0, 4).map(f => `${q(f.text)} is ${f.px} pixels ${f.how}`).join('; ')}.` }] : [];
|
|
300
|
+
return { hits, what, again: async () => { const n = await evaluate(pageOverflow, 6).catch(() => null); return Boolean(n && n.found.some(f => f.text === r.found[0].text)); } };
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
await run('rapid', async () => {
|
|
304
|
+
const now = await look();
|
|
305
|
+
const name = canaries[0] || (pressable(now.buttons)[0] || {}).name;
|
|
306
|
+
if (!name) return { skip: 'no button was known to do anything on this screen' };
|
|
307
|
+
const what = `${q(name)} was clicked ${timing.rapidClicks} times as fast as possible`;
|
|
308
|
+
const once = async () => {
|
|
309
|
+
const before = await look();
|
|
310
|
+
const button = before.buttons.find(b => b.name === name);
|
|
311
|
+
if (!button) return [];
|
|
312
|
+
errors();
|
|
313
|
+
for (let i = 0; i < timing.rapidClicks; i += 1) { await page.mouse.click(button.x, button.y).catch(() => {}); await sleep(timing.rapidGapMs); }
|
|
314
|
+
await sleep(timing.settleMs);
|
|
315
|
+
return judge(what, { before });
|
|
316
|
+
};
|
|
317
|
+
const hits = await once();
|
|
318
|
+
if (names(await look()) !== names(now)) { answered.add(name); await comeBack(now); }
|
|
319
|
+
return { hits, what, again: async hit => {
|
|
320
|
+
// A control the game has since disabled or taken away cannot be pressed again: that try was never made.
|
|
321
|
+
const button = (await look()).buttons.find(b => b.name === name);
|
|
322
|
+
if (!button || button.disabled) return { untried: `${q(name)} was ${button ? 'disabled' : 'gone'} by then, so it could only be tried again from a fresh start` };
|
|
323
|
+
return (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key);
|
|
324
|
+
} };
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
await run('untried', async () => {
|
|
328
|
+
const now = await look();
|
|
329
|
+
const played = namedInPlay(actionRecords);
|
|
330
|
+
const list = pressable(now.buttons).filter(b => !played.has(b.name.toLowerCase()) && ![...played].some(p => p.includes(`"${b.name.toLowerCase()}"`))).slice(0, timing.maxSweep);
|
|
331
|
+
if (pressable(now.buttons).length === 0) return { skip: 'the page play ended on lists no buttons' };
|
|
332
|
+
if (list.length === 0) return { detail: 'play had already named every button on this page' };
|
|
333
|
+
const beside = b => now.fields.some(f => Math.abs(f.y - b.y) <= 40);
|
|
334
|
+
const hits = [];
|
|
335
|
+
let dead = null;
|
|
336
|
+
for (const b of list) {
|
|
337
|
+
if (left() < 5000 || stopped()) break;
|
|
338
|
+
errors();
|
|
339
|
+
const first = await click(b.name);
|
|
340
|
+
if (!first.ok) continue;
|
|
341
|
+
if (first.changed) answered.add(b.name);
|
|
342
|
+
if (!first.changed && !UNSEEN_EFFECT.test(b.name) && !answered.has(b.name) && !beside(b)) {
|
|
343
|
+
await press('Escape');
|
|
344
|
+
const second = await click(b.name);
|
|
345
|
+
if (second.ok && second.changed) await comeBack(now);
|
|
346
|
+
if (second.ok && !second.changed && !dead) { dead = b.name; hits.push({ oracle: 'dead_control', key: b.name, severity: 'minor', category: 'ux', title: `${q(b.name)} does nothing when clicked`, description: `The button ${q(b.name)} was clicked twice, with Escape pressed in between in case something was open over it. The page was answering, and its picture, its text and its buttons were the same before and after. Play had never named it.` }); }
|
|
347
|
+
}
|
|
348
|
+
hits.push(...await judge(`${q(b.name)} was clicked`, { before: first.before, softLock: false }));
|
|
349
|
+
if (first.changed && !(await comeBack(now))) break;
|
|
350
|
+
}
|
|
351
|
+
return { hits, what: dead ? `${q(dead)} was clicked` : 'the buttons play never named were clicked', again: async hit => { if (hit.oracle !== 'dead_control') return false; const r = await click(hit.key); return r.ok && !r.changed; }, detail: `${list.length} pressed` };
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
await run('text', async () => {
|
|
355
|
+
const now = await look();
|
|
356
|
+
if (now.fields.length === 0) return { skip: now.canvas ? 'no text field is on the page (one drawn on a canvas cannot be filled by this probe)' : 'the page play ended on has no text field' };
|
|
357
|
+
const field = now.fields[0];
|
|
358
|
+
const hits = [];
|
|
359
|
+
const tryText = async (label, text) => {
|
|
360
|
+
const at = (await look()).fields.find(f => f.name === field.name);
|
|
361
|
+
if (!at) return [];
|
|
362
|
+
errors();
|
|
363
|
+
const before = await look();
|
|
364
|
+
const filled = await evaluate(pageFill, [at.x, at.y, text]).catch(() => null);
|
|
365
|
+
if (!filled) return [];
|
|
366
|
+
await page.keyboard.press('Enter').catch(() => {});
|
|
367
|
+
await sleep(timing.settleMs);
|
|
368
|
+
const what = `${label} was entered in ${q(field.name)} and Enter was pressed`;
|
|
369
|
+
const found = await judge(what, { before, softLock: false });
|
|
370
|
+
if (text === ODD_TEXT && await evaluate(pageMarkup, MARKUP_ID).catch(() => false)) found.push({ oracle: 'markup', severity: 'major', category: 'bug', title: 'Text the player types is inserted into the page as markup', description: `Text typed into ${q(field.name)} that contained a markup tag was put into the page as markup, not shown as the characters typed. A player's name or message can change the page it is shown on.` });
|
|
371
|
+
if (text.length >= 1000) { const over = await evaluate(pageOverflow, 3).catch(() => null); const long = over ? over.found.find(o => /A{20}/.test(o.text)) : null; if (long) found.push({ oracle: 'overflow_input', severity: 'minor', category: 'ux', title: 'Very long typed text runs out of its box', description: `After ${label} was entered in ${q(field.name)}, the game showed it ${long.px} pixels ${long.how}. The field takes ${filled.max ? `up to ${filled.max}` : 'any number of'} characters.` }); }
|
|
372
|
+
return found.map(h => ({ ...h, text, label }));
|
|
373
|
+
};
|
|
374
|
+
for (const [label, text] of [['nothing', ''], [`${timing.longText} characters`, 'A'.repeat(timing.longText)], ['unusual text (markup, quotes, other scripts, an emoji)', ODD_TEXT]]) hits.push(...await tryText(label, text));
|
|
375
|
+
const back = (await look()).fields.find(f => f.name === field.name);
|
|
376
|
+
if (back) await evaluate(pageFill, [back.x, back.y, '']).catch(() => {});
|
|
377
|
+
await evaluate(pageRings, true).catch(() => {});
|
|
378
|
+
return { hits, what: `text was entered in ${q(field.name)}`, again: async hit => (await tryText(hit.label, hit.text)).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await run('menu', async () => {
|
|
382
|
+
const now = await look();
|
|
383
|
+
const opener = pressable(now.buttons).find(b => MENU.test(b.name));
|
|
384
|
+
if (!opener) return { skip: 'no menu, shop, settings or help button was found on the page play ended on' };
|
|
385
|
+
const numbers = text => new Map(readings(text).map(r => [r.label, r.value]));
|
|
386
|
+
const what = `${q(opener.name)} was opened and closed twice, the second time at once`;
|
|
387
|
+
let opened = true;
|
|
388
|
+
const once = async () => {
|
|
389
|
+
// Something is done first: a menu that undoes what was just done shows only when there is something to undo.
|
|
390
|
+
for (const name of canaries) await click(name);
|
|
391
|
+
errors();
|
|
392
|
+
const before = await look();
|
|
393
|
+
const n0 = numbers(before.text);
|
|
394
|
+
const first = await click(opener.name);
|
|
395
|
+
if (!first.ok || !first.changed) { opened = false; return []; }
|
|
396
|
+
await comeBack(before);
|
|
397
|
+
const again = (await look()).buttons.find(b => b.name === opener.name);
|
|
398
|
+
if (again) { await page.mouse.click(again.x, again.y).catch(() => {}); await page.keyboard.press('Escape').catch(() => {}); await sleep(timing.settleMs); }
|
|
399
|
+
await comeBack(before);
|
|
400
|
+
const n1 = numbers((await look()).text);
|
|
401
|
+
const found = await judge(what, { before });
|
|
402
|
+
for (const [label, was] of n0) { if (!n1.has(label) || n1.get(label) === was || CLOCK.test(label)) continue; found.push({ oracle: 'menu_state', key: label, severity: 'major', category: 'bug', title: `Opening and closing ${q(opener.name)} changes "${label}"`, description: `"${label}" was ${was} before ${q(opener.name)} was opened and ${n1.get(label)} after it was closed again. Nothing was done in between but opening and leaving it.` }); break; }
|
|
403
|
+
return found;
|
|
404
|
+
};
|
|
405
|
+
const hits = await once();
|
|
406
|
+
if (!opened) return { skip: `clicking ${q(opener.name)} did not open anything` };
|
|
407
|
+
return { hits, what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
await run('pause', async () => {
|
|
411
|
+
const now = await look();
|
|
412
|
+
const control = now.buttons.find(b => !b.disabled && PAUSE.test(b.name));
|
|
413
|
+
if (!control) return { skip: 'no pause button was found on the page play ended on' };
|
|
414
|
+
const what = `the game was paused with ${q(control.name)} and resumed`;
|
|
415
|
+
const frames = () => evaluate(() => new Promise(resolve => { let n = 0; const tick = () => { n += 1; requestAnimationFrame(tick); }; requestAnimationFrame(tick); setTimeout(() => resolve(n), 400); })).catch(() => null);
|
|
416
|
+
const moving = async () => { const a = await print(); await sleep(400); const b = await print(); return Boolean(a && b && significant(screenDelta(a, b))); };
|
|
417
|
+
const once = async () => {
|
|
418
|
+
errors();
|
|
419
|
+
const before = await look();
|
|
420
|
+
const movedBefore = await moving();
|
|
421
|
+
const paused = await click(control.name);
|
|
422
|
+
if (!paused.ok) return [];
|
|
423
|
+
const resume = pressable((await look()).buttons).find(b => RESUME.test(b.name) || PAUSE.test(b.name));
|
|
424
|
+
if (resume) await click(resume.name);
|
|
425
|
+
const found = await judge(what, { before });
|
|
426
|
+
// The page still draws frames; a game that moved before the pause and stands still after the resume did not come back.
|
|
427
|
+
if (movedBefore && found.length === 0 && (await frames()) !== null && !(await moving())) found.push({ oracle: 'pause_stuck', severity: 'major', category: 'bug', title: `The game does not come back after a pause with ${q(control.name)}`, description: `Before the pause the screen moved on its own. After pausing with ${q(control.name)} and resuming, it stood still: the game stayed paused, or its loop did not start again.` });
|
|
428
|
+
return found;
|
|
429
|
+
};
|
|
430
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
await run('opposite', async () => {
|
|
434
|
+
if (!keyboard) return { skip: 'the game has no canvas and play pressed no key, so it does not seem to be played by keys' };
|
|
435
|
+
const what = `opposite keys were held together (${OPPOSITES.map(p => p.join(' with ')).join(', ')})`;
|
|
436
|
+
const once = async () => {
|
|
437
|
+
errors();
|
|
438
|
+
const before = await look();
|
|
439
|
+
for (const [a, b] of OPPOSITES) { await page.keyboard.down(a).catch(() => {}); await page.keyboard.down(b).catch(() => {}); await sleep(timing.holdMs); await page.keyboard.up(a).catch(() => {}); await page.keyboard.up(b).catch(() => {}); await sleep(100); }
|
|
440
|
+
await sleep(timing.settleMs);
|
|
441
|
+
return judge(what, { before });
|
|
442
|
+
};
|
|
443
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
await run('edges', async () => {
|
|
447
|
+
if (!keyboard) return { skip: 'the game has no canvas and play pressed no key, so there is no player to push to an edge' };
|
|
448
|
+
const what = 'the player was pushed to the edges of the play area';
|
|
449
|
+
const once = async () => {
|
|
450
|
+
errors();
|
|
451
|
+
const before = await look();
|
|
452
|
+
for (const key of ['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown']) {
|
|
453
|
+
if (left() < 4000 || stopped()) break;
|
|
454
|
+
const from = Date.now();
|
|
455
|
+
await page.keyboard.down(key).catch(() => {});
|
|
456
|
+
let last = await print();
|
|
457
|
+
while (Date.now() - from < timing.edgeMaxMs) { await sleep(timing.edgeHoldMs); const now = await print(); const moved = last && now && significant(screenDelta(last, now)); last = now; if (!moved) break; }
|
|
458
|
+
await page.keyboard.up(key).catch(() => {});
|
|
459
|
+
await sleep(80);
|
|
460
|
+
}
|
|
461
|
+
await sleep(timing.settleMs);
|
|
462
|
+
return judge(what, { before });
|
|
463
|
+
};
|
|
464
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
await run('order', async () => {
|
|
468
|
+
const now = await look();
|
|
469
|
+
const list = pressable(now.buttons).filter(b => !UNSEEN_EFFECT.test(b.name)).slice(0, timing.maxSweep).reverse();
|
|
470
|
+
if (list.length < 2) return { skip: 'the page lists fewer than two buttons to press out of order' };
|
|
471
|
+
const what = 'the buttons were pressed in reverse order with no pause';
|
|
472
|
+
const once = async () => {
|
|
473
|
+
errors();
|
|
474
|
+
const before = await look();
|
|
475
|
+
for (const b of list) { const at = (await controls()).buttons.find(x => x.name === b.name && !x.disabled); if (at) { await page.mouse.click(at.x, at.y).catch(() => {}); await sleep(60); } }
|
|
476
|
+
await sleep(timing.settleMs);
|
|
477
|
+
return judge(what, { before });
|
|
478
|
+
};
|
|
479
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
await run('loading', async () => {
|
|
483
|
+
const what = 'clicks and keys were sent while the page was still loading';
|
|
484
|
+
const size = page.viewportSize() || { width: 1280, height: 720 };
|
|
485
|
+
const once = async () => {
|
|
486
|
+
errors();
|
|
487
|
+
const going = page.reload({ waitUntil: 'load', timeout: 15000 }).then(() => true, () => false);
|
|
488
|
+
const until = Date.now() + timing.loadInputMs;
|
|
489
|
+
while (Date.now() < until) { await page.mouse.click(Math.round(size.width / 2), Math.round(size.height / 2)).catch(() => {}); await page.keyboard.press('Enter').catch(() => {}); await page.keyboard.press(' ').catch(() => {}); await sleep(40); }
|
|
490
|
+
const loaded = await going;
|
|
491
|
+
await sleep(timing.settleMs + 400);
|
|
492
|
+
if (!loaded) return [{ oracle: 'no_load', severity: 'major', category: 'bug', title: 'The game does not load when input arrives while it is loading', description: 'With clicks and keys sent while the page was loading, it did not finish loading. It had loaded when left alone.' }];
|
|
493
|
+
return judge(what, { softLock: false });
|
|
494
|
+
};
|
|
495
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// Try each suspect again where it stands; a game left stuck waits for the replay.
|
|
499
|
+
for (const s of suspects) {
|
|
500
|
+
s.tries = 0; s.hits = 0; s.why = null; s.uncounted = false;
|
|
501
|
+
if (['soft_lock', 'frozen', 'crash', 'blank', 'pause_stuck', 'no_load'].includes(s.oracle) && s.probe !== 'loading') { s.why = 'the game was left stuck, so it can only be tried again from a fresh start'; continue; }
|
|
502
|
+
for (let i = 0; i < retries && left() > 3000 && !stopped() && typeof s.again === 'function'; i += 1) {
|
|
503
|
+
const r = await Promise.resolve().then(() => s.again(s)).catch(() => false);
|
|
504
|
+
// A try the game could not take is not a try: it is never counted as "not reproduced" (the replay tries it from a fresh start).
|
|
505
|
+
if (r && typeof r === 'object' && r.untried) { if (!s.tries) s.why = r.untried; break; }
|
|
506
|
+
// An error nothing caught can leave the game unable to raise it again where it stands (a game loop it
|
|
507
|
+
// stopped): a second try that sees nothing is not counted, and the replay tries it from a fresh start.
|
|
508
|
+
if (!r && s.thrown) { if (!s.tries) { s.why = 'an error nothing caught can leave the game unable to raise it again where it stands, so the run\'s replay tries it from a fresh start'; s.uncounted = true; } break; }
|
|
509
|
+
s.tries += 1;
|
|
510
|
+
if (r) s.hits += 1;
|
|
511
|
+
}
|
|
512
|
+
if (!s.tries && retries > 0 && !s.why) s.why = 'no time was left';
|
|
513
|
+
}
|
|
514
|
+
} finally {
|
|
515
|
+
if (focusMark) await evaluate(() => { const el = document.querySelector('[data-ravensight-play-focus]'); if (el) { el.removeAttribute('data-ravensight-play-focus'); el.focus(); } }).catch(() => {});
|
|
516
|
+
await evaluate(pageRings, false).catch(() => {});
|
|
517
|
+
if (session.dismissDialogs) session.dismissDialogs(false);
|
|
518
|
+
await Promise.resolve().then(() => session.parkClock()).catch(() => {});
|
|
519
|
+
}
|
|
520
|
+
return { checks, suspects: suspects.map(({ again: _again, ...rest }) => rest), canaries, elapsedMs: Date.now() - started };
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* What the probes found, as findings of the runner (./honesty.js), each
|
|
525
|
+
* saying how often it came back.
|
|
526
|
+
*
|
|
527
|
+
* @param {{suspects: Array<Object>}|null} pass
|
|
528
|
+
* @param {{actionRecords?: Array<Object>, action?: number}} [context]
|
|
529
|
+
* @returns {Array<Object>}
|
|
530
|
+
*/
|
|
531
|
+
export function probeFindings(pass, { actionRecords = [], action = 0 } = {}) {
|
|
532
|
+
if (!pass || !Array.isArray(pass.suspects)) return [];
|
|
533
|
+
return pass.suspects.map(s => runnerFinding({
|
|
534
|
+
severity: s.severity, category: s.category, title: s.title,
|
|
535
|
+
description: `${s.description} ${reproducedWords(s.tries || 0, s.hits || 0, s.why, { uncounted: Boolean(s.uncounted) })} Found by a scripted tester probe after play.`,
|
|
536
|
+
steps: [...stepsBefore(actionRecords), `Then: ${s.what}.`], screenshot: s.screenshot, action, key: `probe:${s.probe}:${s.oracle}:${s.key || ''}`
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* The probes' seat on the run's one replay (./reportChecks.js
|
|
542
|
+
* replayWebFindings): the report findings that came from a probe, by id, and
|
|
543
|
+
* `end(driver)`, which runs those probes once more on the replay's page and
|
|
544
|
+
* answers, per finding id, whether the same thing happened. Null when no
|
|
545
|
+
* probe found anything.
|
|
546
|
+
*
|
|
547
|
+
* @param {Object} args
|
|
548
|
+
* @returns {{ids: Array<string>, end: Function}|null}
|
|
549
|
+
*/
|
|
550
|
+
export function probeObserver({ probes, report, actionRecords = [], signal = null, run = runTesterProbes }) {
|
|
551
|
+
const suspects = probes && Array.isArray(probes.suspects) ? probes.suspects.filter(s => s.probe !== 'loading') : [];
|
|
552
|
+
const findings = report && Array.isArray(report.findings) ? report.findings : [];
|
|
553
|
+
const tied = suspects.map(s => ({ suspect: s, finding: findings.find(f => f && f.title === String(s.title).slice(0, 120)) })).filter(entry => entry.finding && typeof entry.finding.id === 'string');
|
|
554
|
+
if (tied.length === 0) return null;
|
|
555
|
+
return {
|
|
556
|
+
ids: tied.map(entry => entry.finding.id),
|
|
557
|
+
async end(driver) {
|
|
558
|
+
const out = new Map();
|
|
559
|
+
if (!driver || typeof driver.edgeSession !== 'function') return out;
|
|
560
|
+
const again = await run({ driver, actionRecords, signal, only: [...new Set(tied.map(entry => entry.suspect.probe))], retries: 0, save: false });
|
|
561
|
+
for (const { suspect, finding } of tied) {
|
|
562
|
+
if (!again.checks.some(check => check.name === suspect.probe && check.status !== 'not_checked')) continue;
|
|
563
|
+
out.set(finding.id, again.suspects.some(s => s.probe === suspect.probe && s.oracle === suspect.oracle && s.key === suspect.key));
|
|
564
|
+
}
|
|
565
|
+
return out;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const STATUS = Object.freeze({ ok: 'tested, nothing went wrong in this check', problem: 'tested, PROBLEM', note: 'note', not_checked: 'not tested' });
|
|
571
|
+
|
|
572
|
+
/** The probes in words for report.md: one line each, tested or not and why. */
|
|
573
|
+
export function probesMarkdown(pass) {
|
|
574
|
+
if (!pass || !Array.isArray(pass.checks) || pass.checks.length === 0) return 'No probe ran.';
|
|
575
|
+
const lines = PROBES.map(([id, title]) => {
|
|
576
|
+
const check = pass.checks.find(c => c.name === id);
|
|
577
|
+
if (!check) return `- **${title}**: not tested. The probes ended before it.`;
|
|
578
|
+
return `- **${title}**: ${STATUS[check.status] || check.status}. ${String(check.detail || '').replace(/\.?$/, '.')}`;
|
|
579
|
+
});
|
|
580
|
+
lines.push('', `A soft lock was ${pass.canaries && pass.canaries.length ? `watched for after each probe, with ${pass.canaries.length === 1 ? 'a button' : `${pass.canaries.length} buttons`} that changed the screen twice running` : 'not watched for: no button play pressed changed the screen twice running, so there was nothing to compare against'}. These probes are scripted. Not tested never means it works.`);
|
|
581
|
+
return lines.join('\n').replace(/[\u2013\u2014]/g, ',');
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export default { runTesterProbes, probeFindings, probesMarkdown, probeObserver, namedInPlay, workedButtons, brokenNow, reproducedWords };
|