diff --git a/lib/cache/cache.js b/lib/cache/cache.js index 087185b6704..04a29151d17 100644 --- a/lib/cache/cache.js +++ b/lib/cache/cache.js @@ -32,7 +32,7 @@ class Cache { * @see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list * @type {requestResponseList} */ - #relevantRequestResponseList = [] + #relevantRequestResponseList constructor () { if (arguments[0] !== kConstruct) { @@ -314,7 +314,7 @@ class Cache { let innerRequest = null // 2. - if (typeof request !== 'string') { + if (request instanceof Request) { innerRequest = request[kState] } else { // 3. innerRequest = new Request(request)[kState] @@ -457,7 +457,7 @@ class Cache { } else { assert(typeof request === 'string') - r = new Request(r)[kState] + r = new Request(request)[kState] } /** @type {CacheBatchOperation[]} */ diff --git a/lib/cache/cachestorage.js b/lib/cache/cachestorage.js index f28f42abf73..7e7f0cff2b5 100644 --- a/lib/cache/cachestorage.js +++ b/lib/cache/cachestorage.js @@ -109,20 +109,7 @@ class CacheStorage { cacheName = webidl.converters.DOMString(cacheName) - // 1. - // 2. - const cacheExists = this.#caches.has(cacheName) - - // 2.1 - if (!cacheExists) { - return false - } - - // 2.3.1 - this.#caches.delete(cacheName) - - // 2.3.2 - return true + return this.#caches.delete(cacheName) } /** diff --git a/test/wpt/runner/worker.mjs b/test/wpt/runner/worker.mjs index 638f53d7a57..90bfcf6dbde 100644 --- a/test/wpt/runner/worker.mjs +++ b/test/wpt/runner/worker.mjs @@ -108,7 +108,7 @@ runInThisContext(` } } globalThis.window = globalThis - globalThis.location = new URL('${url}') + globalThis.location = new URL('${urlPath.replace(/\\/g, '/')}', '${url}') globalThis.Window = Object.getPrototypeOf(globalThis).constructor `) @@ -142,7 +142,7 @@ add_completion_callback((_, status) => { }) }) -setGlobalOrigin(new URL(urlPath, url)) +setGlobalOrigin(globalThis.location) // Inject any script the user provided before // running the tests. diff --git a/test/wpt/server/server.mjs b/test/wpt/server/server.mjs index 75039acb916..7074e154dd1 100644 --- a/test/wpt/server/server.mjs +++ b/test/wpt/server/server.mjs @@ -36,6 +36,7 @@ const server = createServer(async (req, res) => { res.setHeader('content-type', 'text/html') // fall through } + case '/service-workers/cache-storage/resources/simple.txt': case '/fetch/content-encoding/resources/foo.octetstream.gz': case '/fetch/content-encoding/resources/foo.text.gz': case '/fetch/api/resources/cors-top.txt': @@ -361,11 +362,7 @@ const server = createServer(async (req, res) => { res.end('') return } - case '/resources/simple.txt': { - res.end(readFileSync(join(tests, 'service-workers/service-worker', fullUrl.pathname), 'utf-8')) - return - } - case '/resources/fetch-status.py': { + case '/service-workers/cache-storage/resources/fetch-status.py': { const status = Number(fullUrl.searchParams.get('status')) res.statusCode = status diff --git a/test/wpt/status/fetch.status.json b/test/wpt/status/fetch.status.json index cf814114752..72930388cb3 100644 --- a/test/wpt/status/fetch.status.json +++ b/test/wpt/status/fetch.status.json @@ -53,7 +53,8 @@ "fail": [ "origin-when-cross-origin policy on a cross-origin URL", "origin-when-cross-origin policy on a cross-origin URL after same-origin redirection", - "origin-when-cross-origin policy on a same-origin URL after cross-origin redirection" + "origin-when-cross-origin policy on a same-origin URL after cross-origin redirection", + "origin-when-cross-origin policy on a same-origin URL" ] }, "request-forbidden-headers.any.js": { diff --git a/test/wpt/status/service-workers/cache-storage.status.json b/test/wpt/status/service-workers/cache-storage.status.json index 06469aec3cd..6f7cd5287c0 100644 --- a/test/wpt/status/service-workers/cache-storage.status.json +++ b/test/wpt/status/service-workers/cache-storage.status.json @@ -25,7 +25,6 @@ "cache-delete.https.any.js": { "note": "spec bug? - https://github.com/w3c/ServiceWorker/issues/1677 (first fail)", "fail": [ - "Cache.delete called with a string URL", "Cache.delete with ignoreSearch option (when it is specified as false)" ] },