mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1278340 - BroadcastChannel should check for closed flag before dispatching events, r=smaug
This commit is contained in:
parent
05f6aaf959
commit
f8c6086792
@ -105,11 +105,6 @@ private:
|
||||
return mIsKeptAlive;
|
||||
}
|
||||
|
||||
bool IsClosed() const
|
||||
{
|
||||
return mState != StateActive;
|
||||
}
|
||||
|
||||
void RemoveDocFromBFCache();
|
||||
|
||||
RefPtr<BroadcastChannelChild> mActor;
|
||||
|
@ -58,9 +58,8 @@ BroadcastChannelChild::RecvNotify(const ClonedMessageData& aData)
|
||||
nsCOMPtr<DOMEventTargetHelper> helper = mBC;
|
||||
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(helper);
|
||||
|
||||
// This object has been already closed by content or is going to be deleted
|
||||
// soon. No notify is required.
|
||||
if (!eventTarget || mBC->IsClosed()) {
|
||||
// The object is going to be deleted soon. No notify is required.
|
||||
if (!eventTarget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ support-files =
|
||||
[test_broadcastchannel_any.html]
|
||||
[test_broadcastchannel_basic.html]
|
||||
[test_broadcastchannel_close.html]
|
||||
[test_broadcastchannel_close2.html]
|
||||
[test_broadcastchannel_self.html]
|
||||
[test_broadcastchannel_sharedWorker.html]
|
||||
[test_broadcastchannel_worker.html]
|
||||
|
39
dom/broadcastchannel/tests/test_broadcastchannel_close2.html
Normal file
39
dom/broadcastchannel/tests/test_broadcastchannel_close2.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for BroadcastChannel</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="content"></div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
function runTest() {
|
||||
var c1 = new BroadcastChannel('foo');
|
||||
var c2 = new BroadcastChannel('foo');
|
||||
|
||||
var status = [];
|
||||
c2.onmessage = function(e) {
|
||||
status.push(e.data);
|
||||
if (status.length == 2) {
|
||||
is (status[0], 'first', "First message has been received");
|
||||
is (status[1], 'second', "Second message has been received");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
c2.close();
|
||||
}
|
||||
|
||||
c1.postMessage('first');
|
||||
c1.postMessage('second');
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user