mirror of
https://github.com/servo/servo.git
synced 2025-09-03 11:38:22 +01:00
Update web-platform-tests to revision 132d12daea699ce266324e79eecbe59b10e56502
This commit is contained in:
parent
527d874bc1
commit
fe00a63040
1004 changed files with 18598 additions and 92770 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,50 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: Mime type checking of CSS files fetched via SW.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
function getElementColorInFrame(frame, id) {
|
||||
var element = frame.contentDocument.getElementById(id);
|
||||
var style = frame.contentWindow.getComputedStyle(element, '');
|
||||
return style['color'];
|
||||
}
|
||||
|
||||
promise_test(function(t) {
|
||||
var SCOPE =
|
||||
'resources/fetch-request-css-cross-origin-mime-check-iframe.html';
|
||||
var SCRIPT =
|
||||
'resources/fetch-request-css-cross-origin-mime-check-worker.js';
|
||||
var EXPECTED_COLOR = 'rgb(0, 0, 255)';
|
||||
|
||||
return service_worker_unregister_and_register(t, SCRIPT, SCOPE)
|
||||
.then(r => wait_for_state(t, r.installing, 'activated'))
|
||||
.then(_ => with_iframe(SCOPE) )
|
||||
.then(f => {
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'crossOriginCss'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by cross origin CSS.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'crossOriginHtml'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must not be overridden by cross origin non CSS file.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'sameOriginCss'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by same origin CSS.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'sameOriginHtml'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by same origin non CSS file.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'synthetic'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by synthetic CSS.');
|
||||
f.remove();
|
||||
return service_worker_unregister_and_done(t, SCOPE);
|
||||
});
|
||||
}, 'Mime type checking of CSS files fetched via SW.');
|
||||
</script>
|
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: Cross-origin CSS files fetched via SW.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
function getElementColorInFrame(frame, id) {
|
||||
var element = frame.contentDocument.getElementById(id);
|
||||
var style = frame.contentWindow.getComputedStyle(element, '');
|
||||
return style['color'];
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
var SCOPE =
|
||||
'resources/fetch-request-css-cross-origin';
|
||||
var SCRIPT =
|
||||
'resources/fetch-request-css-cross-origin-worker.js';
|
||||
let registration = await service_worker_unregister_and_register(
|
||||
t, SCRIPT, SCOPE);
|
||||
promise_test(async t => {
|
||||
await registration.unregister();
|
||||
}, 'cleanup global state');
|
||||
|
||||
await wait_for_state(t, registration.installing, 'activated');
|
||||
}, 'setup global state');
|
||||
|
||||
promise_test(async t => {
|
||||
const EXPECTED_COLOR = 'rgb(0, 0, 255)';
|
||||
const PAGE =
|
||||
'resources/fetch-request-css-cross-origin-mime-check-iframe.html';
|
||||
|
||||
const f = await with_iframe(PAGE);
|
||||
t.add_cleanup(() => {f.remove(); });
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'crossOriginCss'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by cross origin CSS.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'crossOriginHtml'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must not be overridden by cross origin non CSS file.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'sameOriginCss'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by same origin CSS.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'sameOriginHtml'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by same origin non CSS file.');
|
||||
assert_equals(
|
||||
getElementColorInFrame(f, 'synthetic'),
|
||||
EXPECTED_COLOR,
|
||||
'The color must be overridden by synthetic CSS.');
|
||||
}, 'MIME checking of CSS resources fetched via service worker when Content-Type is not set.');
|
||||
|
||||
promise_test(async t => {
|
||||
const PAGE =
|
||||
'resources/fetch-request-css-cross-origin-read-contents.html';
|
||||
|
||||
const f = await with_iframe(PAGE);
|
||||
t.add_cleanup(() => {f.remove(); });
|
||||
assert_throws('SecurityError', () => {
|
||||
f.contentDocument.styleSheets[0].cssRules[0].cssText;
|
||||
});
|
||||
assert_equals(
|
||||
f.contentDocument.styleSheets[1].cssRules[0].cssText,
|
||||
'#crossOriginCss { color: blue; }',
|
||||
'cross-origin CORS approved response');
|
||||
assert_equals(
|
||||
f.contentDocument.styleSheets[2].cssRules[0].cssText,
|
||||
'#sameOriginCss { color: blue; }',
|
||||
'same-origin response');
|
||||
assert_equals(
|
||||
f.contentDocument.styleSheets[3].cssRules[0].cssText,
|
||||
'#synthetic { color: blue; }',
|
||||
'service worker generated response');
|
||||
}, 'Same-origin policy for access to CSS resources fetched via service worker');
|
||||
|
||||
</script>
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: Registration-updateViaCache</title>
|
||||
<meta name="timeout" content="long">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="resources/testharness-helpers.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
#sameOriginHtml { color: red; }
|
||||
#synthetic { color: red; }
|
||||
</style>
|
||||
<link href="./cross-origin-css.css" rel="stylesheet" type="text/css">
|
||||
<link href="./cross-origin-html.css" rel="stylesheet" type="text/css">
|
||||
<link href="./cross-origin-css.css?mime=no" rel="stylesheet" type="text/css">
|
||||
<link href="./cross-origin-html.css?mime=no" rel="stylesheet" type="text/css">
|
||||
<link href="./fetch-request-css-cross-origin-mime-check-same.css" rel="stylesheet" type="text/css">
|
||||
<link href="./fetch-request-css-cross-origin-mime-check-same.html" rel="stylesheet" type="text/css">
|
||||
<link href="./synthetic.css" rel="stylesheet" type="text/css">
|
||||
<link href="./synthetic.css?mime=no" rel="stylesheet" type="text/css">
|
||||
<h1 id=crossOriginCss>I should be blue</h1>
|
||||
<h1 id=crossOriginHtml>I should be blue</h1>
|
||||
<h1 id=sameOriginCss>I should be blue</h1>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
importScripts('/common/get-host-info.sub.js');
|
||||
importScripts('test-helpers.sub.js');
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
if (event.request.url.indexOf('cross-origin-css.css') != -1) {
|
||||
event.respondWith(fetch(
|
||||
get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() +
|
||||
'fetch-request-css-cross-origin-mime-check-cross.css',
|
||||
{mode: 'no-cors'}));
|
||||
} else if (event.request.url.indexOf('cross-origin-html.css') != -1) {
|
||||
event.respondWith(fetch(
|
||||
get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() +
|
||||
'fetch-request-css-cross-origin-mime-check-cross.html',
|
||||
{mode: 'no-cors'}));
|
||||
} else if (event.request.url.indexOf('synthetic.css') != -1) {
|
||||
event.respondWith(new Response("#synthetic { color: blue; }"));
|
||||
} else {
|
||||
event.respondWith(fetch(event.request));
|
||||
}
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>iframe: cross-origin CSS via service worker</title>
|
||||
|
||||
<!-- Service worker responds with a cross-origin opaque response. -->
|
||||
<link href="cross-origin-css.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- Service worker responds with a cross-origin CORS approved response. -->
|
||||
<link href="cross-origin-css.css?cors" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- Service worker falls back to network. This is a same-origin response. -->
|
||||
<link href="fetch-request-css-cross-origin-mime-check-same.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- Service worker responds with a new Response() synthetic response. -->
|
||||
<link href="synthetic.css" rel="stylesheet" type="text/css">
|
|
@ -0,0 +1,65 @@
|
|||
importScripts('/common/get-host-info.sub.js');
|
||||
importScripts('test-helpers.sub.js');
|
||||
|
||||
const HOST_INFO = get_host_info();
|
||||
const REMOTE_ORIGIN = HOST_INFO.HTTPS_REMOTE_ORIGIN;
|
||||
const BASE_PATH = base_path();
|
||||
const CSS_FILE = 'fetch-request-css-cross-origin-mime-check-cross.css';
|
||||
const HTML_FILE = 'fetch-request-css-cross-origin-mime-check-cross.html';
|
||||
|
||||
function add_pipe_header(url_str, header) {
|
||||
if (url_str.indexOf('?pipe=') == -1) {
|
||||
url_str += '?pipe=';
|
||||
} else {
|
||||
url_str += '|';
|
||||
}
|
||||
url_str += `header${header}`;
|
||||
return url_str;
|
||||
}
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
const use_mime =
|
||||
(url.searchParams.get('mime') != 'no');
|
||||
const mime_header = '(Content-Type, text/css)';
|
||||
|
||||
const use_cors =
|
||||
(url.searchParams.has('cors'));
|
||||
const cors_header = '(Access-Control-Allow-Origin, *)';
|
||||
|
||||
const file = url.pathname.substring(url.pathname.lastIndexOf('/') + 1);
|
||||
|
||||
// Respond with a cross-origin CSS resource, using CORS if desired.
|
||||
if (file == 'cross-origin-css.css') {
|
||||
let fetch_url = REMOTE_ORIGIN + BASE_PATH + CSS_FILE;
|
||||
if (use_mime)
|
||||
fetch_url = add_pipe_header(fetch_url, mime_header);
|
||||
if (use_cors)
|
||||
fetch_url = add_pipe_header(fetch_url, cors_header);
|
||||
const mode = use_cors ? 'cors' : 'no-cors';
|
||||
event.respondWith(fetch(fetch_url, {'mode': mode}));
|
||||
return;
|
||||
}
|
||||
|
||||
// Respond with a cross-origin CSS resource with an HTML name. This is only
|
||||
// used in the MIME sniffing test, so MIME is never added.
|
||||
if (file == 'cross-origin-html.css') {
|
||||
const fetch_url = REMOTE_ORIGIN + BASE_PATH + HTML_FILE;
|
||||
event.respondWith(fetch(fetch_url, {mode: 'no-cors'}));
|
||||
return;
|
||||
}
|
||||
|
||||
// Respond with synthetic CSS.
|
||||
if (file == 'synthetic.css') {
|
||||
let headers = {};
|
||||
if (use_mime) {
|
||||
headers['Content-Type'] = 'text/css';
|
||||
}
|
||||
|
||||
event.respondWith(new Response("#synthetic { color: blue; }", {headers}));
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, fallback to network.
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue