mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1932730 - Pass HybridEventTarget for endpoint binding r=asuth
Doing so registers a shutdown task to workerprivate and prevents CC. Differential Revision: https://phabricator.services.mozilla.com/D229822
This commit is contained in:
parent
ea38eaf128
commit
ef42dea31f
@ -1151,16 +1151,15 @@ bool Notification::CreateActor() {
|
||||
mActor = new notification::NotificationChild(
|
||||
persistent ? nullptr : this,
|
||||
window ? window->GetWindowGlobalChild() : nullptr);
|
||||
if (!childEndpoint.Bind(mActor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsISerialEventTarget* target = nullptr;
|
||||
nsIPrincipal* principal;
|
||||
nsIPrincipal* effectiveStoragePrincipal;
|
||||
bool isSecureContext;
|
||||
|
||||
// TODO: Should get nsIGlobalObject methods for each method
|
||||
if (WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate()) {
|
||||
target = workerPrivate->HybridEventTarget();
|
||||
principal = workerPrivate->GetPrincipal();
|
||||
effectiveStoragePrincipal = workerPrivate->GetEffectiveStoragePrincipal();
|
||||
isSecureContext = workerPrivate->IsSecureContext();
|
||||
@ -1172,6 +1171,10 @@ bool Notification::CreateActor() {
|
||||
isSecureContext = win->IsSecureContext();
|
||||
}
|
||||
|
||||
if (!childEndpoint.Bind(mActor, target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
(void)backgroundActor->SendCreateNotificationParent(
|
||||
std::move(parentEndpoint), WrapNotNull(principal),
|
||||
WrapNotNull(effectiveStoragePrincipal), isSecureContext, mID, mScope,
|
||||
|
@ -0,0 +1,34 @@
|
||||
// META: title=An active notification should prevent worker cycle collection
|
||||
// META: script=/resources/testdriver.js
|
||||
// META: script=/resources/testdriver-vendor.js
|
||||
// META: script=/common/gc.js
|
||||
// META: script=resources/helpers.js
|
||||
|
||||
promise_setup(async () => {
|
||||
await trySettingPermission("granted");
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
let worker = new Worker(URL.createObjectURL(new Blob([`
|
||||
const n = new Notification("foo");
|
||||
onmessage = () => n.close();
|
||||
n.onclose = () => self.postMessage("closed");
|
||||
postMessage("ready");
|
||||
`])));
|
||||
await new Promise(resolve => {
|
||||
worker.addEventListener("message", ev => {
|
||||
if (ev.data === "ready") {
|
||||
resolve();
|
||||
}
|
||||
}, { once: true });
|
||||
});
|
||||
const weakref = new WeakRef(worker);
|
||||
worker = null;
|
||||
|
||||
t.add_cleanup(() => {
|
||||
weakref.deref()?.postMessage("close");
|
||||
});
|
||||
|
||||
await garbageCollect();
|
||||
assert_true(!!weakref.deref());
|
||||
});
|
Loading…
Reference in New Issue
Block a user