[Streams API] Add byte length queuing strategy tests for writable streams
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 11:17:39 +0000 (11:17 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 11:17:39 +0000 (11:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148302

Reviewed by Darin Adler.

* streams/reference-implementation/byte-length-queuing-strategy-expected.txt: Added new expectations.
* streams/reference-implementation/byte-length-queuing-strategy.html: Added new writable stream tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190163 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/streams/reference-implementation/byte-length-queuing-strategy-expected.txt
LayoutTests/streams/reference-implementation/byte-length-queuing-strategy.html

index 634942d..ca6c740 100644 (file)
@@ -1,5 +1,15 @@
 2015-09-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
+        [Streams API] Add byte length queuing strategy tests for writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=148302
+
+        Reviewed by Darin Adler.
+
+        * streams/reference-implementation/byte-length-queuing-strategy-expected.txt: Added new expectations.
+        * streams/reference-implementation/byte-length-queuing-strategy.html: Added new writable stream tests.
+
+2015-09-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
         [Streams API] Add brand checks tests for writable streams
         https://bugs.webkit.org/show_bug.cgi?id=148301
 
index a232afb..e08559e 100644 (file)
@@ -4,4 +4,5 @@ PASS Can construct a ByteLengthQueuingStrategy with any value as its high water
 PASS ByteLengthQueuingStrategy constructor behaves as expected with wrong arguments 
 PASS ByteLengthQueuingStrategy size behaves as expected with wrong arguments 
 PASS ByteLengthQueuingStrategy instances have the correct properties 
+FAIL Closing a writable stream with in-flight writes below the high water mark delays the close call properly Can't find variable: WritableStream
 
index 855c4cd..a99c581 100644 (file)
@@ -4,6 +4,8 @@
 <script src='resources/streams-utils.js'></script>
 <script src='resources/byte-length-queuing-strategy.js'></script>
 <script>
+// This is updated till https://github.com/whatwg/streams/commit/ec5ffa036308d9f6350d2946560d48cdbf090939
+
 test(function() {
     var strategy = new ByteLengthQueuingStrategy({ highWaterMark: 4 });
 }, 'Can construct a ByteLengthQueuingStrategy with a valid high water mark');
@@ -65,4 +67,29 @@ test(function() {
                          'highWaterMark property should be a data property with the value passed the connstructor');
     assert_equals(typeof strategy.size, 'function');
 }, 'ByteLengthQueuingStrategy instances have the correct properties');
+
+var test1 = async_test('Closing a writable stream with in-flight writes below the high water mark delays the close call properly');
+test1.step(function() {
+    var isDone = false;
+    var ws = new WritableStream(
+        {
+            write: function(chunk) {
+                return new Promise(test1.step_func(function(resolve) {
+                    setTimeout(test1.step_func(function() {
+                        isDone = true;
+                        resolve();
+                    }), 500);
+                }));
+            },
+            close: function() {
+                assert_true(isDone, 'close is only called once the promise has been resolved');
+                test1.done();
+            }
+        },
+        new ByteLengthQueuingStrategy({ highWaterMark: 1024 * 16 })
+    );
+
+    ws.write({ byteLength: 1024 });
+    ws.close();
+});
 </script>