Bug 1615832 - Fix diagnostics for error paths in sync loads.

This can happen with invalid @import rules in userContent / userChrome.css

Differential Revision: https://phabricator.services.mozilla.com/D63002

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-02-15 21:27:06 +00:00
Родитель e922294324
Коммит cae4218c68
7 изменённых файлов: 14 добавлений и 6 удалений

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

@ -5,5 +5,6 @@
</head>
<body>
<p>This paragraph should have a green background.</p>
<p>This paragraph should have a green background.</p>
</body>
</html>

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

@ -9,5 +9,6 @@ p {
</head>
<body>
<p class="reftest-usercss">This paragraph should have a green background.</p>
<p class="reftest-usercss-import">This paragraph should have a green background.</p>
</body>
</html>

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

@ -1344,7 +1344,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
// Create a StreamLoader instance to which we will feed
// the data from the sync load. Do this before creating the
// channel to make error recovery simpler.
nsCOMPtr<nsIStreamListener> streamLoader = new StreamLoader(aLoadData);
auto streamLoader = MakeRefPtr<StreamLoader>(aLoadData);
if (mDocument) {
net::PredictorLearn(aLoadData.mURI, mDocument->GetDocumentURI(),
@ -1395,6 +1395,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
}
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to create channel"));
streamLoader->ChannelOpenFailed();
SheetComplete(aLoadData, rv);
return rv;
}
@ -1416,6 +1417,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to open URI synchronously"));
streamLoader->ChannelOpenFailed();
SheetComplete(aLoadData, rv);
return rv;
}
@ -1627,7 +1629,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
rv = channel->AsyncOpen(streamLoader);
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to create stream loader"));
streamLoader->AsyncOpenFailed();
streamLoader->ChannelOpenFailed();
SheetComplete(aLoadData, rv);
return rv;
}

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

@ -21,7 +21,7 @@ StreamLoader::StreamLoader(SheetLoadData& aSheetLoadData)
: mSheetLoadData(&aSheetLoadData), mStatus(NS_OK) {}
StreamLoader::~StreamLoader() {
MOZ_DIAGNOSTIC_ASSERT(mOnStopRequestCalled || mAsyncOpenFailed);
MOZ_DIAGNOSTIC_ASSERT(mOnStopRequestCalled || mChannelOpenFailed);
}
NS_IMPL_ISUPPORTS(StreamLoader, nsIStreamListener)

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

@ -25,9 +25,9 @@ class StreamLoader : public nsIStreamListener {
explicit StreamLoader(SheetLoadData&);
void AsyncOpenFailed() {
void ChannelOpenFailed() {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
mAsyncOpenFailed = true;
mChannelOpenFailed = true;
#endif
}
@ -53,7 +53,7 @@ class StreamLoader : public nsIStreamListener {
nsAutoCStringN<3> mBOMBytes;
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
bool mAsyncOpenFailed = false;
bool mChannelOpenFailed = false;
bool mOnStopRequestCalled = false;
#endif
};

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

@ -1,3 +1,6 @@
@import "invalid.css";
@import "userContent-import.css";
.reftest-usercss {
background: lime !important;
}

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

@ -30,6 +30,7 @@ TEST_HARNESS_FILES.reftest += [
TEST_HARNESS_FILES.reftest.chrome += [
'chrome/binding.xml',
'chrome/userContent-import.css',
'chrome/userContent.css',
]