mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1450644 - WorkerRef should make APIs able to work until the worker is completely terminated - part 2 - BroadcastChannel, r=asuth
This commit is contained in:
parent
97f0ce549b
commit
fd9678b8b2
@ -311,15 +311,15 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
|
||||
// We are already shutting down the worker. Let's return a non-active
|
||||
// object.
|
||||
if (NS_WARN_IF(!workerRef)) {
|
||||
bc->mState = StateClosed;
|
||||
return bc.forget();
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ThreadSafeWorkerRef> tsr = new ThreadSafeWorkerRef(workerRef);
|
||||
|
||||
RefPtr<InitializeRunnable> runnable =
|
||||
new InitializeRunnable(tsr, origin, principalInfo, aRv);
|
||||
runnable->Dispatch(Closing, aRv);
|
||||
runnable->Dispatch(Canceling, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -68,11 +68,6 @@ private:
|
||||
|
||||
~BroadcastChannel();
|
||||
|
||||
void PostMessageData(BroadcastChannelMessage* aData);
|
||||
|
||||
void PostMessageInternal(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void RemoveDocFromBFCache();
|
||||
|
||||
void DisconnectFromOwner() override;
|
||||
|
@ -121,4 +121,21 @@ async_test(t => {
|
||||
}
|
||||
}, 'BroadcastChannel created after a worker self.close()');
|
||||
|
||||
async_test(t => {
|
||||
function workerCode() {
|
||||
close();
|
||||
var bc = new BroadcastChannel('worker-test-after-close');
|
||||
bc.postMessage(true);
|
||||
}
|
||||
|
||||
var bc = new BroadcastChannel('worker-test-after-close');
|
||||
bc.onmessage = function(e) {
|
||||
assert_true(e.data, "BroadcastChannel created on worker shutdown.");
|
||||
t.done();
|
||||
}
|
||||
|
||||
var workerBlob = new Blob([workerCode.toString() + ";workerCode();"], {type:"application/javascript"});
|
||||
new Worker(URL.createObjectURL(workerBlob));
|
||||
}, 'BroadcastChannel used after a worker self.close()');
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user