Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 8 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /background-fetch/mixed-content-and-allowed-schemes.https.window.html - WPT Dashboard Interop Dashboard
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/utils.js
'use strict';
// Tests that Mixed Content requests are blocked.
// With an additional restriction that only https:// and loopback http://
// requests are allowed. Hence the wss:, file:, data:, etc schemes are blocked.
// This is not a comprehensive test of mixed content blocking - it is just
// intended to check that blocking is enabled.
backgroundFetchTest((t, bgFetch) => {
}, 'https: fetch should register ok');
backgroundFetchTest((t, bgFetch) => {
}, 'loopback IPv4 http: fetch should register ok');
backgroundFetchTest((t, bgFetch) => {
}, 'loopback IPv6 http: fetch should register ok');
backgroundFetchTest((t, bgFetch) => {
}, 'localhost http: fetch should register ok');
function testBgFetch(bgFetch, url)
{
return bgFetch.fetch(uniqueId(), url).then(fetch => {
return fetch.match(url);
}).then(match => match.responseReady);
}
backgroundFetchTest((t, bgFetch) => {
return promise_rejects_js(t, TypeError,
testBgFetch(bgFetch, 'wss:127.0.0.1'));
}, 'wss: fetch should reject');
backgroundFetchTest((t, bgFetch) => {
return promise_rejects_js(t, TypeError,
}, 'file: fetch should reject');
backgroundFetchTest((t, bgFetch) => {
return promise_rejects_js(t, TypeError,
testBgFetch(bgFetch, 'data:text/plain,foo'));
}, 'data: fetch should reject');
backgroundFetchTest((t, bgFetch) => {
return promise_rejects_js(t, TypeError,
testBgFetch(bgFetch, 'foobar:bazqux'));
}, 'unknown scheme fetch should reject');