Re: [w3c/ServiceWorker] consider how clients.claim() should work with srcdoc iframes (#1093)

I wonder if I'm hitting this.  I'm trying to rewrite https://thimble.mozilla.org to use SW for serving all user generated content.  I currently do it with Blob URLs and rewriting of relative path URLs to Blob URLs, but it can't handle things like JS dynamically doing things.

Given a page running on `http://localhost:8000/dist/hosted.html`, and a SW running at `http://localhost:8000/dist/sw.js`.  I've got various request/response pairs already placed in CacheStorage, for example `http://localhost:8000/dist/vfs/image.png`.  I then create an HTML page, and a Blob URL for it:

```html
<html>
    <head>
        <title>This will load in the iframe</title>
        <base href="http://localhost:8000/dist/vfs">
    </head>
    <body>
        <img src="http://localhost:8000/dist/vfs/image.png">
    </body>
</html>
```

I then add `<iframe src="blob:http://localhost:8000/e843c3b9-5da7-4cbf-b782-ba3c6fafdbd9">` in the page running at `http://localhost:8000/dist/hosted.html`.  My SW is set up to return anything it matches in the caches, and I can see that there is a cache entry for `http://localhost:8000/dist/vfs/image.png`.

When the iframe loads, I get `404`s for `http://localhost:8000/dist/vfs/image.png`.  However, if I just try to load that same URL in my address bar, it loads no problem.

At first I assumed it was something else I was doing, but I now suspect the fact that it's running in a page via the Blob URL.  I had hoped that by it being a child iframe, and setting the `<base>` I might be able to inherit the parent's controller, too.  Or perhaps there is some CORS issue I don't know about, and need in my cached headers?

I'm thinking I should abandon the Blob URL for the iframe as well, and also load that from cache; it was just surprising to me that this didn't work, and I wanted to investigate.

Thanks for any thoughts, even if only to tell me that I'm wrong.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1093#issuecomment-294327873

Received on Sunday, 16 April 2017 01:35:24 UTC