mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1436763 Fix detached-context.https.html to not timeout due to promise reaction callbacks not firing for detached globals. r=catalinb
This commit is contained in:
parent
bc18da5fe7
commit
5c4463aa45
@ -545706,7 +545706,7 @@
|
||||
"testharness"
|
||||
],
|
||||
"html/browsers/origin/cross-origin-objects/cross-origin-objects.html": [
|
||||
"8fe0ecd10bcc148d1e49668025e4515b70540f89",
|
||||
"5a5a86a7f989232a78a89e07e5678a1eeb8d4d6d",
|
||||
"testharness"
|
||||
],
|
||||
"html/browsers/origin/cross-origin-objects/frame-with-then.html": [
|
||||
@ -583054,7 +583054,7 @@
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/activation.https.html": [
|
||||
"cdd7cd200ff4ec3df61c257305953b3a1f369ab8",
|
||||
"b7a9ca969b4122f1b9adc973c60044a6ab2a2a95",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/active.https.html": [
|
||||
@ -583150,7 +583150,7 @@
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/detached-context.https.html": [
|
||||
"c7645323ba0753f35beaef90836631ca16f64d3a",
|
||||
"a4e96edc51927eb29873b0c97a7232f71ae43378",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/extendable-event-async-waituntil.https.html": [
|
||||
@ -584534,7 +584534,7 @@
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/test-helpers.sub.js": [
|
||||
"55acaa1edd73a39a834e1a1ee0952f47a03e3c78",
|
||||
"fee1648c02422cd2607b008b9a1ef0834385c69c",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/testharness-helpers.js": [
|
||||
|
@ -6,24 +6,6 @@
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
// Registers, waits for activation, then unregisters on a dummy scope.
|
||||
//
|
||||
// This helper can be used in tests that assert that activation doesn't happen.
|
||||
// It would not be sufficient to check the .waiting/.active properties once,
|
||||
// since activation could be scheduled and just hasn't happened yet. Since this
|
||||
// helper shows that activation of another registration completed, we can be
|
||||
// sure that activation really will not happen.
|
||||
function wait_for_activation_on_dummy_scope(t) {
|
||||
var dummy_scope = 'resources/there/is/no/there/there';
|
||||
var registration;
|
||||
return navigator.serviceWorker.register('resources/empty-worker.js',
|
||||
{ scope: dummy_scope })
|
||||
.then(r => {
|
||||
registration = r;
|
||||
return wait_for_state(t, registration.installing, 'activated');
|
||||
})
|
||||
.then(() => registration.unregister());
|
||||
}
|
||||
// Returns {registration, iframe}, where |registration| has an active and
|
||||
// waiting worker. The active worker controls |iframe| and has an inflight
|
||||
// message event that can be finished by calling
|
||||
|
@ -16,6 +16,7 @@ promise_test(t => {
|
||||
const scope_for_main = 'resources/' + scope_for_iframe;
|
||||
const script = 'resources/empty-worker.js';
|
||||
let frame;
|
||||
let resolvedCount = 0;
|
||||
|
||||
return service_worker_unregister(t, scope_for_main)
|
||||
.then(() => {
|
||||
@ -41,9 +42,23 @@ promise_test(t => {
|
||||
assert_equals(r.active.state, 'activated');
|
||||
assert_equals(r.scope, normalizeURL(scope_for_main));
|
||||
r.onupdatefound = () => { /* empty */ };
|
||||
return Promise.all([
|
||||
promise_rejects(t, 'InvalidStateError', r.unregister()),
|
||||
promise_rejects(t, 'InvalidStateError', r.update())]);
|
||||
|
||||
// We want to verify that unregister() and update() do not
|
||||
// resolve on a detached registration. We can't check for
|
||||
// an explicit rejection, though, because not all browsers
|
||||
// fire rejection callbacks on detached promises. Instead
|
||||
// we wait for a dummy scope to install, activate, and
|
||||
// unregister before declaring that the promises did not
|
||||
// resolve.
|
||||
r.unregister().then(() => resolvedCount += 1,
|
||||
() => {});
|
||||
r.update().then(() => resolvedCount += 1,
|
||||
() => {});
|
||||
return wait_for_activation_on_dummy_scope(t);
|
||||
})
|
||||
.then(() => {
|
||||
assert_equals(resolvedCount, 0,
|
||||
'methods called on a detached registration should not resolve');
|
||||
})
|
||||
}, 'accessing a ServiceWorkerRegistration from a removed iframe');
|
||||
|
||||
|
@ -257,3 +257,17 @@ function with_sandboxed_iframe(url, sandbox) {
|
||||
document.body.appendChild(frame);
|
||||
});
|
||||
}
|
||||
|
||||
// Registers, waits for activation, then unregisters on a dummy scope.
|
||||
//
|
||||
// This can be used to wait for a period of time needed to register,
|
||||
// activate, and then unregister a service worker. When checking that
|
||||
// certain behavior does *NOT* happen, this is preferable to using an
|
||||
// arbitrary delay.
|
||||
async function wait_for_activation_on_dummy_scope(t) {
|
||||
const script = 'resources/empty-worker.js';
|
||||
const scope = 'resources/there/is/no/there/there?' + Date.now();
|
||||
let registration = await navigator.serviceWorker.register(script, { scope });
|
||||
await wait_for_state(t, registration.installing, 'activated');
|
||||
await registration.unregister();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user