Bug 1507952 - Part 5: stream.tee() should not try to call a .start() method. r=arai
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 22 Nov 2018 13:43:03 +0000
changeset 504207 f02a0ed71bcabad55dd6ea1a9eab39e58e82fc2d
parent 504206 51f31e8ac73a27c2a1e71de4e546f2069a243bc7
child 504208 1df56440bdb4a75c59c5527c20ae9139b85655a6
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1507952
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507952 - Part 5: stream.tee() should not try to call a .start() method. r=arai This fix is not particularly clean, but at least it's possible to see why the if statement is there, now that the comments explain how we (imperfectly) implement the {start,pull,cancel}Algorithm arguments. Differential Revision: https://phabricator.services.mozilla.com/D12459
js/src/builtin/Stream.cpp
js/src/tests/non262/ReadableStream/tee-start.js
testing/web-platform/meta/streams/readable-streams/patched-global.dedicatedworker.html.ini
testing/web-platform/meta/streams/readable-streams/patched-global.html.ini
testing/web-platform/meta/streams/readable-streams/patched-global.serviceworker.https.html.ini
testing/web-platform/meta/streams/readable-streams/patched-global.sharedworker.html.ini
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -3130,20 +3130,24 @@ SetUpReadableStreamDefaultController(JSC
     // is a TeeState, we use the ReadableStreamTee algorithms for pulling and
     // canceling.
     controller->setUnderlyingSource(underlyingSource);
 
     // Step 8: Set stream.[[readableStreamController]] to controller.
     stream->setController(controller);
 
     // Step 9: Let startResult be the result of performing startAlgorithm.
+    // If this is a tee stream, the startAlgorithm does nothing and returns
+    // undefined.
     RootedValue startResult(cx);
-    RootedValue controllerVal(cx, ObjectValue(*controller));
-    if (!InvokeOrNoop(cx, underlyingSource, cx->names().start, controllerVal, &startResult)) {
-        return false;
+    if (!underlyingSource.isObject() || !underlyingSource.toObject().is<TeeState>()) {
+        RootedValue controllerVal(cx, ObjectValue(*controller));
+        if (!InvokeOrNoop(cx, underlyingSource, cx->names().start, controllerVal, &startResult)) {
+            return false;
+        }
     }
 
     // Step 10: Let startPromise be a promise resolved with startResult.
     RootedObject startPromise(cx, PromiseObject::unforgeableResolve(cx, startResult));
     if (!startPromise) {
         return false;
     }
 
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/ReadableStream/tee-start.js
@@ -0,0 +1,11 @@
+// |reftest| skip-if(!this.ReadableStream||!this.drainJobQueue)
+// stream.tee() shouldn't try to call a .start() method.
+
+Object.prototype.start = function () { throw "FAIL"; };
+let source = Object.create(null);
+new ReadableStream(source).tee();
+
+drainJobQueue();
+
+if (typeof reportCompare == 'function')
+    reportCompare(0, 0);
deleted file mode 100644
--- a/testing/web-platform/meta/streams/readable-streams/patched-global.dedicatedworker.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[patched-global.dedicatedworker.html]
-  [ReadableStream tee() should not touch Object.prototype properties]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/streams/readable-streams/patched-global.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[patched-global.html]
-  [ReadableStream tee() should not touch Object.prototype properties]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/streams/readable-streams/patched-global.serviceworker.https.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[patched-global.serviceworker.https.html]
-  [ReadableStream tee() should not touch Object.prototype properties]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/streams/readable-streams/patched-global.sharedworker.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[patched-global.sharedworker.html]
-  [ReadableStream tee() should not touch Object.prototype properties]
-    expected: FAIL
-