Skip to content
  • Cédric Le Ninivin's avatar
    Audit fixes (tiers A–D) + torrent state-pattern migration · 9db25a01
    Cédric Le Ninivin authored
    
    
    Post-migration RenderJS/JS audit follow-up (plan drifting-yawning-flurry):
    
    A — correctness:
    - gadget_jio.js: createJio now returns an RSVP.Queue (RJS-002).
    - gadget_zip_loader.js: error-swallowing .push(console.log, console.log)
      replaced with CancellationError-aware rethrow; RSVP.Queue() -> new
      RSVP.Queue(); both submit callbacks now return the import promise.
    - import.js (4 sites) / compare.js (5 sites): empty .push(undefined,
      function(){}) swallows now console.warn the cleanup/best-effort failure
      instead of dropping it silently (primary err still surfaced via logStatus).
    - editor.js: throw new Error(...) instead of a string.
    
    B — minor cleanups:
    - editor.js: .style.display instead of clobbering cssText.
    - crib-sw-gadget.js: == -> ===, new RSVP.Queue(), header mirrored.
    - gadget_interface.js: removed dead commented error-handler.
    - save_load.js: magnet textarea writes .value not .textContent.
    
    C — header hygiene (/*global*/ aligned to usage): router (+loopEventListener),
    add (dropped unused jIO param), snapshots (removed stale blobToDataUrl),
    landing (/*globals*/->/*global*/, completed). Cross-script window helpers
    kept as bare globals (not IIFE-injected) to avoid undefined-at-eval capture.
    
    D — torrent migration: gadget_cribjs_page_torrent.js now holds the list +
    copy feedback in this.state (torrent_view, copy_feedback, render_timestamp);
    the polling service and click handlers call changeState, and onStateChange is
    the only DOM site. Closes the one remaining state-pattern gap.
    
    Tests: new test/playwright/cribjs_torrent_checks.py (7 checks) verifies the
    migration end-to-end (empty-in-HTML summary becomes populated only via
    onStateChange). Null-guarded three wait_for_function predicates in
    cribjs_compare_checks.py that could deref a transiently-absent .compare-status.
    
    Verified live: deploy verify OK; torrent 7/7, smoke 22/22, QUnit 113/113,
    export 12/12, import 15/15, compare 15/15; import.js + compare.js JSLint clean.
    
    Co-Authored-By: default avatarClaude Opus 4.8 <noreply@anthropic.com>
    9db25a01