Back out bug 546857 Part 6 due to talos failures. a=backout

This commit is contained in:
Jonas Sicking 2010-08-19 18:41:58 -07:00
Родитель 5c044cb33c
Коммит 681259ee9f
15 изменённых файлов: 44 добавлений и 159 удалений

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

@ -126,9 +126,6 @@ NS_NewMathMLElement(nsIContent** aResult,
#ifdef MOZ_XUL
nsresult
NS_NewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo);
void
NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo);
#endif
#ifdef MOZ_SVG

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

@ -610,11 +610,6 @@ public:
return sPrefBranch;
}
// Get a permission-manager setting for the given uri and type.
// If the pref doesn't exist or if it isn't ALLOW_ACTION, PR_FALSE is
// returned, otherwise PR_TRUE is returned.
static PRBool IsSitePermAllow(nsIURI* aURI, const char* aType);
static nsILineBreaker* LineBreaker()
{
return sLineBreaker;

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

@ -119,8 +119,8 @@ class Element;
#define NS_IDOCUMENT_IID \
{ 0xbd862a79, 0xc31b, 0x419b, \
{ 0x92, 0x90, 0xa0, 0x77, 0x08, 0x62, 0xd4, 0xc4 } }
{ 0x0218352e, 0x9ddf, 0x43b0, \
{ 0xb6, 0x1d, 0xd3, 0x1a, 0x47, 0x7a, 0xfd, 0x89 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -1291,20 +1291,6 @@ public:
PRBool IsDNSPrefetchAllowed() const { return mAllowDNSPrefetch; }
/**
* Returns PR_TRUE if this document is allowed to contain XUL element and
* use non-builtin XBL bindings.
*/
PRBool AllowXULXBL() {
return mAllowXULXBL == eTriTrue ? PR_TRUE :
mAllowXULXBL == eTriFalse ? PR_FALSE :
InternalAllowXULXBL();
}
void ForceEnableXULXBL() {
mAllowXULXBL = eTriTrue;
}
/**
* PR_TRUE when this document is a static clone of a normal document.
* For example print preview and printing use static documents.
@ -1484,9 +1470,6 @@ protected:
// Never ever call this. Only call GetScriptHandlingObject!
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const = 0;
// Never ever call this. Only call AllowXULXBL!
virtual PRBool InternalAllowXULXBL() = 0;
/**
* These methods should be called before and after dispatching
* a mutation event.
@ -1570,12 +1553,6 @@ protected:
PRPackedBool mIsRegularHTML;
PRPackedBool mIsXUL;
enum {
eTriUnset = 0,
eTriFalse,
eTriTrue
} mAllowXULXBL;
// True if we're loaded as data and therefor has any dangerous stuff, such
// as scripts and plugins, disabled.
PRPackedBool mLoadedAsData;

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

@ -153,7 +153,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsIPrivateDOMEvent.h"
#include "nsXULPopupManager.h"
#include "nsIPermissionManager.h"
#include "nsIContentPrefService.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIRunnable.h"
#include "nsDOMJSUtils.h"
@ -2807,20 +2806,6 @@ nsContentUtils::AddIntPrefVarCache(const char *aPref,
RegisterPrefCallback(aPref, IntVarChanged, data);
}
PRBool
nsContentUtils::IsSitePermAllow(nsIURI* aURI, const char* aType)
{
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService("@mozilla.org/permissionmanager;1");
NS_ENSURE_TRUE(permMgr, PR_FALSE);
PRUint32 perm;
nsresult rv = permMgr->TestPermission(aURI, aType, &perm);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
return perm == nsIPermissionManager::ALLOW_ACTION;
}
static const char *gEventNames[] = {"event"};
static const char *gSVGEventNames[] = {"evt"};
// for b/w compat, the first name to onerror is still 'event', even though it

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

@ -272,10 +272,6 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
if (!document) return NS_ERROR_FAILURE;
if (nsContentUtils::IsSystemPrincipal(mOriginalPrincipal)) {
document->ForceEnableXULXBL();
}
rv = document->StartDocumentLoad(kLoadAsData, parserChannel,
nsnull, nsnull,
getter_AddRefs(listener),

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

@ -3801,30 +3801,6 @@ nsDocument::ScriptLoader()
return mScriptLoader;
}
PRBool
nsDocument::InternalAllowXULXBL()
{
if (nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
mAllowXULXBL = eTriTrue;
return PR_TRUE;
}
nsCOMPtr<nsIURI> princURI;
NodePrincipal()->GetURI(getter_AddRefs(princURI));
if (!princURI) {
mAllowXULXBL = eTriFalse;
return PR_FALSE;
}
if (nsContentUtils::IsSitePermAllow(princURI, "allowXULXBL")) {
mAllowXULXBL = eTriTrue;
return PR_TRUE;
}
mAllowXULXBL = eTriFalse;
return PR_FALSE;
}
// Note: We don't hold a reference to the document observer; we assume
// that it has a live reference to the document.
void

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

@ -1049,7 +1049,6 @@ protected:
virtual nsPIDOMWindow *GetWindowInternal();
virtual nsPIDOMWindow *GetInnerWindowInternal();
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const;
virtual PRBool InternalAllowXULXBL();
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \

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

@ -13,8 +13,8 @@
<iframe type="content" id="xhtml4" src="data:text/xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'/>"/>
<iframe type="content" id="xhtml5" src="data:text/xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;head/>&lt;/html&gt;"/>
<iframe type="content" id="xhtml6" src="data:text/xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;head&gt;&lt;style/>&lt;/head&gt;&lt;/html&gt;"/>
<iframe id="xul1" src="data:application/vnd.mozilla.xul+xml,&lt;window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
<iframe id="xul2" src="data:application/vnd.mozilla.xul+xml,&lt;window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
<iframe type="content" id="xul1" src="data:application/vnd.mozilla.xul+xml,&lt;window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
<iframe type="content" id="xul2" src="data:application/vnd.mozilla.xul+xml,&lt;window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
<iframe type="content" id="svg1" src="data:text/xml,&lt;svg xmlns='http://www.w3.org/2000/svg'&gt;&lt;title id='t'&gt;Test&lt;/title&gt;&lt;/svg&gt;"/>
<iframe type="content" id="svg2" src="data:text/xml,&lt;svg xmlns='http://www.w3.org/2000/svg'&gt;&lt;title id='t'&gt;Test&lt;/title&gt;&lt;/svg&gt;"/>

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

@ -1064,21 +1064,6 @@ static PRBool SchemeIs(nsIURI* aURI, const char* aScheme)
return NS_SUCCEEDED(baseURI->SchemeIs(aScheme, &isScheme)) && isScheme;
}
static PRBool
IsSystemOrChromeURLPrincipal(nsIPrincipal* aPrincipal)
{
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
return PR_TRUE;
}
nsCOMPtr<nsIURI> uri;
aPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, PR_FALSE);
PRBool isChrome = PR_FALSE;
return NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome;
}
NS_IMETHODIMP
nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
nsIDocument* aBoundDocument,
@ -1109,19 +1094,19 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
aBoundDocument);
NS_ENSURE_SUCCESS(rv, rv);
if (!IsSystemOrChromeURLPrincipal(aOriginPrincipal)) {
// Also make sure that we're same-origin with the bound document
// except if the stylesheet has the system principal.
if (!(gAllowDataURIs && SchemeIs(aBindingURI, "data")) &&
!SchemeIs(aBindingURI, "chrome")) {
rv = aBoundDocument->NodePrincipal()->CheckMayLoad(aBindingURI,
PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
}
// Also make sure that we're same-origin with the bound document
// except if the stylesheet has the system principal.
PRBool isSystem;
rv = nsContentUtils::GetSecurityManager()->
IsSystemPrincipal(aOriginPrincipal, &isSystem);
NS_ENSURE_SUCCESS(rv, rv);
// Finally check if this document is allowed to use XBL at all.
NS_ENSURE_TRUE(aBoundDocument->AllowXULXBL(),
NS_ERROR_NOT_AVAILABLE);
if (!isSystem &&
!(gAllowDataURIs && SchemeIs(aBindingURI, "data")) &&
!SchemeIs(aBindingURI, "chrome")) {
rv = aBoundDocument->NodePrincipal()->CheckMayLoad(aBindingURI,
PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
}
}

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

@ -347,24 +347,15 @@ NS_NewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
{
NS_PRECONDITION(aNodeInfo.get(), "need nodeinfo for non-proto Create");
nsIDocument* doc = aNodeInfo.get()->GetDocument();
if (doc && !doc->AllowXULXBL()) {
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
return NS_ERROR_NOT_AVAILABLE;
}
NS_ADDREF(*aResult = new nsXULElement(aNodeInfo));
return NS_OK;
}
void
NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
{
NS_PRECONDITION(aNodeInfo.get(), "need nodeinfo for non-proto Create");
*aResult = nsnull;
// Create an nsXULElement with the specified namespace and tag.
NS_ADDREF(*aResult = new nsXULElement(aNodeInfo));
nsXULElement* element = new nsXULElement(aNodeInfo);
NS_ENSURE_TRUE(element, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult = element);
return NS_OK;
}
//----------------------------------------------------------------------

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

@ -697,8 +697,6 @@ protected:
friend nsresult
NS_NewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
friend void
NS_TrustedNewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
static already_AddRefed<nsXULElement>
Create(nsXULPrototypeElement* aPrototype, nsINodeInfo *aNodeInfo,

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

@ -251,8 +251,6 @@ nsXULDocument::nsXULDocument(void)
mIsXUL = PR_TRUE;
mDelayFrameLoaderInitialization = PR_TRUE;
mAllowXULXBL = eTriTrue;
}
nsXULDocument::~nsXULDocument()

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

@ -48,7 +48,6 @@
#include "nsIURL.h"
#include "nsNodeInfo.h"
#include "nsNodeInfoManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsString.h"
#include "nsContentCID.h"
#include "prprf.h"
@ -157,30 +156,6 @@ nsContentDLF::~nsContentDLF()
NS_IMPL_ISUPPORTS1(nsContentDLF,
nsIDocumentLoaderFactory)
PRBool
MayUseXULXBL(nsIChannel* aChannel)
{
nsIScriptSecurityManager *securityManager =
nsContentUtils::GetSecurityManager();
if (!securityManager) {
return PR_FALSE;
}
nsCOMPtr<nsIPrincipal> principal;
securityManager->GetChannelPrincipal(aChannel, getter_AddRefs(principal));
NS_ENSURE_TRUE(principal, PR_FALSE);
if (nsContentUtils::IsSystemPrincipal(principal)) {
return PR_TRUE;
}
nsCOMPtr<nsIURI> uri;
principal->GetURI(getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, PR_FALSE);
return nsContentUtils::IsSitePermAllow(uri, "allowXULXBL");
}
NS_IMETHODIMP
nsContentDLF::CreateInstance(const char* aCommand,
nsIChannel* aChannel,
@ -303,9 +278,8 @@ nsContentDLF::CreateInstance(const char* aCommand,
// Try XUL
typeIndex = 0;
while (gXULTypes[typeIndex]) {
if (0 == PL_strcmp(gXULTypes[typeIndex++], aContentType) &&
MayUseXULXBL(aChannel)) {
return CreateXULDocument(aCommand,
if (0 == PL_strcmp(gXULTypes[typeIndex++], aContentType)) {
return CreateXULDocument(aCommand,
aChannel, aLoadGroup,
aContentType, aContainer,
aExtraInfo, aDocListener, aDocViewer);

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

@ -2163,6 +2163,8 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
}
}
nsresult rv;
nsNodeInfoManager *nodeInfoManager =
presContext->Document()->NodeInfoManager();
nsCOMPtr<nsINodeInfo> nodeInfo;
@ -2172,7 +2174,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
if (canHaveHorizontal) {
nsCOMPtr<nsINodeInfo> ni = nodeInfo;
NS_TrustedNewXULElement(getter_AddRefs(mHScrollbarContent), ni.forget());
rv = NS_NewElement(getter_AddRefs(mHScrollbarContent),
kNameSpaceID_XUL, ni.forget(), PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
mHScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
NS_LITERAL_STRING("horizontal"), PR_FALSE);
mHScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::clickthrough,
@ -2183,7 +2187,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
if (canHaveVertical) {
nsCOMPtr<nsINodeInfo> ni = nodeInfo;
NS_TrustedNewXULElement(getter_AddRefs(mVScrollbarContent), ni.forget());
rv = NS_NewElement(getter_AddRefs(mVScrollbarContent),
kNameSpaceID_XUL, ni.forget(), PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
mVScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
NS_LITERAL_STRING("vertical"), PR_FALSE);
mVScrollbarContent->SetAttr(kNameSpaceID_None, nsGkAtoms::clickthrough,
@ -2198,7 +2204,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
kNameSpaceID_XUL);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_TrustedNewXULElement(getter_AddRefs(mScrollCornerContent), nodeInfo.forget());
rv = NS_NewXULElement(getter_AddRefs(mScrollCornerContent),
nodeInfo.forget());
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString dir;
switch (resizeStyle) {
@ -2231,7 +2239,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
else if (canHaveHorizontal && canHaveVertical) {
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollcorner, nsnull,
kNameSpaceID_XUL);
NS_TrustedNewXULElement(getter_AddRefs(mScrollCornerContent), nodeInfo.forget());
rv = NS_NewElement(getter_AddRefs(mScrollCornerContent),
kNameSpaceID_XUL, nodeInfo.forget(), PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
if (!aElements.AppendElement(mScrollCornerContent))
return NS_ERROR_OUT_OF_MEMORY;
}

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

@ -127,7 +127,11 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
kNameSpaceID_XUL);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_TrustedNewXULElement(getter_AddRefs(mVideoControls), nodeInfo.forget());
nsresult rv = NS_NewElement(getter_AddRefs(mVideoControls),
kNameSpaceID_XUL,
nodeInfo.forget(),
PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
if (!aElements.AppendElement(mVideoControls))
return NS_ERROR_OUT_OF_MEMORY;