Multiple service worker tests
You can run a simple Node server if you're not testing push:
npm install
cd
browserify common_worker.js > common_worker_browserified.js
./node_modules/.bin/http-server -c-1 test_site/
...or to test Push, get your GCM API key, and run the Python server:
npm install
browserify common_worker.js > common_worker_browserified.js
virtualenv venv
. venv/bin/activate
env GCM_API_KEY=<your api key> ./server.py
There are two pages. http://localhost:8080/
is the root, and
http://localhost:8080/subpath/
is a second page. Both pages allow you
to register and unregister a service worker, and test fetches and
push messages.
To test the iframe communication
- Configure a proxy (e.g. Charles) to map
https://test.com
andhttp://test-insecure.com
both tohttp://localhost:8080
. Start the server. - In Chrome or Firefox, load
https://test.com
. Make sure the JavaScript console is visible, and click register to register the service worker. Verify that it is handling fetch events by clicking fetch. - Now load
http://test-insecure.com
. Click iframe to open an iframe tohttps://test.com
. Click fetch in the iframe, and verify that thetest.com
service worker is intercepting fetches. Click check to verify that the service worker can check the permission and subscription.