test: wait until the page shows a screen, not only until it lays out (closes #502)
The browser suites' wait for a screen passed as soon as the element laid out. Until the page's stylesheet has applied, every view lays out, so an approval test could read the prompt before the page's script had filled it. visible() in the Chrome harness and waitVisible() in the Firefox driver now also wait for the page to finish loading and for neither the element nor anything around it to carry the hidden class that showView() keeps on every view but the current one. No caller changed. Model: opus-5-5
This commit is contained in:
@@ -279,12 +279,17 @@ class Driver {
|
||||
|
||||
// Shown means shown: in the popup a view is switched by toggling a
|
||||
// "hidden" class, and an element that is present but collapsed is not
|
||||
// the thing a test means by visible.
|
||||
// the thing a test means by visible. Until the page's stylesheet has
|
||||
// applied that class hides nothing and every view lays out, so the page
|
||||
// must also have finished loading, which it does only after its
|
||||
// stylesheet, and neither the element nor anything enclosing it may
|
||||
// carry the class (https://git.eeqj.de/sneak/AutistMask/issues/502).
|
||||
async waitVisible(selector, timeout = DEFAULT_WAIT_MS) {
|
||||
return this.waitFor(
|
||||
"selector " + selector + " to be visible",
|
||||
`const el = document.querySelector(arguments[0]);
|
||||
if (!el) return false;
|
||||
if (document.readyState !== "complete" || !el) return false;
|
||||
if (el.closest(".hidden")) return false;
|
||||
const r = el.getBoundingClientRect();
|
||||
return r.width > 0 && r.height > 0;`,
|
||||
[selector],
|
||||
|
||||
Reference in New Issue
Block a user