Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 2173873003: Cancel image loads if decoding failed (attempt #2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UAF Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // Re-adds a ResourceClient but not ImageResourceObserver. 614 // Re-adds a ResourceClient but not ImageResourceObserver.
615 Persistent<MockResourceClient> client2 = new MockResourceClient(imageResourc e); 615 Persistent<MockResourceClient> client2 = new MockResourceClient(imageResourc e);
616 616
617 ASSERT_TRUE(imageResource->hasImage()); 617 ASSERT_TRUE(imageResource->hasImage());
618 EXPECT_FALSE(imageResource->getImage()->isNull()); 618 EXPECT_FALSE(imageResource->getImage()->isNull());
619 EXPECT_EQ(1, imageResource->getImage()->width()); 619 EXPECT_EQ(1, imageResource->getImage()->width());
620 EXPECT_EQ(1, imageResource->getImage()->height()); 620 EXPECT_EQ(1, imageResource->getImage()->height());
621 EXPECT_TRUE(client2->notifyFinishedCalled()); 621 EXPECT_TRUE(client2->notifyFinishedCalled());
622 } 622 }
623 623
624 TEST(ImageResourceTest, CancelOnDecodeError)
625 {
626 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
627 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html ");
628
629 ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetc hContext::create());
630 FetchRequest request(testURL, FetchInitiatorInfo());
631 ImageResource* cachedImage = ImageResource::fetch(request, fetcher);
632 Platform::current()->getURLLoaderMockFactory()->unregisterURL(testURL);
633
634 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(R esourceResponse(testURL, "image/jpeg", 18, nullAtom, String())), nullptr);
635 cachedImage->loader()->didReceiveData(nullptr, "notactuallyanimage", 18, 18, 18);
636 EXPECT_EQ(Resource::DecodeError, cachedImage->getStatus());
637 EXPECT_FALSE(cachedImage->isLoading());
638 }
639
624 } // namespace blink 640 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698