@@ -408,6 +408,90 @@ test.describe('HTML axe — the report overlay passes its own scan', () => {
408408 } ) ;
409409} ) ;
410410
411+ test . describe ( 'RevealJS axe — the report slide passes its own scan' , ( ) => {
412+ test ( 'report slide has no axe-core violations' , async ( { page } ) => {
413+ // The report slide is injected after the page scan runs, so it never
414+ // audits itself (same gap as the HTML overlay). Scan it here with the
415+ // same vendored axe-core build the deck already loaded (window.axe).
416+ //
417+ // createReportSlide() navigates back to the original slide, leaving the
418+ // report slide as a hidden future slide (hidden + aria-hidden). axe skips
419+ // hidden elements, so we MUST navigate to the report slide and wait for
420+ // `.present` first — otherwise the scan is a vacuous, permanent PASS.
421+ await page . goto ( '/revealjs/axe-accessibility.html' , { waitUntil : 'networkidle' } ) ;
422+
423+ const reportSlide = page . locator ( 'section.quarto-axe-report-slide' ) ;
424+ await expect ( reportSlide ) . toBeAttached ( { timeout : 10000 } ) ;
425+ await waitForAxeCompletion ( page ) ;
426+
427+ await page . evaluate ( ( ) => Reveal . slide ( Reveal . getTotalSlides ( ) - 1 ) ) ;
428+ await expect ( reportSlide ) . toHaveClass ( / p r e s e n t / ) ;
429+
430+ // Non-empty precondition: guards against the region silently becoming
431+ // empty in a future refactor, which would make violations == [] a
432+ // vacuous pass rather than a real guard.
433+ await expect (
434+ reportSlide . locator ( '.quarto-axe-violation-description' ) ,
435+ ) . not . toHaveCount ( 0 ) ;
436+
437+ const violations = await page . evaluate ( async ( ) => {
438+ const axe = ( window as any ) . axe ;
439+ const result = await axe . run ( document . querySelector ( '.quarto-axe-report-slide' ) ) ;
440+ return result . violations . map ( ( v : { id : string ; nodes : { target : string [ ] } [ ] } ) => ( {
441+ id : v . id ,
442+ targets : v . nodes . map ( ( n ) => n . target ) ,
443+ } ) ) ;
444+ } ) ;
445+ expect ( violations ) . toEqual ( [ ] ) ;
446+ } ) ;
447+ } ) ;
448+
449+ test . describe ( 'Dashboard axe — the offcanvas passes its own scan' , ( ) => {
450+ test ( 'offcanvas and toggle have no axe-core violations' , async ( { page } ) => {
451+ // The offcanvas and its toggle button are injected after the page scan
452+ // runs, so they never audit themselves on initial load. Scan both here.
453+ // The toggle (.quarto-axe-toggle) is a SIBLING of #quarto-axe-offcanvas
454+ // (both appended to <body>), so it must be an explicit include — scanning
455+ // the offcanvas alone would miss a dropped aria-label on the toggle.
456+ await page . goto ( '/dashboard/axe-accessibility.html' , { waitUntil : 'networkidle' } ) ;
457+
458+ const offcanvas = page . locator ( '#quarto-axe-offcanvas' ) ;
459+ await expect ( offcanvas ) . toBeVisible ( { timeout : 10000 } ) ;
460+
461+ // Non-empty precondition — see reveal test above for rationale.
462+ await expect (
463+ offcanvas . locator ( '.quarto-axe-violation-description' ) ,
464+ ) . not . toHaveCount ( 0 ) ;
465+
466+ const violations = await page . evaluate ( async ( ) => {
467+ const axe = ( window as any ) . axe ;
468+ const result = await axe . run ( {
469+ include : [ [ '#quarto-axe-offcanvas' ] , [ '.quarto-axe-toggle' ] ] ,
470+ } ) ;
471+ return result . violations . map ( ( v : { id : string ; nodes : { target : string [ ] } [ ] } ) => ( {
472+ id : v . id ,
473+ targets : v . nodes . map ( ( n ) => n . target ) ,
474+ } ) ) ;
475+ } ) ;
476+
477+ // Known issue quarto-dev/quarto-cli#14710: .offcanvas-body is a scrolling
478+ // region with no focusable descendant and isn't itself focusable, so it
479+ // trips scrollable-region-focusable even on this short fixture (its fixed
480+ // height already overflows). That one node is filtered out (not
481+ // test.fail()'d) at the node level — not the whole violation — so this
482+ // test still catches any other regression here, including a second,
483+ // unrelated scrollable-region-focusable node — while #14710 is open.
484+ const unexpected = violations
485+ . map ( ( v ) =>
486+ v . id === 'scrollable-region-focusable'
487+ ? { ...v , targets : v . targets . filter ( ( t ) => ! t . includes ( '.offcanvas-body' ) ) }
488+ : v ,
489+ )
490+ . filter ( ( v ) => v . targets . length > 0 ) ;
491+ expect ( unexpected ) . toEqual ( [ ] ) ;
492+ } ) ;
493+ } ) ;
494+
411495test . describe ( 'Dashboard axe — re-scan on visibility change' , ( ) => {
412496 const pagesUrl = '/dashboard/axe-accessibility-pages.html' ;
413497
@@ -680,3 +764,86 @@ test.describe('Axe — standard and best-practice scoping (#14607)', () => {
680764 . not . toContain ( 'heading' ) ;
681765 } ) ;
682766} ) ;
767+
768+ test . describe ( 'Axe — no third-party/CDN dependency (regression guard for #14677)' , ( ) => {
769+ const CDN_DENYLIST = [
770+ 'skypack.dev' ,
771+ 'unpkg.com' ,
772+ 'jsdelivr.net' ,
773+ 'esm.sh' ,
774+ 'cdnjs.cloudflare.com' ,
775+ ] ;
776+
777+ function cdnHost ( url : string ) : string | null {
778+ let hostname : string ;
779+ try {
780+ hostname = new URL ( url ) . hostname ;
781+ } catch {
782+ return null ;
783+ }
784+ return CDN_DENYLIST . find (
785+ ( base ) => hostname === base || hostname . endsWith ( '.' + base ) ,
786+ ) ?? null ;
787+ }
788+
789+ test ( 'html — axe-enabled page makes no request to a package CDN' , async ( { page } ) => {
790+ const cdnRequests : string [ ] = [ ] ;
791+ page . on ( 'request' , ( req ) => {
792+ if ( cdnHost ( req . url ( ) ) ) cdnRequests . push ( req . url ( ) ) ;
793+ } ) ;
794+
795+ await page . goto ( '/html/axe-accessibility.html' , { waitUntil : 'networkidle' } ) ;
796+ await waitForAxeCompletion ( page ) ;
797+
798+ expect (
799+ cdnRequests ,
800+ `axe-enabled page must not load resources from a package CDN. ` +
801+ `Offending request(s): ${ cdnRequests . join ( ', ' ) } ` ,
802+ ) . toEqual ( [ ] ) ;
803+ } ) ;
804+ } ) ;
805+
806+ test . describe ( 'HTML axe — the report overlay scrolls by keyboard (#14680)' , ( ) => {
807+ // Commit 4a528a2e3 made the fixed overlay a focusable scroll region so a
808+ // report taller than max-height: 50vh can be scrolled from the keyboard.
809+ // Keyboard scrolling here is *native* browser behavior (overflow-y: auto +
810+ // tabindex=0, no keydown handler), so the regression this guards is the
811+ // scroll behavior breaking — overflow-y flipped away from auto, or a future
812+ // keydown handler swallowing the keys — while tabindex/role/aria-label stay
813+ // intact. Those cases pass the static attribute checks (line ~172) AND the
814+ // overlay self-scan (scrollable-region-focusable, line ~388), so only an
815+ // actual key press that moves scrollTop catches them.
816+ for ( const key of [ 'PageDown' , 'ArrowDown' ] ) {
817+ test ( `html — focused overlay scrolls on ${ key } ` , async ( { page } ) => {
818+ await page . goto ( '/html/axe-overlay-scroll.html' , { waitUntil : 'networkidle' } ) ;
819+
820+ const axeReport = page . locator ( '.quarto-axe-report' ) ;
821+ await expect ( axeReport ) . toBeVisible ( { timeout : 10000 } ) ;
822+
823+ // Precondition: the fixture must inflate the report past its max-height,
824+ // or there is nothing to scroll and a green result would be meaningless.
825+ const overflow = await axeReport . evaluate (
826+ ( el ) => ( { scrollHeight : el . scrollHeight , clientHeight : el . clientHeight } ) ,
827+ ) ;
828+ expect (
829+ overflow . scrollHeight ,
830+ `overlay must overflow to be scrollable (scrollHeight ${ overflow . scrollHeight } ` +
831+ `must exceed clientHeight ${ overflow . clientHeight } ); check axe-overlay-scroll.qmd` ,
832+ ) . toBeGreaterThan ( overflow . clientHeight ) ;
833+
834+ // Start from the top and put focus on the overlay itself. toBeFocused is
835+ // test hygiene: it proves the key goes to the overlay, not the document,
836+ // so a scrollTop change can only mean the overlay scrolled.
837+ await axeReport . evaluate ( ( el ) => { el . scrollTop = 0 ; } ) ;
838+ await axeReport . focus ( ) ;
839+ await expect ( axeReport ) . toBeFocused ( ) ;
840+
841+ await page . keyboard . press ( key ) ;
842+
843+ // Native key scroll is instant, but poll to avoid any timing race.
844+ await expect
845+ . poll ( ( ) => axeReport . evaluate ( ( el ) => el . scrollTop ) , { timeout : 3000 } )
846+ . toBeGreaterThan ( 0 ) ;
847+ } ) ;
848+ }
849+ } ) ;
0 commit comments