From 7a4c2c0b30923cb0fa67b79a951d32f7264f56af Mon Sep 17 00:00:00 2001 From: Matt Falkenhagen Date: Tue, 11 Dec 2018 21:20:44 -0800 Subject: [PATCH] service worker: XSLT: Use response URL for the base URL. This aligns with the standard. See https://github.com/whatwg/fetch/pull/146 Chrome Status: https://www.chromestatus.com/feature/4857368017895424 No intent to ship because it's a trivial change. Bug: 914135 Change-Id: I229aec6f8473bb6b7cdc88429afa830bc6eb80ed --- .../resources/import-relative.xsl | 5 +++ .../resources/xsl-base-url-iframe.xml | 5 +++ .../resources/xsl-base-url-worker.js | 12 +++++++ .../service-worker/resources/xslt-pass.xsl | 11 +++++++ .../service-worker/xsl-base-url.https.html | 32 +++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 service-workers/service-worker/resources/import-relative.xsl create mode 100644 service-workers/service-worker/resources/xsl-base-url-iframe.xml create mode 100644 service-workers/service-worker/resources/xsl-base-url-worker.js create mode 100644 service-workers/service-worker/resources/xslt-pass.xsl create mode 100644 service-workers/service-worker/xsl-base-url.https.html diff --git a/service-workers/service-worker/resources/import-relative.xsl b/service-workers/service-worker/resources/import-relative.xsl new file mode 100644 index 00000000000000..063a62d03143a3 --- /dev/null +++ b/service-workers/service-worker/resources/import-relative.xsl @@ -0,0 +1,5 @@ + + + + + diff --git a/service-workers/service-worker/resources/xsl-base-url-iframe.xml b/service-workers/service-worker/resources/xsl-base-url-iframe.xml new file mode 100644 index 00000000000000..065a07acb28482 --- /dev/null +++ b/service-workers/service-worker/resources/xsl-base-url-iframe.xml @@ -0,0 +1,5 @@ + + + +This tests a stylesheet which has a xsl:import with a relative URL. + diff --git a/service-workers/service-worker/resources/xsl-base-url-worker.js b/service-workers/service-worker/resources/xsl-base-url-worker.js new file mode 100644 index 00000000000000..50e2b1842ffc7f --- /dev/null +++ b/service-workers/service-worker/resources/xsl-base-url-worker.js @@ -0,0 +1,12 @@ +self.addEventListener('fetch', event => { + const url = new URL(event.request.url); + + // For the import-relative.xsl file, respond in a way that changes the + // response URL. This is expected to change the base URL and allow the import + // from the file to succeed. + const path = 'request-url-path/import-relative.xsl'; + if (url.pathname.indexOf(path) != -1) { + // Respond with a different URL, deleting "request-url-path/". + event.respondWith(fetch('import-relative.xsl')); + } +}); diff --git a/service-workers/service-worker/resources/xslt-pass.xsl b/service-workers/service-worker/resources/xslt-pass.xsl new file mode 100644 index 00000000000000..2cd7f2f8f86a23 --- /dev/null +++ b/service-workers/service-worker/resources/xslt-pass.xsl @@ -0,0 +1,11 @@ + + + + + + +

PASS

+ + +
+
diff --git a/service-workers/service-worker/xsl-base-url.https.html b/service-workers/service-worker/xsl-base-url.https.html new file mode 100644 index 00000000000000..1d3c36408a66a7 --- /dev/null +++ b/service-workers/service-worker/xsl-base-url.https.html @@ -0,0 +1,32 @@ + + +Service Worker: XSL's base URL must be the response URL + + + +