mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1217909 P4 Extend wpt tests to verify update() promise values for different script failures. r=catalinb
This commit is contained in:
parent
a670404ca2
commit
034b029b68
@ -11,6 +11,7 @@ def main(request, response):
|
||||
('Pragma', 'no-cache')]
|
||||
|
||||
content_type = ''
|
||||
extra_body = ''
|
||||
|
||||
if mode == 'init':
|
||||
# Set a normal mimetype.
|
||||
@ -24,11 +25,21 @@ def main(request, response):
|
||||
response.set_cookie('mode', 'error');
|
||||
elif mode == 'error':
|
||||
# Set a disallowed mimetype.
|
||||
# Unset and delete cookie to clean up the test setting.
|
||||
# Set cookie value to 'syntax-error' so the next fetch will work in 'syntax-error' mode.
|
||||
content_type = 'text/html'
|
||||
response.set_cookie('mode', 'syntax-error');
|
||||
elif mode == 'syntax-error':
|
||||
# Set cookie value to 'throw-install' so the next fetch will work in 'throw-install' mode.
|
||||
content_type = 'application/javascript'
|
||||
response.set_cookie('mode', 'throw-install');
|
||||
extra_body = 'badsyntax(isbad;'
|
||||
elif mode == 'throw-install':
|
||||
# Unset and delete cookie to clean up the test setting.
|
||||
content_type = 'application/javascript'
|
||||
response.delete_cookie('mode')
|
||||
extra_body = "addEventListener('install', function(e) { throw new Error('boom'); });"
|
||||
|
||||
headers.append(('Content-Type', content_type))
|
||||
# Return a different script for each access.
|
||||
return headers, '// %s' % (time.time())
|
||||
return headers, '/* %s */ %s' % (time.time(), extra_body)
|
||||
|
||||
|
@ -69,6 +69,36 @@ promise_test(function(t) {
|
||||
'promise reject with a SecurityError.');
|
||||
assert_equals(registration.active.scriptURL, expected_url,
|
||||
'active should still exist after update failure.');
|
||||
|
||||
// A new worker(generated by update-worker.py) should be found.
|
||||
// The returned promise should reject as update-worker.py returns
|
||||
// a worker script with a syntax error.
|
||||
return registration.update();
|
||||
})
|
||||
.then(
|
||||
function() { assert_unreached("update() should reject."); },
|
||||
function(e) {
|
||||
assert_throws({name: 'TypeError'}, function () { throw e; },
|
||||
'A script syntax error should make update() ' +
|
||||
'promise reject with a TypeError.');
|
||||
assert_equals(registration.active.scriptURL, expected_url,
|
||||
'active should still exist after update failure.');
|
||||
|
||||
// A new worker(generated by update-worker.py) should be found.
|
||||
// The returned promise should not reject, even though
|
||||
// update-worker.py returns a worker script that throws in the
|
||||
// install event handler.
|
||||
return Promise.all([registration.update(),
|
||||
wait_for_update(t, registration)]);
|
||||
})
|
||||
.then(function() {
|
||||
assert_equals(registration.installing.scriptURL, expected_url,
|
||||
'new installing should be set after update resolves.');
|
||||
assert_equals(registration.waiting, null,
|
||||
'waiting should be null after activated.');
|
||||
assert_equals(registration.active.scriptURL, expected_url,
|
||||
'active should still exist after update found.');
|
||||
|
||||
return service_worker_unregister_and_done(t, scope);
|
||||
});
|
||||
}, 'Update a registration.');
|
||||
|
Loading…
Reference in New Issue
Block a user