mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Update web-platform-tests to revision 34f9b93c2749043ba68485dea92d1fb554075e60
This commit is contained in:
parent
fd64f11efe
commit
ace02666c2
75 changed files with 1496 additions and 120 deletions
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Service Worker: isSecureContext</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
promise_test(async (t) => {
|
||||
var url = 'isSecureContext.serviceworker.js';
|
||||
var scope = 'empty.html';
|
||||
var frame_sw, sw_registration;
|
||||
|
||||
await service_worker_unregister(t, scope);
|
||||
var f = await with_iframe(scope);
|
||||
t.add_cleanup(function() {
|
||||
f.remove();
|
||||
});
|
||||
frame_sw = f.contentWindow.navigator.serviceWorker;
|
||||
var registration = await navigator.serviceWorker.register(url, {scope: scope});
|
||||
sw_registration = registration;
|
||||
await wait_for_state(t, registration.installing, 'activated');
|
||||
fetch_tests_from_worker(sw_registration.active);
|
||||
}, 'Setting up tests');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
importScripts("/resources/testharness.js");
|
||||
|
||||
test(() => {
|
||||
assert_true(self.isSecureContext, true);
|
||||
}, "isSecureContext");
|
|
@ -36,6 +36,15 @@ function registration_tests_script_url(register_method, check_error_types) {
|
|||
'URL-encoded backslash in the script URL should be rejected.');
|
||||
}, 'Script URL including uppercase URL-encoded backslash');
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'data:application/javascript,';
|
||||
var scope = 'resources/scope/data-url-in-script-url';
|
||||
return promise_rejects(t,
|
||||
check_error_types ? new TypeError : null,
|
||||
register_method(script, {scope: scope}),
|
||||
'Data URLs should not be registered as service workers.');
|
||||
}, 'Script URL is a data URL');
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/././empty-worker.js';
|
||||
var scope = 'resources/scope/parent-reference-in-script-url';
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import time
|
||||
|
||||
def main(request, response):
|
||||
# no-cache itself to ensure the user agent finds a new version for each update.
|
||||
headers = [('Cache-Control', 'no-cache, must-revalidate'),
|
||||
('Pragma', 'no-cache')]
|
||||
content_type = 'application/javascript'
|
||||
|
||||
headers.append(('Content-Type', content_type))
|
||||
|
||||
body = '''
|
||||
let promise = self.registration.update()
|
||||
onmessage = (evt) => {
|
||||
promise.then(r => {
|
||||
evt.source.postMessage(self.registration === r ? 'PASS' : 'FAIL');
|
||||
});
|
||||
};'''
|
||||
return headers, '/* %s %s */ %s' % (time.time(), time.clock(), body)
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: Registration update()</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
function wait_for_message() {
|
||||
return new Promise(resolve => {
|
||||
navigator.serviceWorker.addEventListener("message",
|
||||
e => {
|
||||
resolve(e.data);
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
const script = './resources/update-top-level-worker.py';
|
||||
const scope = './resources/empty.html?update-result';
|
||||
|
||||
let reg = await navigator.serviceWorker.register(script, { scope });
|
||||
t.add_cleanup(async _ => await reg.unregister());
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
|
||||
reg.addEventListener("updatefound",
|
||||
() => assert_unreached("shouldn't find an update"));
|
||||
|
||||
reg.active.postMessage("ping");
|
||||
assert_equals(await wait_for_message(), 'PASS', 'did not hang');
|
||||
}, 'A serviceworker with a top-level update should not hang');
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue