Bug 1392739 - Add test for faulty nsStandardURL deserialization. r=mayhemer

This commit is contained in:
Alex Gaynor 2018-05-23 22:25:08 +02:00
Родитель 300188571e
Коммит d71b5b9238
1 изменённых файлов: 15 добавлений и 0 удалений

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

@ -4,10 +4,12 @@
#include "nsCOMPtr.h"
#include "nsNetCID.h"
#include "nsIURL.h"
#include "nsIStandardURL.h"
#include "nsString.h"
#include "nsPrintfCString.h"
#include "nsComponentManagerUtils.h"
#include "nsIURIMutator.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/Unused.h"
// In nsStandardURL.cpp
@ -274,3 +276,16 @@ TEST(TestStandardURL, Mutator)
ASSERT_EQ(url->GetSpec(out), NS_OK);
ASSERT_TRUE(out == NS_LITERAL_CSTRING("https://mozilla.org/path?query#ref"));
}
TEST(TestStandardURL, Deserialize_Bug1392739)
{
mozilla::ipc::StandardURLParams standard_params;
standard_params.urlType() = nsIStandardURL::URLTYPE_STANDARD;
standard_params.spec() = NS_LITERAL_CSTRING("");
standard_params.host() = mozilla::ipc::StandardURLSegment(4294967295, 1);
mozilla::ipc::URIParams params(standard_params);
nsCOMPtr<nsIURIMutator> mutator = do_CreateInstance(NS_STANDARDURLMUTATOR_CID);
ASSERT_EQ(mutator->Deserialize(params), NS_ERROR_FAILURE);
}