mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1657130 - Expose worker's window IDs to nsIWorkerDebugger r=dom-workers-and-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D99441
This commit is contained in:
parent
3e98e56e75
commit
3f05d24fad
@ -269,19 +269,45 @@ WorkerDebugger::GetWindow(mozIDOMWindow** aResult) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = DedicatedWorkerWindow();
|
||||
window.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WorkerDebugger::GetWindowIDs(nsTArray<uint64_t>& aResult) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (!mWorkerPrivate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (mWorkerPrivate->IsDedicatedWorker()) {
|
||||
const auto window = DedicatedWorkerWindow();
|
||||
aResult.AppendElement(window->WindowID());
|
||||
} else if (mWorkerPrivate->IsSharedWorker()) {
|
||||
const RemoteWorkerChild* const controller =
|
||||
mWorkerPrivate->GetRemoteWorkerController();
|
||||
MOZ_ASSERT(controller);
|
||||
aResult = controller->WindowIDs().Clone();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> WorkerDebugger::DedicatedWorkerWindow() {
|
||||
MOZ_ASSERT(mWorkerPrivate);
|
||||
|
||||
WorkerPrivate* worker = mWorkerPrivate;
|
||||
while (worker->GetParent()) {
|
||||
worker = worker->GetParent();
|
||||
}
|
||||
|
||||
if (!worker->IsDedicatedWorker()) {
|
||||
*aResult = nullptr;
|
||||
return NS_OK;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = worker->GetWindow();
|
||||
window.forget(aResult);
|
||||
return NS_OK;
|
||||
return worker->GetWindow();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
class mozIDOMWindow;
|
||||
class nsIPrincipal;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -56,6 +57,8 @@ class WorkerDebugger : public nsIWorkerDebugger {
|
||||
void ReportErrorToDebuggerOnMainThread(const nsAString& aFilename,
|
||||
uint32_t aLineno,
|
||||
const nsAString& aMessage);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> DedicatedWorkerWindow();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -37,6 +37,8 @@ interface nsIWorkerDebugger : nsISupports
|
||||
// nested workers) its top-level ancestral worker is associated with.
|
||||
readonly attribute mozIDOMWindow window;
|
||||
|
||||
readonly attribute Array<uint64_t> windowIDs;
|
||||
|
||||
readonly attribute nsIPrincipal principal;
|
||||
|
||||
readonly attribute unsigned long serviceWorkerID;
|
||||
|
@ -66,6 +66,8 @@ class RemoteWorkerChild final
|
||||
|
||||
RefPtr<GenericPromise> MaybeSendSetServiceWorkerSkipWaitingFlag();
|
||||
|
||||
const nsTArray<uint64_t>& WindowIDs() const { return mWindowIDs; }
|
||||
|
||||
private:
|
||||
class InitializeWorkerRunnable;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user