Bug 1384162 part 3 - Move document container setting into nsContentDLF::CreateBlankDocument before adding any nodes. r?bz
MozReview-Commit-ID: KdXQH5eRD7a
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8182,24 +8182,22 @@ nsDocShell::CreateAboutBlankContentViewe
principal = NullPrincipal::CreateWithInheritedAttributes(aPrincipal);
} else {
principal = NullPrincipal::CreateWithInheritedAttributes(this);
}
} else {
principal = aPrincipal;
}
// generate (about:blank) document to load
- blankDoc = nsContentDLF::CreateBlankDocument(mLoadGroup, principal);
+ blankDoc = nsContentDLF::CreateBlankDocument(mLoadGroup, principal, this);
if (blankDoc) {
// Hack: set the base URI manually, since this document never
// got Reset() with a channel.
blankDoc->SetBaseURI(aBaseURI);
- blankDoc->SetContainer(this);
-
// Copy our sandbox flags to the document. These are immutable
// after being set here.
blankDoc->SetSandboxFlags(mSandboxFlags);
// create a content viewer for us and the new document
docFactory->CreateInstanceForDocument(
NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view",
getter_AddRefs(viewer));
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -260,32 +260,34 @@ nsContentDLF::CreateInstanceForDocument(
// Bind the document to the Content Viewer
contentViewer->LoadStart(aDocument);
contentViewer.forget(aContentViewer);
return NS_OK;
}
/* static */ already_AddRefed<nsIDocument>
nsContentDLF::CreateBlankDocument(nsILoadGroup* aLoadGroup,
- nsIPrincipal* aPrincipal)
+ nsIPrincipal* aPrincipal,
+ nsDocShell* aContainer)
{
// create a new blank HTML document
nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID));
if (!blankDoc) {
return nullptr;
}
// initialize
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank"));
if (!uri) {
return nullptr;
}
blankDoc->ResetToURI(uri, aLoadGroup, aPrincipal);
+ blankDoc->SetContainer(aContainer);
// add some simple content structure
nsNodeInfoManager *nim = blankDoc->NodeInfoManager();
RefPtr<mozilla::dom::NodeInfo> htmlNodeInfo;
// generate an html html element
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML,
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsContentDLF_h__
#define nsContentDLF_h__
#include "nsIDocumentLoaderFactory.h"
#include "nsMimeTypes.h"
+class nsDocShell;
class nsIChannel;
class nsIContentViewer;
class nsILoadGroup;
class nsIStreamListener;
#define CONTENT_DLF_CONTRACTID "@mozilla.org/content/document-loader-factory;1"
#define PLUGIN_DLF_CONTRACTID "@mozilla.org/content/plugin/document-loader-factory;1"
@@ -47,17 +48,19 @@ public:
nsIContentViewer** aContentViewer);
/**
* Create a blank document using the given loadgroup and given
* principal. aPrincipal is allowed to be null, in which case the
* new document will get the about:blank codebase principal.
*/
static already_AddRefed<nsIDocument>
- CreateBlankDocument(nsILoadGroup* aLoadGroup, nsIPrincipal* aPrincipal);
+ CreateBlankDocument(nsILoadGroup* aLoadGroup,
+ nsIPrincipal* aPrincipal,
+ nsDocShell* aContainer);
private:
static nsresult EnsureUAStyleSheet();
static bool IsImageContentType(const char* aContentType);
};
nsresult
NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
--- a/testing/web-platform/meta/cssom-view/matchMedia.xht.ini
+++ b/testing/web-platform/meta/cssom-view/matchMedia.xht.ini
@@ -1,16 +1,18 @@
[matchMedia.xht]
type: testharness
expected: TIMEOUT
[window.matchMedia exists]
expected: FAIL
[MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"]
- expected: FAIL
+ expected:
+ if stylo: PASS
+ FAIL
[Resize iframe from 200x100 to 200x50, then to 100x50]
expected: NOTRUN
[Listeners are called in the order which they have been added]
expected: NOTRUN
[Listener added twice is only called once.]