mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1207727 - Add WPT tests for service worker update algorithm. r=bkelly
This commit is contained in:
parent
0a7f5412e3
commit
975b82b179
@ -220,8 +220,6 @@ skip-if = release_build
|
||||
[test_origin_after_redirect_cached.html]
|
||||
[test_origin_after_redirect_to_https.html]
|
||||
[test_origin_after_redirect_to_https_cached.html]
|
||||
[test_periodic_https_update.html]
|
||||
[test_periodic_update.html]
|
||||
[test_post_message.html]
|
||||
[test_post_message_advanced.html]
|
||||
[test_post_message_source.html]
|
||||
|
@ -160,6 +160,9 @@ pref("dom.serviceWorkers.idle_timeout", 30000);
|
||||
// The amount of time (milliseconds) service workers can be kept running using waitUntil promises.
|
||||
pref("dom.serviceWorkers.idle_extended_timeout", 300000);
|
||||
|
||||
// Enable test for 24 hours update, service workers will always treat last update check time is over 24 hours
|
||||
pref("dom.serviceWorkers.testUpdateOverOneDay", false);
|
||||
|
||||
// Whether nonzero values can be returned from performance.timing.*
|
||||
pref("dom.enable_performance", true);
|
||||
|
||||
|
@ -505,6 +505,18 @@
|
||||
"url": "/_mozilla/service-workers/service-worker/update.https.html"
|
||||
}
|
||||
],
|
||||
"service-workers/service-worker/update-after-navigation-fetch-event.https.html": [
|
||||
{
|
||||
"path": "service-workers/service-worker//update-after-navigation-fetch-event.https.html",
|
||||
"url": "/_mozilla/service-workers/service-worker//update-after-navigation-fetch-event.https.html"
|
||||
}
|
||||
],
|
||||
"service-workers/service-worker/update-after-oneday.https.html": [
|
||||
{
|
||||
"path": "service-workers/service-worker//update-after-oneday.https.html",
|
||||
"url": "/_mozilla/service-workers/service-worker//update-after-oneday.https.html"
|
||||
}
|
||||
],
|
||||
"service-workers/service-worker/waiting.https.html": [
|
||||
{
|
||||
"path": "service-workers/service-worker/waiting.https.html",
|
||||
|
@ -0,0 +1,2 @@
|
||||
[update-after-oneday.https.html]
|
||||
prefs: [dom.serviceWorkers.testUpdateOverOneDay: true]
|
@ -0,0 +1,14 @@
|
||||
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')]
|
||||
|
||||
# Set a normal mimetype.
|
||||
content_type = 'application/javascript'
|
||||
|
||||
headers.append(('Content-Type', content_type))
|
||||
# Return a different script for each access.
|
||||
return headers, '// %s' % (time.time())
|
||||
|
@ -0,0 +1,8 @@
|
||||
<body>
|
||||
<script>
|
||||
function load_image(url) {
|
||||
var img = document.createElement('img');
|
||||
img.src = url;
|
||||
}
|
||||
</script>
|
||||
</body>
|
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Service Worker: Update should be triggered after a navigation fetch event.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/update-nocookie-worker.py';
|
||||
var scope = 'resources/scope/update';
|
||||
var parsed_url = normalizeURL(script);
|
||||
var registration;
|
||||
|
||||
return service_worker_unregister_and_register(t, parsed_url, scope)
|
||||
.then(function(r) {
|
||||
registration = r;
|
||||
return wait_for_state(t, registration.installing, 'activated');
|
||||
})
|
||||
.then(function() {
|
||||
// Navigation to the iframe.
|
||||
return with_iframe(scope);
|
||||
})
|
||||
.then(function(f) {
|
||||
// Navigation fetch event should trigger update.
|
||||
return wait_for_update(t, registration);
|
||||
})
|
||||
.then(function() {
|
||||
return service_worker_unregister_and_done(t, scope);
|
||||
})
|
||||
}, 'Update should be triggered after a navigation fetch event.');
|
||||
</script>
|
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- This test requires browser to treat all registrations are older than 24 hours.
|
||||
Preference 'dom.serviceWorkers.testUpdateOverOneDay' should be enabled during
|
||||
the execution of the test -->
|
||||
<title>Service Worker: Functional events should trigger update if last update time is over 24 hours</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/update-nocookie-worker.py';
|
||||
var scope = 'resources/update/update-after-oneday.https.html';
|
||||
var parsed_url = normalizeURL(script);
|
||||
var registration;
|
||||
var frame;
|
||||
|
||||
return service_worker_unregister_and_register(t, parsed_url, scope)
|
||||
.then(function(r) {
|
||||
registration = r;
|
||||
return wait_for_state(t, registration.installing, 'activated');
|
||||
})
|
||||
.then(function() { return with_iframe(scope); })
|
||||
.then(function(f) {
|
||||
frame = f;
|
||||
return wait_for_update(t, registration);
|
||||
})
|
||||
.then(function() {
|
||||
// Trigger a non-navigation fetch event
|
||||
frame.contentWindow.load_image(normalizeURL('resources/update/dummy'));
|
||||
return wait_for_update(t, registration);
|
||||
})
|
||||
.then(function() {
|
||||
return service_worker_unregister_and_done(t, scope);
|
||||
})
|
||||
}, 'Update should be triggered after a functional event when last update time is over 24 hours');
|
||||
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user