It's fairly obvious when you see the source code: http://trac.webkit.org/browser/trunk/Source/WebCore/websockets/WebSocket.cpp?rev=94274#L257 257 m_bufferedAmountAfterClose += message.utf8().length() + 2; // 2 for frameing This code only assumes hixie76 protocol in which every frame has two-byte framing overhead ("\x00" and "\xFF"). Let's make this code hybi-aware.
Created attachment 105901 [details] Patch
Comment on attachment 105901 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=105901&action=review > LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:25 > +function getExpectedFramingOverhead(payloadSize) > +{ > + var overhead = 2 + 4; // Base header size and masking key size. > + if (payloadSize > 0xFFFF) > + overhead += 8; > + else if (payloadSize > 125) > + overhead += 2; > + return overhead; > +} Copying the code logic in C++ to the test code makes the test meaningless. We should have constant values of the overheads for each test cases. > LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:59 > +function doTest(message) nit: doTest -> testBufferedAmount ?
Created attachment 105918 [details] Patch v2
Comment on attachment 105901 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=105901&action=review >> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:25 >> +} > > Copying the code logic in C++ to the test code makes the test meaningless. We should have constant values of the overheads for each test cases. Fixed. >> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:59 >> +function doTest(message) > > nit: doTest -> testBufferedAmount ? Fixed.
Comment on attachment 105918 [details] Patch v2 ok
Comment on attachment 105918 [details] Patch v2 Clearing flags on attachment: 105918 Committed r94282: <http://trac.webkit.org/changeset/94282>
All reviewed patches have been landed. Closing bug.