зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1164397 - Part 10: Add a test case for the service worker for an app:// URI responding with cached HTTP and HTTPS responses; r=jdm
This commit is contained in:
Родитель
94b37a9fb9
Коммит
b71252d396
Двоичные данные
dom/workers/test/serviceworkers/app-protocol/application.zip
Двоичные данные
dom/workers/test/serviceworkers/app-protocol/application.zip
Двоичный файл не отображается.
|
@ -19,6 +19,8 @@ function runTests() {
|
|||
})
|
||||
.then(testRedirectedResponse)
|
||||
.then(testRedirectedHttpsResponse)
|
||||
.then(testCachedRedirectedResponse)
|
||||
.then(testCachedRedirectedHttpsResponse)
|
||||
.then(done);
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
const kHTTPRedirect = "http://example.com/tests/dom/workers/test/serviceworkers/app-protocol/redirect.sjs";
|
||||
const kHTTPSRedirect = "https://example.com/tests/dom/workers/test/serviceworkers/app-protocol/redirect-https.sjs";
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
self.caches.open("origin-app-cache")
|
||||
.then(c => {
|
||||
return Promise.all(
|
||||
[
|
||||
c.add(kHTTPRedirect),
|
||||
c.add(kHTTPSRedirect),
|
||||
]
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.url.indexOf('foo.txt') >= 0) {
|
||||
event.respondWith(new Response('swresponse', {
|
||||
|
@ -19,10 +36,28 @@ self.addEventListener('fetch', (event) => {
|
|||
}
|
||||
|
||||
if (event.request.url.indexOf('redirected.html') >= 0) {
|
||||
event.respondWith(fetch("http://example.com/tests/dom/workers/test/serviceworkers/app-protocol/redirect.sjs"));
|
||||
event.respondWith(fetch(kHTTPRedirect));
|
||||
}
|
||||
|
||||
if (event.request.url.indexOf('redirected-https.html') >= 0) {
|
||||
event.respondWith(fetch("https://example.com/tests/dom/workers/test/serviceworkers/app-protocol/redirect-https.sjs"));
|
||||
event.respondWith(fetch(kHTTPSRedirect));
|
||||
}
|
||||
|
||||
if (event.request.url.indexOf('redirected-cached.html') >= 0) {
|
||||
event.respondWith(
|
||||
self.caches.open("origin-app-cache")
|
||||
.then(c => {
|
||||
return c.match(kHTTPRedirect);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (event.request.url.indexOf('redirected-https-cached.html') >= 0) {
|
||||
event.respondWith(
|
||||
self.caches.open("origin-app-cache")
|
||||
.then(c => {
|
||||
return c.match(kHTTPSRedirect);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,6 +46,14 @@ function testRedirectedHttpsResponse() {
|
|||
return testRedirectedResponseWorker("redirected-https", "HTTPSIFRAMELOADED");
|
||||
}
|
||||
|
||||
function testCachedRedirectedResponse() {
|
||||
return testRedirectedResponseWorker("redirected-cached", "IFRAMELOADED");
|
||||
}
|
||||
|
||||
function testCachedRedirectedHttpsResponse() {
|
||||
return testRedirectedResponseWorker("redirected-https-cached", "HTTPSIFRAMELOADED");
|
||||
}
|
||||
|
||||
function testRedirectedResponseWorker(aFrameId, aAlert) {
|
||||
// Because of the CSP policies applied to privileged apps, we cannot run
|
||||
// inline script inside realindex.html, and loading a script from the app://
|
||||
|
|
|
@ -28,7 +28,8 @@ function setup() {
|
|||
['dom.mozBrowserFramesEnabled', true],
|
||||
['dom.serviceWorkers.exemptFromPerDomainMax', true],
|
||||
['dom.serviceWorkers.enabled', true],
|
||||
['dom.serviceWorkers.testing.enabled', true]
|
||||
['dom.serviceWorkers.testing.enabled', true],
|
||||
['dom.caches.enabled', true],
|
||||
]}, () => {
|
||||
SpecialPowers.pushPermissions([
|
||||
{ 'type': 'webapps-manage', 'allow': 1, 'context': document },
|
||||
|
|
Загрузка…
Ссылка в новой задаче