Backed out changeset 29c306545aa5 (bug 1539528) for mochitest failure at /builds/worker/workspace/build/src/xpcom/threads/nsThreadManager.cpp:69. On a CLOSED TREE

This commit is contained in:
Daniel Varga 2019-03-29 11:18:33 +02:00
Родитель c711763836
Коммит 7707038236
2 изменённых файлов: 25 добавлений и 16 удалений

Просмотреть файл

@ -870,8 +870,8 @@ WebSocketImpl::GetInterface(const nsIID& aIID, void** aResult) {
// WebSocket
////////////////////////////////////////////////////////////////////////////////
WebSocket::WebSocket(nsIGlobalObject* aGlobal)
: DOMEventTargetHelper(aGlobal),
WebSocket::WebSocket(nsPIDOMWindowInner* aOwnerWindow)
: DOMEventTargetHelper(aOwnerWindow),
mIsMainThread(true),
mKeepingAlive(false),
mCheckMustKeepAlive(true),
@ -879,8 +879,6 @@ WebSocket::WebSocket(nsIGlobalObject* aGlobal)
mBinaryType(dom::BinaryType::Blob),
mMutex("WebSocket::mMutex"),
mReadyState(CONNECTING) {
MOZ_ASSERT(aGlobal);
mImpl = new WebSocketImpl(this);
mIsMainThread = mImpl->mIsMainThread;
}
@ -1182,12 +1180,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
const nsACString& aNegotiatedExtensions, ErrorResult& aRv) {
MOZ_ASSERT_IF(!aTransportProvider, aNegotiatedExtensions.IsEmpty());
nsCOMPtr<nsIPrincipal> principal;
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
if (NS_WARN_IF(!global)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsPIDOMWindowInner> ownerWindow;
if (NS_IsMainThread()) {
nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
@ -1209,6 +1202,12 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
if (!ownerWindow) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
}
nsTArray<nsString> protocolArray;
@ -1232,7 +1231,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
protocolArray.AppendElement(protocolElement);
}
RefPtr<WebSocket> webSocket = new WebSocket(global);
RefPtr<WebSocket> webSocket = new WebSocket(ownerWindow);
RefPtr<WebSocketImpl> webSocketImpl = webSocket->mImpl;
bool connectionFailed = true;
@ -1350,7 +1349,6 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
if (NS_IsMainThread()) {
MOZ_ASSERT(principal);
nsCOMPtr<nsPIDOMWindowInner> ownerWindow = do_QueryInterface(global);
nsPIDOMWindowOuter* outerWindow = ownerWindow->GetOuterWindow();
uint64_t windowID = 0;
@ -1802,8 +1800,17 @@ nsresult WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
AssertIsOnTargetThread();
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(GetOwnerGlobal()))) {
return NS_ERROR_FAILURE;
if (NS_IsMainThread()) {
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
return NS_ERROR_FAILURE;
}
} else {
MOZ_ASSERT(!mIsMainThread);
MOZ_ASSERT(mImpl->mWorkerRef);
if (NS_WARN_IF(!jsapi.Init(mImpl->mWorkerRef->Private()->GlobalScope()))) {
return NS_ERROR_FAILURE;
}
}
JSContext* cx = jsapi.cx();
@ -1822,7 +1829,7 @@ nsresult WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
messageType = nsIWebSocketEventListener::TYPE_BLOB;
RefPtr<Blob> blob =
Blob::CreateStringBlob(GetOwnerGlobal(), aData, EmptyString());
Blob::CreateStringBlob(GetOwner(), aData, EmptyString());
MOZ_ASSERT(blob);
if (!ToJSValue(cx, blob, &jsData)) {

Просмотреть файл

@ -55,6 +55,8 @@ class WebSocket final : public DOMEventTargetHelper {
virtual void DisconnectFromOwner() override;
// nsWrapperCache
nsPIDOMWindowInner* GetParentObject() { return GetOwner(); }
virtual JSObject* WrapObject(JSContext* cx,
JS::Handle<JSObject*> aGivenProto) override;
@ -136,7 +138,7 @@ class WebSocket final : public DOMEventTargetHelper {
void Send(const ArrayBufferView& aData, ErrorResult& aRv);
private: // constructor && destructor
explicit WebSocket(nsIGlobalObject* aGlobal);
explicit WebSocket(nsPIDOMWindowInner* aOwnerWindow);
virtual ~WebSocket();
void SetReadyState(uint16_t aReadyState);