Bug 1266178 Make ServiceWorkerClient not assert if the document doesn't have an outer window. r=ehsan
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -30,16 +30,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(Service
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClient)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
ServiceWorkerClientInfo::ServiceWorkerClientInfo(nsIDocument* aDoc)
: mWindowId(0)
+ , mFrameType(FrameType::None)
{
MOZ_ASSERT(aDoc);
nsresult rv = aDoc->GetOrCreateId(mClientId);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to get the UUID of the document.");
}
RefPtr<nsGlobalWindow> innerWindow = nsGlobalWindow::Cast(aDoc->GetInnerWindow());
@@ -59,18 +60,19 @@ ServiceWorkerClientInfo::ServiceWorkerCl
ErrorResult result;
mFocused = aDoc->HasFocus(result);
if (result.Failed()) {
NS_WARNING("Failed to get focus information.");
}
RefPtr<nsGlobalWindow> outerWindow = nsGlobalWindow::Cast(aDoc->GetWindow());
- MOZ_ASSERT(outerWindow);
- if (!outerWindow->IsTopLevelWindow()) {
+ if (!outerWindow) {
+ MOZ_ASSERT(mFrameType == FrameType::None);
+ } else if (!outerWindow->IsTopLevelWindow()) {
mFrameType = FrameType::Nested;
} else if (outerWindow->HadOriginalOpener()) {
mFrameType = FrameType::Auxiliary;
} else {
mFrameType = FrameType::Top_level;
}
}