diff --git a/fetch/security/dangling-markup/dangling-markup-mitigation-allowed-apis.html b/fetch/security/dangling-markup/dangling-markup-mitigation-allowed-apis.html new file mode 100644 index 00000000000000..66456a8876b609 --- /dev/null +++ b/fetch/security/dangling-markup/dangling-markup-mitigation-allowed-apis.html @@ -0,0 +1,26 @@ + + + + + diff --git a/fetch/security/dangling-markup/dangling-markup-mitigation-data-url.tentative.sub.html b/fetch/security/dangling-markup/dangling-markup-mitigation-data-url.sub.html similarity index 100% rename from fetch/security/dangling-markup/dangling-markup-mitigation-data-url.tentative.sub.html rename to fetch/security/dangling-markup/dangling-markup-mitigation-data-url.sub.html diff --git a/fetch/security/dangling-markup/dangling-markup-mitigation.tentative.html b/fetch/security/dangling-markup/dangling-markup-mitigation.html similarity index 100% rename from fetch/security/dangling-markup/dangling-markup-mitigation.tentative.html rename to fetch/security/dangling-markup/dangling-markup-mitigation.html diff --git a/fetch/security/dangling-markup/dangling-markup-mitigation.https.html b/fetch/security/dangling-markup/dangling-markup-mitigation.https.html new file mode 100644 index 00000000000000..3f038cbb7be452 --- /dev/null +++ b/fetch/security/dangling-markup/dangling-markup-mitigation.https.html @@ -0,0 +1,61 @@ + + + + + + diff --git a/fetch/security/dangling-markup/resources/empty.html b/fetch/security/dangling-markup/resources/empty.html new file mode 100644 index 00000000000000..0e76edd65b7baf --- /dev/null +++ b/fetch/security/dangling-markup/resources/empty.html @@ -0,0 +1 @@ + diff --git a/fetch/security/dangling-markup/service-worker.js b/fetch/security/dangling-markup/service-worker.js new file mode 100644 index 00000000000000..837e216a013be4 --- /dev/null +++ b/fetch/security/dangling-markup/service-worker.js @@ -0,0 +1,35 @@ +const requests = new Set(); + +addEventListener('install', evt => { + evt.waitUntil(self.skipWaiting()); +}); + +addEventListener('activate', evt => { + evt.waitUntil(self.clients.claim()); +}); + +addEventListener('message', evt => { + evt.source.postMessage(requests); +}); + +addEventListener('fetch', evt => { + const url = new URL(evt.request.url); + const path = url.pathname; + const search = url.search || "?"; + if (path.includes('404')) { + const dir = path.split('/'); + const request = dir[dir.length-1] + search; + if (!requests.has(request)) { + requests.add(request); + } + evt.respondWith(new Response("")); + } else if (path.endsWith('resources.html')) { + const html = (new URLSearchParams(search)).get('html'); + evt.respondWith(new Response(html, { + headers: { + "Content-Type": "text/html" + } + })); + } + return; +});