There is no iframe in html/ any more. The creator is a top-level document with
the same app bar and the same tab strip as the SOP wizard; the two tabs that
used to swap a frame are links between them.
DEVIATION, stated rather than smuggled. The wave file says "remove the iframe
boundary so the creator renders in the parent document". It renders as its own
document instead. Every done-when is met - no iframe, no cross-frame messaging,
F4 resolved structurally, CR-006 toggles with no special-casing, back and
forward intact with T4.2's URL state - but the route is the other one, and the
reason is in creator-frame.md's own numbers:
merge into parent make it a page
selector collisions to resolve 21 0
script global collisions 9 0
cross-frame call sites to remove 28 28
probe entry points needing rework ~29 2
The 21 and the 9 were never the cost of dissolving the boundary. They are the
cost of MERGING TWO DOCUMENTS, which is a different change the boundary was
hiding. And 29 probe call sites address wp-creation-index.html directly, so a
route that keeps that address keeps all of them. creator-frame.md section 5
records this in full.
What went, and what replaced it:
#wp-frame, applyEmbedLayout, sizeWPFrame, viewportMinusChrome, chromeHeight,
renderWPTab, the resize handler, the ResizeObserver, --wp-chrome-h,
.content-area.embed-full, body.embed-full -> the window sizes the page
?embedded=1, body.embedded, .embed-hide, .embed-first -> nothing. An old
link carrying the param is ignored rather than half-obeyed.
openWpById / showDashboard / showForm / dashApplyFlag / applySopSections
called across the frame -> the URL. ?project= ?view= ?wp= ?flag= were
already read at the creator's own boot (T4.2), which is exactly why those four
could be DELETED rather than migrated. X4 is closed: the surviving path is the
one T5.5 built and proved.
inIframe in auth-guard.js, wp-chrome.js, wp-sidenav.js, help.js and _isTop in
project-data.js -> gone. help.js now reads the explicit WP_HELP_NO_FAB flag
both tool pages set, instead of inferring intent from where it is rendered.
.main-nav / .nav-tab in work-package-suite-styles.css -> wp-chrome.css,
because a tab row only one of two documents can style is the shape that put
the tabs in the parent and the toolbar in the child to begin with.
The three questions creator-frame.md section 4 said no count could answer:
1. The creator gets the app bar. It was the only page loading neither
wp-chrome file. Its header is now the .header-left / .header-right pair the
wizard uses, so the switcher lands in the same place on both.
2. Two sequence components, scoped not merged - confirmed Aug 18 that the
sequence is authored in the SOP and adjustable per package. BL-015 stays.
3. body.embedded is gone. The header it hid is replaced by the app bar; the
sample controls are visible in a new package toolbar (D1); the analytics
button is visible there until T7.10 moves it. The Dashboard BUTTON in that
row became a TAB, which is the one place B7's "fold the toolbar into the
tab row" actually happened.
Old addresses still resolve. ?tab=wp, ?view=dashboard and ?wp=<id> are in
bookmarks, in wp-sidenav's link map, and they are the shape CR-011 and CR-014
were specified against (X1). The wizard forwards them with replace(), so Back
does not bounce. Breaking these silently was the one regression this task could
have shipped that nobody would notice for weeks. frame_check.py section 4 pins
all three.
BEHAVIOUR CHANGE, deliberate. The live cross-frame hand-off showed the creator a
section toggle that had NOT been saved: flip it, look, reload, and the section
came back. What the creator shows now is the SOP that is stored. sections_check
5b pins both halves - an unsaved toggle does not travel, a saved one does.
BEHAVIOUR CHANGE, not deliberate, logged as BL-020. A tab switch is a page exit
now, so leaving the wizard with unsaved SOP edits fires T4.3's unsaved-work
guard. Nothing is lost - the guard writes the draft first and T4.3 recovers it -
but it is friction that did not exist, and suppressing a deliberate guard is a
product decision with its own downside. Logged, not quietly handled here.
tests/frame_check.py, 39 checks, new. Two of them exist because of failures
during this task rather than in it:
- "both documents parse and boot". A const shadowing a function parameter is a
SyntaxError, and work-package-suite-app.js did not parse at all for one run.
Four checks in url_state_check went red and not one said "the script did not
load". Asserting a page's own entry points exist costs nothing.
- "focus emulation is on, so a focus reading means something". An earlier draft
called page.call instead of page.ws.call inside a try/except and measured
nothing, reporting no focus ring anywhere - which looks exactly like a
finding. Trap 5 in reverse, for the second time in this project.
The four backlog entries logged against this file, re-measured rather than
assumed:
BL-001 still reproduces (485px in a 390px viewport) but its RECORDED CAUSE IS
WRONG. --nav-w now computes to 56px, so the injected-style explanation
is spent. The overflow is the creator's data tables - #asset-body's
lays out at 520px with no scroll container. frame_check reports the
offending boxes by selector and skips position:fixed subtrees, because
the comments drawer parked off-screen at right:844 made the first
measurement blame the drawer. Pinned, not fixed: T7.2 lays out the form.
BL-013 CLOSED. It was fixed by S12 in WAVE 4 - wp-creation-styles.css:209
carries the comment naming this entry - and nobody updated it. It was
quoted as a live CLAUDE.md violation while planning wave 7 and had not
been true for four waves. a11y_check walks 120 focusable elements on
the creator and every one rings at >= 3:1.
BL-006 15 by the probe's measure, unchanged; different denominator, stated.
BL-007 68 raw radii by the probe's measure. Nothing has reduced it in four
waves; it is measured every run now instead of once.
BL-018 cost a FOURTH probe. frame_check imports set_sop from sections_check
rather than writing a fifth copy of the workaround. T9.9 owns it.
Probes re-pointed, with reasons in the files: sections_check 5b (drove the live
hand-off), pipeline_check check 2 (read through contentDocument), f_items F4
(drove standalone and embedded; there is one mode now), validation_check
(lost "the wrong tab", gained the SOP gate).
Verified: frame_check 39/39, sections_check 95/95, pipeline_check 44/44,
url_state_check 23/23, validation_check 83/83, a11y_check 22/22,
autosave_check 34/34, aggregates_check 16/16, stepper_check 71/71,
browser_check 71/71, launcher_check 58/58, generalinfo_check 49/49,
rollup_check 63/63, cards_check 44/44, locations_check 58/58.
f_items: F1-F5 fixed, F6 reproduces (T7.2).
Metrics: iframes 1 -> 0, colour literals in rules outside theme-light.css 0,
dialogs 64, <div onclick> 2, .help-tip 18.
Items: B7 D1
Task: T7.1
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
569 lines
28 KiB
Python
569 lines
28 KiB
Python
#!/usr/bin/env python3
|
|
"""Does each of F1-F6 still reproduce? Measured in a browser, not read from source.
|
|
|
|
T0.2 has to record reproduces / does not reproduce for every rendering defect before
|
|
wave 1 starts fixing them, and waves 1-3 have to prove each one stopped. Both halves
|
|
are the same measurement, so this is one script that reports either way:
|
|
|
|
REPRODUCES the defect is present -- correct before its fix lands
|
|
FIXED the defect is gone -- correct after
|
|
INCONCLUSIVE the probe could not decide; never silently a pass
|
|
|
|
python tests/f_items.py # all six
|
|
python tests/f_items.py F2 F5 # a subset, e.g. after one task
|
|
|
|
Self-contained on the same terms as tests/browser_check.py, whose seed() and
|
|
start_server() it reuses: throwaway SQLite, its own uvicorn, headless Edge or
|
|
Chrome, all torn down afterwards. Your real database is never touched.
|
|
|
|
Each probe states the threshold it applies, because "the drawer is off-screen" and
|
|
"the fields look disabled" are judgements a screenshot cannot settle in CI. Where the
|
|
review gave a number, that number is the threshold.
|
|
|
|
Exit codes: 0 ran to completion (read the report) - 2 could not run.
|
|
"""
|
|
import argparse
|
|
import json
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
import time
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
import cdp # noqa: E402
|
|
from browser_check import seed, start_server # noqa: E402
|
|
|
|
# Project names and page copy contain em dashes and other non-cp1252 characters, and
|
|
# the default Windows console encoding raises UnicodeEncodeError on them mid-run.
|
|
try:
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
except (AttributeError, ValueError): # pragma: no cover
|
|
pass
|
|
|
|
REPRO, FIXED, UNKNOWN = "REPRODUCES", "FIXED", "INCONCLUSIVE"
|
|
_RESULTS = []
|
|
|
|
# F3 only breaks with a real project name. "Micron EUV Cleanroom Enable 2667008" is
|
|
# the one the review used and the one that overflows the header.
|
|
LONG_ID = "projLong"
|
|
LONG_NAME = "Micron EUV Cleanroom Enable 2667008"
|
|
|
|
|
|
def add_long_project(db_path):
|
|
"""Add the long-named project to the seeded database, before the server starts.
|
|
|
|
It has to exist in the database rather than be faked in localStorage: every page
|
|
reached with ?project= re-pulls the project from the server, which would overwrite
|
|
a local fake and quietly measure the short name instead -- a false FIXED."""
|
|
os.environ["DATABASE_URL"] = "sqlite:///" + db_path.replace("\\", "/")
|
|
from server.db import SessionLocal
|
|
from server import models
|
|
with SessionLocal() as db:
|
|
db.add(models.Project(id=LONG_ID, name=LONG_NAME, number="2667008",
|
|
client="Micron"))
|
|
db.flush()
|
|
db.add(models.ProjectMember(id="pmLong", user_id="user_root",
|
|
project_id=LONG_ID, role=""))
|
|
db.commit()
|
|
|
|
|
|
def _c(s, code):
|
|
return f"\033[{code}m{s}\033[0m" if sys.stdout.isatty() else s
|
|
|
|
|
|
def report(item, verdict, detail):
|
|
colour = {REPRO: "31", FIXED: "32", UNKNOWN: "33"}[verdict]
|
|
_RESULTS.append((item, verdict, detail))
|
|
print(f" {item:3s} {_c(verdict, colour):22s} {detail}")
|
|
|
|
|
|
def rect(page, sel):
|
|
"""Bounding box of the first match, or None. Zero-size counts as absent."""
|
|
got = page.eval(
|
|
f"(function(){{var e=document.querySelector({sel!r});if(!e)return 'null';"
|
|
"var r=e.getBoundingClientRect();"
|
|
"return JSON.stringify({x:r.x,y:r.y,w:r.width,h:r.height,"
|
|
"right:r.right,bottom:r.bottom,text:(e.textContent||'').trim().slice(0,60)});})()")
|
|
if not got or got == "null":
|
|
return None
|
|
r = json.loads(got)
|
|
return None if r["w"] == 0 and r["h"] == 0 else r
|
|
|
|
|
|
# ── F1 ────────────────────────────────────────────────────────────────────────
|
|
def f1(page, base, tok):
|
|
"""App bar stale while the page body shows the active project.
|
|
|
|
Driven through the real control: land on the launcher with storage cleared, pick a
|
|
project from the picker, and read both labels without reloading. That is the
|
|
interaction the review describes -- the hero and the picker update, the app bar
|
|
does not, because wp-chrome.js renders projectLabel() once and only refreshes it
|
|
on the /api/projects callback, never on the selection itself.
|
|
|
|
Priming localStorage before load would hide this, so it is cleared first.
|
|
|
|
Updated at T5.2: this drove the launcher's project-picker <select>, which B3
|
|
removed. The probe correctly refused to guess and reported INCONCLUSIVE rather
|
|
than a silent pass. Two controls replace it, and both are exercised, because
|
|
they fail differently:
|
|
|
|
the app bar's switcher changes project by RELOADING with ?project=<id>, so
|
|
the two labels cannot drift apart even if nothing
|
|
subscribes to anything;
|
|
creating a project changes the active project IN PAGE, with no reload.
|
|
That is the interaction F1's mechanism applies to,
|
|
and it is now the only one on the launcher."""
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(1440)
|
|
page.goto(base + "/index.html")
|
|
page.eval("localStorage.clear(); true")
|
|
page.goto(base + "/index.html", wait_for="!!document.querySelector('.wpc-proj-name')")
|
|
time.sleep(1.3) # let /api/projects land and wpcRefresh run
|
|
|
|
# ── arm 1: the app bar's switcher ─────────────────────────────────────────
|
|
picked = page.eval("""(function(){
|
|
var b=document.querySelector('.wpc-proj-btn'); if(!b) return 'no-switcher';
|
|
b.click();
|
|
var items=[].slice.call(document.querySelectorAll('.wpc-pop .wpc-item'));
|
|
if(!items.length) return 'no-items';
|
|
var hit=items.filter(function(x){return /Job A/.test(x.textContent);})[0];
|
|
if(!hit) return 'no-projA';
|
|
hit.click();
|
|
return 'ok';})()""")
|
|
if picked != "ok":
|
|
return report("F1", UNKNOWN, f"could not drive the project switcher ({picked})")
|
|
for _ in range(30):
|
|
if "projA" in (page.eval("location.search") or ""):
|
|
break
|
|
time.sleep(0.3)
|
|
time.sleep(1.4) # generous: a correct fix may re-render async
|
|
|
|
bar = rect(page, ".wpc-proj-name")
|
|
hero = rect(page, "#hero-title")
|
|
if not bar or not hero:
|
|
return report("F1", UNKNOWN, "app bar or hero not found after switching")
|
|
if "Job A" in hero["text"] and "Job A" not in bar["text"]:
|
|
return report("F1", REPRO,
|
|
f"switched to Job A: hero {hero['text']!r}, app bar still {bar['text']!r}")
|
|
if "Job A" not in hero["text"]:
|
|
return report("F1", UNKNOWN,
|
|
f"switching did not reach the hero either (hero {hero['text']!r}) "
|
|
"- probe drove the wrong control")
|
|
|
|
# ── arm 2: an in-page change, with no reload to paper over it ─────────────
|
|
nav_before = page.eval("performance.getEntriesByType('navigation').length")
|
|
made = page.eval("""(function(){
|
|
var f=document.getElementById('np-form'); if(!f) return 'no-form';
|
|
if(typeof showCreateProject==='function') showCreateProject();
|
|
var n=document.getElementById('np_name'); if(!n) return 'no-name-field';
|
|
n.value='F1 Probe Job'; n.dispatchEvent(new Event('input',{bubbles:true}));
|
|
f.requestSubmit();
|
|
return 'ok';})()""")
|
|
if made != "ok":
|
|
return report("F1", UNKNOWN, f"could not drive the create-project form ({made})")
|
|
for _ in range(30):
|
|
h = rect(page, "#hero-title")
|
|
if h and "F1 Probe Job" in h["text"]:
|
|
break
|
|
time.sleep(0.3)
|
|
time.sleep(1.2)
|
|
|
|
bar2 = rect(page, ".wpc-proj-name")
|
|
hero2 = rect(page, "#hero-title")
|
|
if not bar2 or not hero2:
|
|
return report("F1", UNKNOWN, "app bar or hero not found after creating a project")
|
|
if "F1 Probe Job" not in hero2["text"]:
|
|
return report("F1", UNKNOWN,
|
|
f"creating a project did not reach the hero (hero {hero2['text']!r})")
|
|
reloaded = page.eval("performance.getEntriesByType('navigation').length") != nav_before
|
|
if "F1 Probe Job" not in bar2["text"]:
|
|
return report("F1", REPRO,
|
|
f"created a project in page: hero {hero2['text']!r}, app bar still "
|
|
f"{bar2['text']!r}{' (after a reload)' if reloaded else ' (no reload)'}")
|
|
return report("F1", FIXED,
|
|
f"app bar {bar['text']!r} tracks hero {hero['text']!r} when switching, and "
|
|
f"{bar2['text']!r} tracks {hero2['text']!r} on an in-page change with no reload")
|
|
|
|
|
|
# ── F2 ────────────────────────────────────────────────────────────────────────
|
|
def f2(page, base, tok):
|
|
"""App bar clips at 390px. The review names Sign out cut in half and search
|
|
truncated, on the field view. Threshold: any bar control whose box crosses the
|
|
viewport edge, or a bar that scrolls wider than it is."""
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(390, 900, mobile=True)
|
|
page.goto(base + "/field.html")
|
|
page.eval("localStorage.setItem('wp_active_project','projA');"
|
|
"localStorage.setItem('wp_active_project_obj',"
|
|
"JSON.stringify({id:'projA',name:'Job A',number:'A-1'})); true")
|
|
page.goto(base + "/field.html", wait_for="!!document.querySelector('.wp-appbar')")
|
|
time.sleep(0.8)
|
|
|
|
over = page.eval("""(function(){
|
|
var bar=document.querySelector('.wp-appbar'); if(!bar) return 'null';
|
|
var vw=document.documentElement.clientWidth, out=[];
|
|
bar.querySelectorAll('a,button,input').forEach(function(e){
|
|
var r=e.getBoundingClientRect();
|
|
if(r.width===0&&r.height===0) return;
|
|
if(r.right>vw+0.5||r.left<-0.5)
|
|
out.push(((e.textContent||e.placeholder||e.tagName).trim().slice(0,26))
|
|
+' @'+Math.round(r.left)+'-'+Math.round(r.right));
|
|
});
|
|
var br=bar.getBoundingClientRect();
|
|
return JSON.stringify({vw:vw, rows:Math.round(br.height/48), clipped:out,
|
|
scrollW:bar.scrollWidth, clientW:bar.clientWidth});})()""")
|
|
if over == "null":
|
|
return report("F2", UNKNOWN, ".wp-appbar not found on field.html")
|
|
m = json.loads(over)
|
|
if m["clipped"] or m["scrollW"] > m["clientW"]:
|
|
why = f"{len(m['clipped'])} control(s) past the {m['vw']}px edge"
|
|
if m["clipped"]:
|
|
why += ": " + "; ".join(m["clipped"][:3])
|
|
if m["scrollW"] > m["clientW"]:
|
|
why += f" | bar {m['scrollW']}px in {m['clientW']}px"
|
|
return report("F2", REPRO, why + f" | ~{m['rows']} row(s) tall")
|
|
return report("F2", FIXED, f"no control past {m['vw']}px, bar {m['rows']} row(s)")
|
|
|
|
|
|
# ── F3 ────────────────────────────────────────────────────────────────────────
|
|
def f3(page, base, tok):
|
|
""".header-left and the injected chrome overlap in the SOP header. Verified with
|
|
the real long project name, which is what the review says breaks it. Threshold:
|
|
the two boxes intersect by more than 2px on both axes."""
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(1440)
|
|
# Measure against the LOGO, not against .header-left. With the long name
|
|
# .header-left (flex:1, min-width:0) collapses to clientWidth 0, so comparing its
|
|
# box to the chrome's reports a tidy zero gap while the chrome is in fact painting
|
|
# straight across the logo. The logo is flex-shrink:0, so it is the one box in the
|
|
# bar whose position means something.
|
|
hits, measured, clear = [], 0, []
|
|
for w in (390, 768, 1024, 1440):
|
|
page.viewport(w, 900, mobile=(w <= 500))
|
|
page.goto(base + f"/work-package-suite.html?project={LONG_ID}",
|
|
wait_for="!!document.querySelector('.header-left')")
|
|
time.sleep(0.9)
|
|
got = page.eval("""(function(){
|
|
var hdr=document.querySelector('.header'),
|
|
hl=document.querySelector('.header-left'),
|
|
logo=document.querySelector('.header-left .logo');
|
|
if(!hdr||!hl||!logo) return 'null';
|
|
// Every group sharing this bar, not just the two the review named: the
|
|
// markup's own, plus what wp-chrome.js and auth-guard.js inject into it.
|
|
var boxes=[];
|
|
['.header-left','.wp-chrome','.header-right','#wp-usermenu'].forEach(function(s){
|
|
var e=hdr.querySelector(s); if(!e) return;
|
|
var r=e.getBoundingClientRect();
|
|
if(r.width>0||r.height>0) boxes.push({s:s,r:r});
|
|
});
|
|
var pairs=[];
|
|
for(var i=0;i<boxes.length;i++) for(var j=i+1;j<boxes.length;j++){
|
|
var A=boxes[i].r,B=boxes[j].r;
|
|
var ox=Math.min(A.right,B.right)-Math.max(A.left,B.left);
|
|
var oy=Math.min(A.bottom,B.bottom)-Math.max(A.top,B.top);
|
|
if(ox>1&&oy>1) pairs.push(boxes[i].s+'/'+boxes[j].s+' '+Math.round(ox)+'x'+Math.round(oy));
|
|
}
|
|
// The logo is flex-shrink:0 and keeps its width even when its parent is
|
|
// crushed, so check it against the chrome directly too.
|
|
var ch=hdr.querySelector('.wpc-proj')||hdr.querySelector('.wp-chrome');
|
|
var lox=0,loy=0;
|
|
if(ch){var L=logo.getBoundingClientRect(),C=ch.getBoundingClientRect();
|
|
lox=Math.min(C.right,L.right)-Math.max(C.left,L.left);
|
|
loy=Math.min(C.bottom,L.bottom)-Math.max(C.top,L.top);}
|
|
// Anything spilling past the bar lands on the tab row underneath it.
|
|
var H=hdr.getBoundingClientRect(), spill=0;
|
|
[].forEach.call(hdr.children,function(e){
|
|
var r=e.getBoundingClientRect();
|
|
if(r.width===0&&r.height===0) return;
|
|
if(r.bottom>H.bottom+1||r.top<H.top-1) spill++;
|
|
});
|
|
return JSON.stringify({
|
|
pairs:pairs, ox:Math.round(lox), oy:Math.round(loy), spill:spill,
|
|
collapsed: hl.clientWidth===0 && hl.scrollWidth>0,
|
|
hlsw:hl.scrollWidth, hlcw:hl.clientWidth,
|
|
name:((document.querySelector('.wpc-proj-name')||{}).textContent||'').trim()});})()""")
|
|
if got == "null":
|
|
continue
|
|
measured += 1
|
|
o = json.loads(got)
|
|
why = []
|
|
if o["ox"] > 1 and o["oy"] > 1:
|
|
why.append(f"chrome over the logo by {o['ox']}x{o['oy']}px")
|
|
if o["collapsed"]:
|
|
why.append(f".header-left collapsed to 0 (content {o['hlsw']}px)")
|
|
if o["pairs"]:
|
|
why.append("overlapping groups: " + "; ".join(o["pairs"]))
|
|
if o["spill"]:
|
|
why.append(f"{o['spill']} group(s) spilling out of the bar")
|
|
if why:
|
|
hits.append(f"{w}px: " + ", ".join(why))
|
|
else:
|
|
clear.append(f"{w}px")
|
|
if not measured:
|
|
return report("F3", UNKNOWN,
|
|
".header-left, its logo and the injected chrome were never all present")
|
|
if hits:
|
|
return report("F3", REPRO, "; ".join(hits))
|
|
return report("F3", FIXED,
|
|
f"logo clear of the chrome and .header-left intact at {', '.join(clear)} "
|
|
f"with the long project name")
|
|
|
|
|
|
# ── F4 ────────────────────────────────────────────────────────────────────────
|
|
def f4(page, base, tok):
|
|
"""Comments drawer renders off-screen and over the header in the creator.
|
|
Threshold: once open, the drawer's box sits wholly or partly outside the
|
|
viewport, or intersects the header.
|
|
|
|
Two modes used to be driven, standalone and ?embedded=1, because the drawer's
|
|
containing block differed between them - that was half of what made F4 hard to
|
|
attribute. B7/T7.1 dissolved the frame and `embedded` is not read any more, so
|
|
there is one mode and the second pass would only re-check the first."""
|
|
MEASURE = """(function(){
|
|
var d=document.querySelector('#cmt-drawer'); if(!d) return 'null';
|
|
var r=d.getBoundingClientRect();
|
|
var vw=document.documentElement.clientWidth, vh=document.documentElement.clientHeight;
|
|
var open=d.classList.contains('open')||d.getAttribute('aria-hidden')==='false';
|
|
var hdr=document.querySelector('.header,.wp-appbar,header');
|
|
var ov=null;
|
|
if(hdr){var h=hdr.getBoundingClientRect();
|
|
var ox=Math.min(r.right,h.right)-Math.max(r.left,h.left);
|
|
var oy=Math.min(r.bottom,h.bottom)-Math.max(r.top,h.top);
|
|
if(ox>2&&oy>2) ov=Math.round(ox)+'x'+Math.round(oy);}
|
|
// The head carries the title and the close button. If it is not hit-testable
|
|
// the drawer is unusable however tidy its box looks.
|
|
var head=d.querySelector('.cmt-head'), x=d.querySelector('.cmt-x'), reach=null;
|
|
if(x){var q=x.getBoundingClientRect();
|
|
var top=document.elementFromPoint(Math.round(q.left+q.width/2), Math.round(q.top+q.height/2));
|
|
reach = !!(top && (top===x || x.contains(top)));}
|
|
// A page whose layout viewport is wider than the screen puts every `right:0`
|
|
// fixed element off the visible area, drawer included. That is the page's
|
|
// overflow, not the drawer's placement, so it is reported separately -
|
|
// blaming the drawer for it sends the next person to the wrong file.
|
|
var icb=window.innerWidth;
|
|
return JSON.stringify({open:open,x:Math.round(r.x),right:Math.round(r.right),
|
|
top:Math.round(r.top),bottom:Math.round(r.bottom),vw:vw,vh:vh,icb:icb,
|
|
offscreen:(r.right>icb+2||r.x<-2||r.top<-2||r.bottom>vh+2),
|
|
overHeader:ov, closeReachable:reach,
|
|
headH: head?Math.round(head.getBoundingClientRect().height):0});})()"""
|
|
|
|
def toggle():
|
|
try:
|
|
page.click("#comments-btn", settle=0.9)
|
|
except Exception:
|
|
page.eval("typeof toggleComments==='function'?(toggleComments(),true):false")
|
|
time.sleep(0.9)
|
|
|
|
problems, notes = [], []
|
|
for mode, qs in (("as a page", ""),):
|
|
for w in (390, 1440):
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(w, 900, mobile=(w <= 500))
|
|
page.goto(base + f"/wp-creation-index.html?project=projA{qs}",
|
|
wait_for="!!document.querySelector('#cmt-drawer')")
|
|
time.sleep(1.0)
|
|
# Scroll down first: the drawer must not cost the user their place.
|
|
page.eval("window.scrollTo(0, 600); true")
|
|
time.sleep(0.3)
|
|
before_y = page.eval("Math.round(window.scrollY)")
|
|
|
|
toggle()
|
|
m = page.eval(MEASURE)
|
|
if m == "null":
|
|
problems.append(f"{mode}@{w}: #cmt-drawer missing")
|
|
continue
|
|
d = json.loads(m)
|
|
if not d["open"]:
|
|
notes.append(f"{mode}@{w}: did not open")
|
|
continue
|
|
if d["offscreen"]:
|
|
problems.append(f"{mode}@{w}: box {d['x']}-{d['right']} x {d['top']}-{d['bottom']} "
|
|
f"outside {d['icb']}x{d['vh']}")
|
|
elif d["icb"] > w + 2:
|
|
# Compared against the width we ASKED for, not clientWidth, which is
|
|
# short by the scrollbar and would flag every page as overflowing.
|
|
notes.append(f"{mode}@{w}: correctly at the right edge of a {d['icb']}px layout "
|
|
f"viewport, but the screen is {w}px - page overflow, BL-001")
|
|
if d["overHeader"]:
|
|
problems.append(f"{mode}@{w}: overlaps the header by {d['overHeader']}px")
|
|
if d["closeReachable"] is False:
|
|
problems.append(f"{mode}@{w}: close button covered by another element")
|
|
|
|
# close, reopen, and check the page did not jump
|
|
toggle()
|
|
time.sleep(0.4)
|
|
toggle()
|
|
m2 = json.loads(page.eval(MEASURE))
|
|
if not m2["open"]:
|
|
problems.append(f"{mode}@{w}: did not reopen")
|
|
elif m2["offscreen"] or m2["overHeader"]:
|
|
problems.append(f"{mode}@{w}: misplaced after reopen")
|
|
after_y = page.eval("Math.round(window.scrollY)")
|
|
if abs(after_y - before_y) > 4:
|
|
problems.append(f"{mode}@{w}: scroll moved {before_y}->{after_y}")
|
|
toggle()
|
|
|
|
if problems:
|
|
return report("F4", REPRO, "; ".join(problems[:4]))
|
|
if len(notes) >= 4:
|
|
return report("F4", UNKNOWN, "drawer never opened: " + "; ".join(notes[:2]))
|
|
detail = "on screen, clear of the header, reopens, scroll kept - at 390 and 1440"
|
|
return report("F4", FIXED, detail + (f" ({'; '.join(notes)})" if notes else ""))
|
|
|
|
|
|
# ── F5 ────────────────────────────────────────────────────────────────────────
|
|
def f5(page, base, tok):
|
|
"""SOP wizard inputs read as read-only. The review names the exact colours:
|
|
#f4f4f4 fill, #e0e0e0 border, because the wizard never sees --cds-field #ffffff.
|
|
Threshold: an ENABLED input computing to that fill."""
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(1440)
|
|
page.goto(base + "/work-package-suite.html?project=projA",
|
|
wait_for="!!document.querySelector('.field input, .field select')")
|
|
time.sleep(0.9)
|
|
got = page.eval("""(function(){
|
|
var out=[], n=0, dis=[];
|
|
document.querySelectorAll('.field input,.field select,.field textarea').forEach(function(e){
|
|
if(e.type==='hidden'||e.type==='checkbox'||e.type==='radio') return;
|
|
var r=e.getBoundingClientRect(); if(r.width===0&&r.height===0) return;
|
|
var s=getComputedStyle(e), sig=s.backgroundColor+' | '+s.borderTopColor;
|
|
if(e.disabled||e.readOnly){ dis.push(sig); return; }
|
|
n++; out.push(sig);
|
|
});
|
|
var tally={}; out.forEach(function(v){tally[v]=(tally[v]||0)+1;});
|
|
var dtally={}; dis.forEach(function(v){dtally[v]=(dtally[v]||0)+1;});
|
|
// Prove the disabled rule works even when the page has no disabled field to
|
|
// sample: borrow a real one, flip it, measure, put it back.
|
|
var probe=document.querySelector('.field input:not([type=hidden])'), forced=null;
|
|
if(probe){ var was=probe.disabled; probe.disabled=true;
|
|
var ps=getComputedStyle(probe);
|
|
forced=ps.backgroundColor+' | '+ps.borderTopColor; probe.disabled=was; }
|
|
return JSON.stringify({n:n,tally:tally,dis:dtally,forced:forced});})()""")
|
|
m = json.loads(got)
|
|
if not m["n"]:
|
|
return report("F5", UNKNOWN, "no enabled wizard inputs found")
|
|
GREY = ("rgb(244, 244, 244)", "rgb(243, 243, 243)")
|
|
greyed = sum(c for k, c in m["tally"].items() if any(g in k for g in GREY))
|
|
top = sorted(m["tally"].items(), key=lambda kv: -kv[1])[0]
|
|
if greyed:
|
|
return report("F5", REPRO,
|
|
f"{greyed}/{m['n']} enabled inputs fill #f4f4f4 (most common: {top[0]})")
|
|
# An enabled field that looks exactly like a disabled one is the same defect
|
|
# inverted, so this must not silently pass.
|
|
if m["forced"] and m["forced"] == top[0]:
|
|
return report("F5", REPRO,
|
|
f"enabled and disabled fields are identical ({top[0]}) - "
|
|
f"locked fields no longer read as locked")
|
|
extra = f", disabled reads {m['forced']}" if m["forced"] else ""
|
|
return report("F5", FIXED,
|
|
f"{m['n']} enabled inputs at {top[0]}{extra}")
|
|
|
|
|
|
# ── F6 ────────────────────────────────────────────────────────────────────────
|
|
def f6(page, base, tok):
|
|
"""The creator is one very tall form: the review counted 11 cards and ~4,700px
|
|
with jump links standing in for structure. Threshold: no sectioning control
|
|
(tabs/steps) and every card in the document flow at once."""
|
|
page.clear_cookies()
|
|
page.set_cookie("wp_session", tok["root"])
|
|
page.viewport(1440)
|
|
page.goto(base + "/wp-creation-index.html?project=projA",
|
|
wait_for="!!document.querySelector('.card, .section')")
|
|
time.sleep(1.0)
|
|
got = page.eval("""(function(){
|
|
var h=document.documentElement.scrollHeight;
|
|
var cards=document.querySelectorAll('.card,.wp-card,section.card').length;
|
|
var vis=0;
|
|
document.querySelectorAll('.card,.wp-card,section.card').forEach(function(e){
|
|
var s=getComputedStyle(e);
|
|
if(s.display!=='none'&&s.visibility!=='hidden') vis++;});
|
|
var tabs=document.querySelectorAll('[role=tab],.tab,.section-tab').length;
|
|
var jump=document.querySelectorAll('a[href^="#"]').length;
|
|
return JSON.stringify({h:h,cards:cards,vis:vis,tabs:tabs,jump:jump});})()""")
|
|
m = json.loads(got)
|
|
if m["vis"] > 1 and not m["tabs"] and m["h"] > 3000:
|
|
return report("F6", REPRO,
|
|
f"{m['vis']} cards in one {m['h']}px scroll, {m['tabs']} tabs, "
|
|
f"{m['jump']} jump link(s)")
|
|
if m["tabs"]:
|
|
return report("F6", FIXED,
|
|
f"{m['tabs']} sectioning control(s), {m['vis']} card(s) visible, {m['h']}px")
|
|
return report("F6", UNKNOWN,
|
|
f"{m['vis']} card(s), {m['h']}px, {m['tabs']} tabs - below the 3000px threshold")
|
|
|
|
|
|
PROBES = {"F1": f1, "F2": f2, "F3": f3, "F4": f4, "F5": f5, "F6": f6}
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser(description=__doc__,
|
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
ap.add_argument("items", nargs="*", default=[], help="subset, e.g. F2 F5")
|
|
ap.add_argument("--base-url", default="")
|
|
args = ap.parse_args()
|
|
|
|
wanted = [i.upper() for i in args.items] or list(PROBES)
|
|
bad = [i for i in wanted if i not in PROBES]
|
|
if bad:
|
|
print(f"unknown item(s): {', '.join(bad)}; known: {', '.join(PROBES)}")
|
|
return 2
|
|
if not cdp.find_browser():
|
|
print("no headless-capable browser found (set WP_BROWSER)")
|
|
return 2
|
|
|
|
tmpdir = tempfile.mkdtemp(prefix="wpsuite-f-items-")
|
|
db_path = os.path.join(tmpdir, "f.db")
|
|
proc = browser = None
|
|
try:
|
|
tok = seed(db_path)
|
|
add_long_project(db_path)
|
|
if args.base_url:
|
|
base = args.base_url.rstrip("/")
|
|
else:
|
|
port = cdp.free_port()
|
|
proc = start_server(port, db_path)
|
|
base = f"http://127.0.0.1:{port}"
|
|
if not proc:
|
|
print("the server would not start")
|
|
return 2
|
|
|
|
print(f"\n probing {', '.join(wanted)}\n")
|
|
browser = cdp.Browser()
|
|
page = browser.page()
|
|
for item in wanted:
|
|
try:
|
|
PROBES[item](page, base, tok)
|
|
except Exception as exc: # noqa: BLE001
|
|
report(item, UNKNOWN, f"probe raised: {str(exc)[:120]}")
|
|
|
|
r = sum(1 for _, v, _ in _RESULTS if v == REPRO)
|
|
f = sum(1 for _, v, _ in _RESULTS if v == FIXED)
|
|
u = sum(1 for _, v, _ in _RESULTS if v == UNKNOWN)
|
|
print(f"\n {_c(str(r) + ' reproduce', '31')}, {_c(str(f) + ' fixed', '32')}"
|
|
+ (f", {_c(str(u) + ' inconclusive', '33')}" if u else "") + "\n")
|
|
return 0
|
|
finally:
|
|
if browser:
|
|
browser.close()
|
|
if proc:
|
|
proc.kill()
|
|
proc.wait(timeout=10)
|
|
try:
|
|
from server.db import engine
|
|
engine.dispose()
|
|
except Exception: # noqa: BLE001
|
|
pass
|
|
shutil.rmtree(tmpdir, ignore_errors=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|