Repository navigation
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
index.htmloutputWhat is the current behavior?
Individual index-HTML transformations (
inlineCritical,subresourceIntegrity,autoCsp,fonts,csp-nonce) are each tested separately, but there is no builder-level regression test verifying that@angular/build:applicationemits zero inline scripts, inline styles, inline event handlers, or CSP<meta>tags in the final generated HTML when all inline-emitting options are disabled.Issue Number: Related to angular/angular#70877 / angular/angular#70890
What is the new behavior?
Adds
packages/angular/build/src/builders/application/tests/behavior/csp-inline-content_spec.tsusing the existinghtmlRewritingStreamparser (parse5-html-rewriting-stream) andisJavascriptMimeTypehelper to assert that:polyfills: ['zone.js'], globalscripts, globalstyles,baseHref+index.preloadInitial: true,sourceMap: { scripts: true },outputHashing: All,optimization.styles.inlineCritical: false,optimization.fonts: false,subresourceIntegrity: false, andsecurity.autoCspunset) emits external scripts and stylesheets and zero:<script>tags (any<script>withoutsrc)<style>tagsstyle="..."attributeson*event handler attributes<meta http-equiv="Content-Security-Policy*">tagsoptimization: false,subresourceIntegrity: false) maintains the same guarantee.outputMode: OutputMode.Static, withoutwithEventReplay(), withinlineCritical: false,fonts: false,subresourceIntegrity: false) emits external scripts and stylesheets and zero executable inline<script>tags, inlineon*event handler attributes, or CSP<meta>tags in bothdist/browser/index.csr.htmland the prerendereddist/browser/lazy/index.html(allowing non-executable data blocks such astype="application/json"and serialized component<style>tags).Following the recent CSP guidance update for static hosting and CDN caching in angular/angular#70890 (requested in angular/angular#70877), this test helps ensure that guidance stays accurate over time by catching any future builder change that accidentally introduces inline scripts, inline styles, or inline event handlers into the generated HTML when those options are disabled.
Does this PR introduce a breaking change?
Other information
Replaces #34816 (closed before CLA signing completed; CLA is now signed).
Verified locally with Bazel:
pnpm bazel test //packages/angular/build:application_integration_test_lib_strict_deps_test(PASSED)pnpm bazel test //packages/angular/build:application_integration_tests --test_arg=--filter="CSP without inline scripts or styles"(3 specs, 0 failures)pnpm exec prettier --check packages/angular/build/src/builders/application/tests/behavior/csp-inline-content_spec.ts(passed)pnpm ts-circular-deps check(0 cycles)Disclosure: AI coding assistance (GitHub Copilot) was used to help draft and verify this test.