mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
cc23d02e38
Automatic update from web-platform-tests Replace some "promise_rejects(t, new FooError, stuff)" calls with promise_rejects_js. This diff was generated by running: find . -type f -print0 | xargs -0 perl -pi -e 'BEGIN { $/ = undef; } s/promise_rejects\(([ \n]*[a-zA-Z_]+[ \n]*,[ \n]*)(?:new )?([A-Z][A-Za-z]*Error) *(?:\(\))? *(, *.)/promise_rejects_js(\1\2\3/gs' (which allows the optional "new" before "FooError" and an optional "()" after it) and then: 1) Manually editing css/cssom-view/MediaQueryList-addListener-handleEvent.html to make it get TypeError from the right global. 2) Manually editing fetch/api/response/response-error-from-stream.html to use promise_rejects_exactly instead of the thing it was doing with a CustomTestError. 3) Manually editing html/cross-origin-embedder-policy/require-corp.https.html to use TypeError from the right global in the window.open case. 4) Manually editing service-workers/service-worker/controller-with-no-fetch-event-handler.https.html to use TypeError from the right global in the subframe case. 5) Manually editing service-workers/service-worker/fetch-response-taint.https.html to use TypeError from the right frame. 6) Manually editing service-workers/service-worker/redirected-response.https.html to get the TypeError from the right subframe in various places. -- wpt-commits: ab733fd9f53eefdc034a2b96d08f080b355b6b10 wpt-pr: 21582
52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
// 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.
|
|
// https://w3c.github.io/webappsec-mixed-content/#should-block-fetch
|
|
// https://w3c.github.io/webappsec-mixed-content/#a-priori-authenticated-url
|
|
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
|
|
|
|
// With an additional restriction that only https:// and loopback http://
|
|
// requests are allowed. Hence the wss:, file:, data:, etc schemes are blocked.
|
|
// https://github.com/WICG/background-fetch/issues/44
|
|
|
|
// This is not a comprehensive test of mixed content blocking - it is just
|
|
// intended to check that blocking is enabled.
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return bgFetch.fetch(uniqueId(), 'https://example.com');
|
|
}, 'https: fetch should register ok');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return bgFetch.fetch(uniqueId(), 'http://127.0.0.1');
|
|
}, 'loopback IPv4 http: fetch should register ok');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return bgFetch.fetch(uniqueId(), 'http://[::1]');
|
|
}, 'loopback IPv6 http: fetch should register ok');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return bgFetch.fetch(uniqueId(), 'http://localhost');
|
|
}, 'localhost http: fetch should register ok');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return promise_rejects_js(t, TypeError,
|
|
bgFetch.fetch(uniqueId(), 'wss:127.0.0.1'));
|
|
}, 'wss: fetch should reject');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return promise_rejects_js(t, TypeError,
|
|
bgFetch.fetch(uniqueId(), 'file:///'));
|
|
}, 'file: fetch should reject');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return promise_rejects_js(t, TypeError,
|
|
bgFetch.fetch(uniqueId(), 'data:text/plain,foo'));
|
|
}, 'data: fetch should reject');
|
|
|
|
backgroundFetchTest((t, bgFetch) => {
|
|
return promise_rejects_js(t, TypeError,
|
|
bgFetch.fetch(uniqueId(), 'foobar:bazqux'));
|
|
}, 'unknown scheme fetch should reject');
|