OLD | NEW |
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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 FetchRequest(resourceRequest, FetchInitiatorInfo()); | 608 FetchRequest(resourceRequest, FetchInitiatorInfo()); |
609 Platform::current()->getURLLoaderMockFactory()->registerURL( | 609 Platform::current()->getURLLoaderMockFactory()->registerURL( |
610 url, WebURLResponse(), ""); | 610 url, WebURLResponse(), ""); |
611 Resource* newResource = RawResource::fetch(fetchRequest, fetcher); | 611 Resource* newResource = RawResource::fetch(fetchRequest, fetcher); |
612 fetcher->stopFetching(); | 612 fetcher->stopFetching(); |
613 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 613 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
614 | 614 |
615 EXPECT_NE(resource, newResource); | 615 EXPECT_NE(resource, newResource); |
616 } | 616 } |
617 | 617 |
| 618 TEST_F(ResourceFetcherTest, LinkPreloadImageMultipleFetchersAndMove) { |
| 619 ResourceFetcher* fetcher = ResourceFetcher::create( |
| 620 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource)); |
| 621 ResourceFetcher* fetcher2 = ResourceFetcher::create( |
| 622 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource)); |
| 623 |
| 624 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.png"); |
| 625 URLTestHelpers::registerMockedURLLoad(url, testImageFilename, "image/png"); |
| 626 |
| 627 FetchRequest fetchRequestOriginal = FetchRequest(url, FetchInitiatorInfo()); |
| 628 fetchRequestOriginal.setLinkPreload(true); |
| 629 Resource* resource = ImageResource::fetch(fetchRequestOriginal, fetcher); |
| 630 ASSERT_TRUE(resource); |
| 631 EXPECT_TRUE(resource->isLinkPreload()); |
| 632 fetcher->preloadStarted(resource); |
| 633 |
| 634 // Image created by parser on the second fetcher |
| 635 FetchRequest fetchRequest2 = FetchRequest(url, FetchInitiatorInfo()); |
| 636 Resource* newResource2 = ImageResource::fetch(fetchRequest2, fetcher2); |
| 637 Persistent<MockResourceClient> client2 = new MockResourceClient(newResource2); |
| 638 EXPECT_EQ(resource, newResource2); |
| 639 EXPECT_FALSE(fetcher2->isFetching()); |
| 640 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); |
| 641 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 642 } |
| 643 |
618 } // namespace blink | 644 } // namespace blink |
OLD | NEW |