Skip to content

Allow disabling publication JavaScript in the EPUB navigator [H3-6a] - #931

Draft
Tarun-joy wants to merge 1 commit into
readium:developfrom
openread-ai:openread/3.11.0-content-javascript
Draft

Tarun-joy wants to merge 1 commit into
readium:developfrom
openread-ai:openread/3.11.0-content-javascript

Conversation

@Tarun-joy

Copy link
Copy Markdown

Why

Apps need to disable publication JavaScript before the first page loads while keeping Readium's injected scripts available. WebKit's content JavaScript preference preserves user scripts and application evaluation.

What changed

Add EPUBNavigatorViewController.Configuration.allowsContentJavaScript, defaulting to true, and apply it before each spread constructs its WebView. Existing callers retain the current behavior.

The regression opens an XHTML publication through a real reflowable spread in the existing navigator app host. It waits for Readium's spread-loaded event. It checks that a parse-time script changes visible text when enabled and leaves the original text intact when disabled. Readium's injected script must still complete spread loading, and application evaluation must still call Readium's CSS API.

Scope

This patch is based on 3.11.0 for an explicitly pinned OpenRead integration. We offer the configuration hook upstream. No script sanitizer, runtime toggle, stored preference, or application-specific behavior is added.

Verification

Passed all three hosted cases on an iPhone 18 Pro simulator with iOS 27.0: disabled, enabled, and enabled by default. Readium injection and application evaluation worked in each case. Without the enforcement assignment, the disabled case failed on the publication script's text mutation and both positive controls passed. Native result bundles were inspected. SwiftFormat 0.61.1 lint and git diff --check passed.

Generate the existing test project with make navigator-ui-tests-project, then run xcodebuild test -project Tests/NavigatorTests/UITests/NavigatorUITests.xcodeproj -scheme NavigatorTestHost -destination 'platform=iOS Simulator,name=Readium H3-6A' -only-testing:ContentJavaScriptTests/ContentJavaScriptTests -parallel-testing-enabled NO -collect-test-diagnostics never.

This draft offers the patch tested against 3.11.0. Current develop integration, whole-app behavior, and fixed-layout publication qualification remain separate.

@Tarun-joy Tarun-joy changed the title Allow disabling publication JavaScript in the EPUB navigator Allow disabling publication JavaScript in the EPUB navigator [H3-6a] Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant