From c486969a1071084d9bf57930c7eeb03fbd3f337b Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Wed, 15 Sep 2010 15:53:01 -0700 Subject: [PATCH] Bug 591198: Display element using normal layout rules if XBL binding fails for security reasons. r=jst a=blocker --- content/base/public/nsContentErrors.h | 4 +++ content/xbl/src/nsXBLService.cpp | 7 +++-- content/xbl/test/Makefile.in | 3 ++ content/xbl/test/file_bug591198_inner.html | 38 ++++++++++++++++++++++++ content/xbl/test/file_bug591198_xbl.xml | 5 ++++ content/xbl/test/test_bug591198.html | 47 ++++++++++++++++++++++++++++++ layout/base/nsCSSFrameConstructor.cpp | 4 +-- 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 content/xbl/test/file_bug591198_inner.html create mode 100644 content/xbl/test/file_bug591198_xbl.xml create mode 100644 content/xbl/test/test_bug591198.html diff --git a/content/base/public/nsContentErrors.h b/content/base/public/nsContentErrors.h index 0351f46703..4a16574a9f 100644 --- a/content/base/public/nsContentErrors.h +++ b/content/base/public/nsContentErrors.h @@ -91,4 +91,8 @@ #define NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION \ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, 99) +/* Error codes for XBL */ +#define NS_ERROR_XBL_BLOCKED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 15) + #endif // nsContentErrors_h___ diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index fa7d4d0ad2..84fdd25e3e 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -76,6 +76,7 @@ #include "nsIDOM3Node.h" #include "nsContentPolicyUtils.h" #include "nsTArray.h" +#include "nsContentErrors.h" #include "nsIPresShell.h" #include "nsIDocumentObserver.h" @@ -1107,7 +1108,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, gAllowDataURIs, nsIContentPolicy::TYPE_XBL, aBoundDocument); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, NS_ERROR_XBL_BLOCKED); if (!IsSystemOrChromeURLPrincipal(aOriginPrincipal)) { // Also make sure that we're same-origin with the bound document @@ -1116,12 +1117,12 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, !SchemeIs(aBindingURI, "chrome")) { rv = aBoundDocument->NodePrincipal()->CheckMayLoad(aBindingURI, PR_TRUE); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, NS_ERROR_XBL_BLOCKED); } // Finally check if this document is allowed to use XBL at all. NS_ENSURE_TRUE(aBoundDocument->AllowXULXBL(), - NS_ERROR_NOT_AVAILABLE); + NS_ERROR_XBL_BLOCKED); } } diff --git a/content/xbl/test/Makefile.in b/content/xbl/test/Makefile.in index b770b67eb2..b791a2e7a6 100644 --- a/content/xbl/test/Makefile.in +++ b/content/xbl/test/Makefile.in @@ -72,6 +72,9 @@ _TEST_FILES = \ file_bug481558.xbl \ test_bug526178.xhtml \ test_bug542406.xhtml \ + test_bug591198.html \ + file_bug591198_xbl.xml \ + file_bug591198_inner.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/content/xbl/test/file_bug591198_inner.html b/content/xbl/test/file_bug591198_inner.html new file mode 100644 index 0000000000..12fc9f5834 --- /dev/null +++ b/content/xbl/test/file_bug591198_inner.html @@ -0,0 +1,38 @@ + + + + + + + +
long long text here
+
long long text here
+
PASS
+ + diff --git a/content/xbl/test/file_bug591198_xbl.xml b/content/xbl/test/file_bug591198_xbl.xml new file mode 100644 index 0000000000..f69959b47c --- /dev/null +++ b/content/xbl/test/file_bug591198_xbl.xml @@ -0,0 +1,5 @@ + + + PASS + diff --git a/content/xbl/test/test_bug591198.html b/content/xbl/test/test_bug591198.html new file mode 100644 index 0000000000..f107746045 --- /dev/null +++ b/content/xbl/test/test_bug591198.html @@ -0,0 +1,47 @@ + + + + + Test for Bug 591198 + + + + + +Mozilla Bug 591198 + +
+
+
+ + diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 06c2033aaf..d7fd0bb6e0 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2341,7 +2341,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle display->mBinding->mOriginPrincipal, PR_FALSE, getter_AddRefs(binding), &resolveStyle); - if (NS_FAILED(rv)) + if (NS_FAILED(rv) && rv != NS_ERROR_XBL_BLOCKED) return NS_OK; // Binding will load asynchronously. if (binding) { @@ -5095,7 +5095,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState PR_FALSE, getter_AddRefs(newPendingBinding->mBinding), &resolveStyle); - if (NS_FAILED(rv)) + if (NS_FAILED(rv) && rv != NS_ERROR_XBL_BLOCKED) return; if (newPendingBinding->mBinding) { -- 2.11.4.GIT