Bug 1186832 - Fix multiple-register.https.html test. r=bkelly,jgraham

Standard scope comparison stuff for the most part. Added <body> tag so
document.body.appendChild() in with_iframe() works. I had to add a simple 404
script because <iframe> apparently only fires the onload event if the
content-type was text/plain or text/html but our test harness delivers JSON by
default leading to timeouts.

Update web-platform-tests expected data
This commit is contained in:
Nikhil Marathe 2015-08-28 17:06:00 -07:00
parent 06d506b806
commit 41c68c7aa3
3 changed files with 20 additions and 19 deletions

View File

@ -1,12 +0,0 @@
[multiple-register.https.html]
type: testharness
expected: TIMEOUT
[Subsequent registrations resolve to the same registration object]
expected: FAIL
[Subsequent registrations from a different iframe resolve to the different registration object but they refer to the same registration and workers]
expected: TIMEOUT
[Concurrent registrations resolve to the same registration object]
expected: FAIL

View File

@ -2,6 +2,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
var worker_url = 'resources/empty-worker.js';
@ -18,10 +19,14 @@ async_test(function(t) {
return navigator.serviceWorker.register(worker_url, { scope: scope });
})
.then(function(new_registration) {
assert_equals(new_registration, registration,
'register should resolve to the same registration');
assert_equals(new_registration.active, registration.active,
'register should resolve to the same worker');
// FIXME: Bug 1201127 will fix scope vs object comparisons.
assert_not_equals(
registration, new_registration,
'register should resolve to the different registration');
assert_equals(new_registration.scope, registration.scope,
'registrations should have the same scope');
assert_equals(new_registration.active.scriptURL, registration.active.scriptURL,
'active workers should have same scriptURL');
assert_equals(new_registration.active.state, 'activated',
'the worker should be in state "activated"');
return registration.unregister();
@ -40,13 +45,14 @@ async_test(function(t) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() { return with_iframe('out-of-scope'); })
.then(function() { return with_iframe('resources/404.py'); })
.then(function(f) {
frame = f;
return frame.contentWindow.navigator.serviceWorker.register(
worker_url, { scope: scope });
})
.then(function(new_registration) {
// FIXME: Bug 1201127 will fix scope vs object comparisons.
assert_not_equals(
registration, new_registration,
'register should resolve to the different registration');
@ -102,8 +108,9 @@ async_test(function(t) {
})
.then(function(registrations) {
registrations.forEach(function(registration) {
assert_equals(registration, registrations[0],
'register should resolve to the same registration');
// FIXME: Bug 1201127 will fix scope vs object comparisons.
assert_equals(registration.scope, registrations[0].scope,
'register should resolve to registrations with the same scope');
});
return registrations[0].unregister();
})
@ -112,3 +119,4 @@ async_test(function(t) {
}, 'Concurrent registrations resolve to the same registration object');
</script>
</body>

View File

@ -0,0 +1,5 @@
# iframe does not fire onload event if the response's content-type is not
# text/plain or text/html so this script exists if you want to test a 404 load
# in an iframe.
def main(req, res):
return 404, [('Content-Type', 'text/plain')], "Page not found"