[Streams API] Shield streams against user replacing the Promise constructor
[WebKit-https.git] / Source / WebCore / Modules / streams / StreamInternals.js
index cb23af3779d64c1f60a0b6dfd504cc7132e4980b..0475c510e7f0dd2e95088fb45c657ab8b5a06ec2 100644 (file)
@@ -44,12 +44,12 @@ function promiseInvokeOrNoop(object, key, args)
     try {
         var method = object[key];
         if (typeof method === "undefined")
-            return Promise.resolve();
+            return @Promise.resolve();
         var result = method.@apply(object, args);
-        return Promise.resolve(result);
+        return @Promise.resolve(result);
     }
     catch(error) {
-        return Promise.reject(error);
+        return @Promise.reject(error);
     }
 
 }
@@ -63,10 +63,10 @@ function promiseInvokeOrFallbackOrNoop(object, key1, args1, key2, args2)
         if (typeof method === "undefined")
             return @promiseInvokeOrNoop(object, key2, args2);
         const result = method.@apply(object, args1);
-        return Promise.resolve(result);
+        return @Promise.resolve(result);
     }
     catch(error) {
-        return Promise.reject(error);
+        return @Promise.reject(error);
     }
 }
 
@@ -90,43 +90,6 @@ function validateAndNormalizeQueuingStrategy(size, highWaterMark)
     return normalizedStrategy;
 }
 
-function createNewStreamsPromise()
-{
-    "use strict";
-
-    var resolveFunction;
-    var rejectFunction;
-    var promise = new Promise(function(resolve, reject) {
-        resolveFunction = resolve;
-        rejectFunction = reject;
-    });
-    promise.@resolve = resolveFunction;
-    promise.@reject = rejectFunction;
-    return promise;
-}
-
-function resolveStreamsPromise(promise, value)
-{
-    "use strict";
-
-    if (promise && promise.@resolve) {
-        promise.@resolve(value);
-        promise.@resolve = undefined;
-        promise.@reject = undefined;
-    }
-}
-
-function rejectStreamsPromise(promise, value)
-{
-    "use strict";
-
-    if (promise && promise.@reject) {
-        promise.@reject(value);
-        promise.@resolve = undefined;
-        promise.@reject = undefined;
-    }
-}
-
 function newQueue()
 {
     return { content: [], size: 0 };