mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 983301 part 2. Change Promise to not be distinguishable from any other type. r=peterv
This commit is contained in:
parent
c6f4dbf8d9
commit
de15290127
@ -136,10 +136,10 @@ class Configuration:
|
||||
while True:
|
||||
if t.isMozMap():
|
||||
t = t.inner
|
||||
elif t.isPromise():
|
||||
t = t.promiseInnerType()
|
||||
elif t.unroll() != t:
|
||||
t = t.unroll()
|
||||
elif t.isPromise():
|
||||
t = t.promiseInnerType()
|
||||
else:
|
||||
break
|
||||
if t.isUnion():
|
||||
|
@ -2026,6 +2026,9 @@ class IDLNullableType(IDLType):
|
||||
def isInterface(self):
|
||||
return self.inner.isInterface()
|
||||
|
||||
def isPromise(self):
|
||||
return self.inner.isPromise()
|
||||
|
||||
def isCallbackInterface(self):
|
||||
return self.inner.isCallbackInterface()
|
||||
|
||||
@ -2158,11 +2161,14 @@ class IDLSequenceType(IDLType):
|
||||
return self.inner.unroll()
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
return (other.isPrimitive() or other.isString() or other.isEnum() or
|
||||
other.isDate() or other.isInterface() or other.isDictionary() or
|
||||
other.isDate() or other.isInterface() or
|
||||
other.isDictionary() or
|
||||
other.isCallback() or other.isMozMap())
|
||||
|
||||
def _getDependentObjects(self):
|
||||
@ -2217,6 +2223,8 @@ class IDLMozMapType(IDLType):
|
||||
return self
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
@ -2442,6 +2450,8 @@ class IDLArrayType(IDLType):
|
||||
return self.inner.unroll()
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
@ -2676,6 +2686,10 @@ class IDLWrapperType(IDLType):
|
||||
assert False
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if self.isPromise():
|
||||
return False
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
@ -2935,6 +2949,8 @@ class IDLBuiltinType(IDLType):
|
||||
return IDLBuiltinType.TagLookup[self._typeTag]
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
@ -4192,6 +4208,8 @@ class IDLCallbackType(IDLType):
|
||||
return IDLType.Tags.callback
|
||||
|
||||
def isDistinguishableFrom(self, other):
|
||||
if other.isPromise():
|
||||
return False
|
||||
if other.isUnion():
|
||||
# Just forward to the union; it'll deal
|
||||
return other.isDistinguishableFrom(self)
|
||||
|
@ -160,13 +160,15 @@ def WebIDLTest(parser, harness):
|
||||
"optional Dict2", "sequence<long>", "sequence<short>",
|
||||
"MozMap<object>", "MozMap<Dict>", "MozMap<long>",
|
||||
"long[]", "short[]", "Date", "Date?", "any",
|
||||
"Promise<any>", "Promise<any>?",
|
||||
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer", "SharedArrayBufferView",
|
||||
"Uint8Array", "SharedUint8Array", "Uint16Array", "SharedUint16Array" ]
|
||||
# When we can parse Date and RegExp, we need to add them here.
|
||||
|
||||
# Try to categorize things a bit to keep list lengths down
|
||||
def allBut(list1, list2):
|
||||
return [a for a in list1 if a not in list2 and a != "any"]
|
||||
return [a for a in list1 if a not in list2 and
|
||||
(a != "any" and a != "Promise<any>" and a != "Promise<any>?")]
|
||||
numerics = [ "long", "short", "long?", "short?" ]
|
||||
booleans = [ "boolean", "boolean?" ]
|
||||
primitives = numerics + booleans
|
||||
@ -182,7 +184,7 @@ def WebIDLTest(parser, harness):
|
||||
"UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes
|
||||
nullables = ["long?", "short?", "boolean?", "Interface?",
|
||||
"CallbackInterface?", "optional Dict", "optional Dict2",
|
||||
"Date?", "any"]
|
||||
"Date?", "any", "Promise<any>?"]
|
||||
dates = [ "Date", "Date?" ]
|
||||
sequences = [ "sequence<long>", "sequence<short>" ]
|
||||
arrays = [ "long[]", "short[]" ]
|
||||
@ -238,6 +240,8 @@ def WebIDLTest(parser, harness):
|
||||
setDistinguishable("Date", allBut(argTypes, dates + ["object"]))
|
||||
setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"]))
|
||||
setDistinguishable("any", [])
|
||||
setDistinguishable("Promise<any>", [])
|
||||
setDistinguishable("Promise<any>?", [])
|
||||
setDistinguishable("ArrayBuffer", allBut(argTypes, ["ArrayBuffer", "object"]))
|
||||
setDistinguishable("ArrayBufferView", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "Uint16Array", "object"]))
|
||||
setDistinguishable("Uint8Array", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "object"]))
|
||||
@ -265,6 +269,7 @@ def WebIDLTest(parser, harness):
|
||||
callback Callback2 = long(short arg);
|
||||
dictionary Dict {};
|
||||
dictionary Dict2 {};
|
||||
interface _Promise {};
|
||||
interface TestInterface {%s
|
||||
};
|
||||
"""
|
||||
|
@ -18,7 +18,7 @@ interface FetchEvent : Event {
|
||||
readonly attribute boolean isReload;
|
||||
|
||||
[Throws]
|
||||
void respondWith((Response or Promise<Response>) r);
|
||||
void respondWith(Promise<Response> r);
|
||||
};
|
||||
|
||||
dictionary FetchEventInit : EventInit {
|
||||
|
@ -348,34 +348,19 @@ RespondWithHandler::CancelRequest(nsresult aStatus)
|
||||
} // namespace
|
||||
|
||||
void
|
||||
FetchEvent::RespondWith(const ResponseOrPromise& aArg, ErrorResult& aRv)
|
||||
FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
||||
{
|
||||
if (mWaitToRespond) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise;
|
||||
|
||||
if (aArg.IsResponse()) {
|
||||
nsRefPtr<Response> res = &aArg.GetAsResponse();
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(worker);
|
||||
worker->AssertIsOnWorkerThread();
|
||||
promise = Promise::Create(worker->GlobalScope(), aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
promise->MaybeResolve(res);
|
||||
} else if (aArg.IsPromise()) {
|
||||
promise = &aArg.GetAsPromise();
|
||||
}
|
||||
nsRefPtr<InternalRequest> ir = mRequest->GetInternalRequest();
|
||||
mWaitToRespond = true;
|
||||
nsRefPtr<RespondWithHandler> handler =
|
||||
new RespondWithHandler(mChannel, mServiceWorker, mRequest->Mode(),
|
||||
ir->IsClientRequest());
|
||||
promise->AppendNativeHandler(handler);
|
||||
aArg.AppendNativeHandler(handler);
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerClient>
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
RespondWith(const ResponseOrPromise& aArg, ErrorResult& aRv);
|
||||
RespondWith(Promise& aArg, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
ForwardTo(const nsAString& aUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user