diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index efc59546f841..31e39a750a0f 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3764,6 +3764,28 @@ nsPIDOMWindowOuter::RefreshMediaElements() } } +void +nsPIDOMWindowOuter::SetServiceWorkersTestingEnabled(bool aEnabled) +{ + // Devtools should only be setting this on the top level window. Its + // ok if devtools clears the flag on clean up of nested windows, though. + // It will have no affect. +#ifdef DEBUG + nsCOMPtr topWindow = GetScriptableTop(); + MOZ_ASSERT_IF(aEnabled, this == topWindow); +#endif + mServiceWorkersTestingEnabled = aEnabled; +} + +bool +nsPIDOMWindowOuter::GetServiceWorkersTestingEnabled() +{ + // Automatically get this setting from the top level window so that nested + // iframes get the correct devtools setting. + nsCOMPtr topWindow = GetScriptableTop(); + return topWindow->mServiceWorkersTestingEnabled; +} + bool nsPIDOMWindowInner::GetAudioCaptured() const { diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 40d28b544ab4..8e356be4aa75 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -865,15 +865,8 @@ public: float GetAudioVolume() const; nsresult SetAudioVolume(float aVolume); - void SetServiceWorkersTestingEnabled(bool aEnabled) - { - mServiceWorkersTestingEnabled = aEnabled; - } - - bool GetServiceWorkersTestingEnabled() - { - return mServiceWorkersTestingEnabled; - } + void SetServiceWorkersTestingEnabled(bool aEnabled); + bool GetServiceWorkersTestingEnabled(); }; NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowOuter, NS_PIDOMWINDOWOUTER_IID)