Skip to content

Commit e115436

Browse files
fix: overlay and require-trusted-types-for (#5046)
1 parent 7681477 commit e115436

File tree

8 files changed

+475
-2521
lines changed

8 files changed

+475
-2521
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
!/test/client
44
coverage
55
node_modules
6+
examples/client/trusted-types-overlay/app.js

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
coverage
44
node_modules
55
CHANGELOG.md
6+
examples/client/trusted-types-overlay/app.js

client-src/overlay.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ const createOverlay = (options) => {
189189
*/
190190
function ensureOverlayExists(callback, trustedTypesPolicyName) {
191191
if (containerElement) {
192-
containerElement.innerHTML = "";
192+
containerElement.innerHTML = overlayTrustedTypesPolicy
193+
? overlayTrustedTypesPolicy.createHTML("")
194+
: "";
193195
// Everything is ready, call the callback right away.
194196
callback(containerElement);
195197

examples/client/trusted-types-overlay/app.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ const target = document.querySelector("#target");
44

55
target.classList.add("pass");
66
target.textContent = "Success!";
7+
8+
// To display an overlay with an error
9+
(

examples/client/trusted-types-overlay/webpack.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ const { setup } = require("../../util");
99
const config = setup({
1010
context: __dirname,
1111
// create error for overlay
12-
entry: "./invalid.js",
12+
entry: "./app.js",
1313
output: {
1414
trustedTypes: { policyName: "webpack" },
1515
},
1616
devServer: {
17+
headers: {
18+
"Content-Security-Policy": "require-trusted-types-for 'script'",
19+
},
1720
client: {
1821
overlay: {
1922
trustedTypesPolicyName: "webpack#dev-overlay",

0 commit comments

Comments
 (0)