From b0e55c813b08d89480b4b66e9c1ea94eb54d66c2 Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Tue, 1 Jul 2014 10:50:47 -0700 Subject: [PATCH] Bug 1027461 - Handle an error condition in imports more gracefully in debug builds. --- content/base/crashtests/1027461-1.html | 9 +++++++++ content/base/crashtests/1027461-inner.xul | 2 ++ content/base/crashtests/crashtests.list | 1 + content/base/src/ImportManager.cpp | 17 +++++++++++++---- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 content/base/crashtests/1027461-1.html create mode 100644 content/base/crashtests/1027461-inner.xul diff --git a/content/base/crashtests/1027461-1.html b/content/base/crashtests/1027461-1.html new file mode 100644 index 000000000000..3117a5e3cc62 --- /dev/null +++ b/content/base/crashtests/1027461-1.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/content/base/crashtests/1027461-inner.xul b/content/base/crashtests/1027461-inner.xul new file mode 100644 index 000000000000..84ee2d222a67 --- /dev/null +++ b/content/base/crashtests/1027461-inner.xul @@ -0,0 +1,2 @@ + + diff --git a/content/base/crashtests/crashtests.list b/content/base/crashtests/crashtests.list index 2bc8258cc533..b801d6ee1e9b 100644 --- a/content/base/crashtests/crashtests.list +++ b/content/base/crashtests/crashtests.list @@ -150,3 +150,4 @@ load 930250.html load 942979.html load 978646.html load 1026714.html +pref(dom.webcomponents.enabled,true) load 1027461-1.html diff --git a/content/base/src/ImportManager.cpp b/content/base/src/ImportManager.cpp index 1150f03fd0c3..45b609a75e0e 100644 --- a/content/base/src/ImportManager.cpp +++ b/content/base/src/ImportManager.cpp @@ -273,6 +273,15 @@ ImportLoader::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatus) { + // OnStartRequest throws a special error code to let us know that we + // shouldn't do anything else. + if (aStatus == NS_ERROR_DOM_ABORT_ERR) { + // We failed in OnStartRequest, nothing more to do (we've already + // dispatched an error event) just return here. + MOZ_ASSERT(!mChannel); + return NS_OK; + } + MOZ_ASSERT(aRequest == mChannel, "Wrong channel something went horribly wrong"); @@ -303,7 +312,7 @@ ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) mChannel->GetContentType(type); if (!type.EqualsLiteral("text/html")) { NS_WARNING("ImportLoader wrong content type"); - return NS_ERROR_FAILURE; + return NS_ERROR_DOM_ABORT_ERR; } // The scope object is same for all the imports in an import tree, @@ -316,7 +325,7 @@ ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) emptyStr, emptyStr, nullptr, mURI, baseURI, principal, false, global, DocumentFlavorHTML); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR); // The imported document must know which master document it belongs to. mDocument = do_QueryInterface(importDoc); @@ -330,12 +339,12 @@ ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) rv = mDocument->StartDocumentLoad("import", mChannel, loadGroup, nullptr, getter_AddRefs(listener), true); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR); // Let's start parser. mParserStreamListener = listener; rv = listener->OnStartRequest(aRequest, aContext); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_ABORT_ERR); ae.Pass(); return NS_OK;