@@ -770,6 +770,36 @@ TEST_F(BlobRegistryImplTest, Register_ValidBytesAsReply) {
770770 EXPECT_EQ (0u , BlobsUnderConstruction ());
771771}
772772
773+ TEST_F (BlobRegistryImplTest, Register_InvalidBytesAsReply) {
774+ const std::string kId = " id" ;
775+ const std::string kData = " hello" ;
776+
777+ std::vector<blink::mojom::DataElementPtr> elements;
778+ elements.push_back (
779+ blink::mojom::DataElement::NewBytes (blink::mojom::DataElementBytes::New (
780+ kData .size (), base::nullopt , CreateBytesProvider (" " ))));
781+
782+ mojo::PendingRemote<blink::mojom::Blob> blob;
783+ EXPECT_TRUE (registry_->Register (blob.InitWithNewPipeAndPassReceiver (), kId ,
784+ " " , " " , std::move (elements)));
785+
786+ std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID (kId );
787+ WaitForBlobCompletion (handle.get ());
788+
789+ EXPECT_TRUE (handle->IsBroken ());
790+ ASSERT_EQ (BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS,
791+ handle->GetBlobStatus ());
792+
793+ EXPECT_EQ (1u , reply_request_count_);
794+ EXPECT_EQ (0u , stream_request_count_);
795+ EXPECT_EQ (0u , file_request_count_);
796+ EXPECT_EQ (0u , BlobsUnderConstruction ());
797+
798+ // Expect 2 bad messages, one for the bad reply by the bytes provider, and one
799+ // for the original register call.
800+ EXPECT_EQ (2u , bad_messages_.size ());
801+ }
802+
773803TEST_F (BlobRegistryImplTest, Register_ValidBytesAsStream) {
774804 const std::string kId = " id" ;
775805 const std::string kData =
0 commit comments