Bug 1274364 - BroadcastChannel.postMessage should throw an InvalidStateError DOMException when channel is closed, r=smaug

This commit is contained in:
Andrea Marchesini 2016-05-22 13:22:52 +02:00
Родитель cbf578c96e
Коммит bc5d7ec31f
3 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@ -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>