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

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

Issue 2543203002: Fix memory corruption related to load blocking resource move (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 FetchRequest(resourceRequest, FetchInitiatorInfo()); 607 FetchRequest(resourceRequest, FetchInitiatorInfo());
608 Platform::current()->getURLLoaderMockFactory()->registerURL( 608 Platform::current()->getURLLoaderMockFactory()->registerURL(
609 url, WebURLResponse(), ""); 609 url, WebURLResponse(), "");
610 Resource* newResource = RawResource::fetch(fetchRequest, fetcher); 610 Resource* newResource = RawResource::fetch(fetchRequest, fetcher);
611 fetcher->stopFetching(); 611 fetcher->stopFetching();
612 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 612 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
613 613
614 EXPECT_NE(resource, newResource); 614 EXPECT_NE(resource, newResource);
615 } 615 }
616 616
617 TEST_F(ResourceFetcherTest, LinkPreloadImageMultipleFetchersAndMove) {
618 ResourceFetcher* fetcher = ResourceFetcher::create(
619 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource));
620 ResourceFetcher* fetcher2 = ResourceFetcher::create(
621 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource));
622
623 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.png");
624 URLTestHelpers::registerMockedURLLoad(url, testImageFilename, "image/png");
625
626 FetchRequest fetchRequestOriginal = FetchRequest(url, FetchInitiatorInfo());
627 fetchRequestOriginal.setLinkPreload(true);
628 Resource* resource = ImageResource::fetch(fetchRequestOriginal, fetcher);
629 ASSERT_TRUE(resource);
630 EXPECT_TRUE(resource->isLinkPreload());
631 fetcher->preloadStarted(resource);
632
633 // Image created by parser on the second fetcher
634 FetchRequest fetchRequest2 = FetchRequest(url, FetchInitiatorInfo());
635 Resource* newResource2 = ImageResource::fetch(fetchRequest2, fetcher2);
636 Persistent<MockResourceClient> client2 = new MockResourceClient(newResource2);
637 EXPECT_EQ(resource, newResource2);
638 EXPECT_FALSE(fetcher2->isFetching());
639 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
640 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
641 }
642
617 } // namespace blink 643 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698