Skip to content

Commit

Permalink
Correct readyState in WebSocket when worker goes away,
Browse files Browse the repository at this point in the history
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1446366
gecko-commit: fdd61cf07d83133d4a2a719586d1af5bda24c6be
gecko-integration-branch: central
gecko-reviewers: smaug
  • Loading branch information
moz-wptsync-bot authored and jgraham committed Jul 5, 2018
1 parent 234137e commit 273e3f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions websockets/Create-on-worker-shutdown.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ async_test(t => {
function workerCode() {
close();
var ws = new WebSocket(self.location.origin.replace('http', 'ws'));
postMessage(ws.readyState == WebSocket.CONNECTING);
var data = {
originalState: ws.readyState,
afterCloseState: null
};

ws.close();

data.afterCloseState = ws.readyState;
postMessage(data);
}

var workerBlob = new Blob([workerCode.toString() + ";workerCode();"], {
Expand All @@ -13,7 +21,8 @@ async_test(t => {

var w = new Worker(URL.createObjectURL(workerBlob));
w.onmessage = function(e) {
assert_true(e.data, "WebSocket created on worker shutdown.");
assert_equals(e.data.originalState, WebSocket.CONNECTING, "WebSocket created on worker shutdown is in connecting state.");
assert_equals(e.data.afterCloseState, WebSocket.CLOSING, "Closed WebSocket created on worker shutdown is in closing state.");
t.done();
}
}, 'WebSocket created after a worker self.close()');

0 comments on commit 273e3f0

Please sign in to comment.