зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1274364 - BroadcastChannel.postMessage should throw an InvalidStateError DOMException when channel is closed, r=smaug
This commit is contained in:
Родитель
cbf578c96e
Коммит
bc5d7ec31f
|
@ -441,7 +441,7 @@ BroadcastChannel::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
if (mState != StateActive) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,4 +24,5 @@ skip-if = buildapp != 'mulet'
|
|||
[test_broadcastchannel_mozbrowser2.html]
|
||||
skip-if = buildapp != 'mulet'
|
||||
[test_bfcache.html]
|
||||
[test_invalidState.html]
|
||||
[test_dataCloning.html]
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for BroadcastChannel.postMessage invalid State</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">
|
||||
|
||||
var c = new BroadcastChannel("foo");
|
||||
c.close();
|
||||
|
||||
try {
|
||||
c.postMessage("bar");
|
||||
ok(false, "This should throw!");
|
||||
} catch(e) {
|
||||
ok(true, "This should throw!");
|
||||
is(e.name, "InvalidStateError", "Correct invalid-state exception thrown");
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче