Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py

Issue 23069004: Check WebSocket close code sent on unload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating the code comments for landing Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py
diff --git a/LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py b/LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py
index 23acea7789c6051411a14948360097f45132f346..a2078de8b7ca731810250d4e27380fa312d0b7ae 100644
--- a/LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py
+++ b/LayoutTests/http/tests/websocket/tests/hybi/close-on-unload_wsh.py
@@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+import json
from mod_pywebsocket import msgutil
@@ -42,15 +42,17 @@ def web_socket_do_extra_handshake(request):
def web_socket_transfer_data(request):
global connections
connections[request] = True
- socketName = None
+ message = None
+ dataToBroadcast = {}
try:
- socketName = msgutil.receive_message(request)
- # notify to client that socketName is received by server.
- msgutil.send_message(request, socketName)
+ message = msgutil.receive_message(request)
+ # notify to client that message is received by server.
+ msgutil.send_message(request, message)
msgutil.receive_message(request) # wait, and exception by close.
- socketName = socketName + ': ' + request.ws_close_code
+ dataToBroadcast["message"] = message
+ dataToBroadcast["closeCode"] = str(request.ws_close_code)
finally:
- # request is closed. notify this socketName to other web sockets.
+ # request is closed. notify this dataToBroadcast to other web sockets.
del connections[request]
for ws in connections.keys():
- msgutil.send_message(ws, socketName)
+ msgutil.send_message(ws, json.dumps(dataToBroadcast))

Powered by Google App Engine
This is Rietveld 408576698