Source/core/frame/ImageBitmapTest.cpp
// Verifies that ImageBitmaps constructed from HTMLImageElements hold a reference to the original Image if the HTMLImageElement src is changed.
Verifies that ImageBitmaps constructed from HTMLImageElements hold a reference to the original Image if the HTMLImageElement src is changed.
Verifies that ImageBitmaps constructed from HTMLImageElements hold a reference to the original Image if the HTMLImageElement src is changed .
TEST_F(ImageBitmapTest, ImageBitmapSourceChanged)
{
    RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(*Document::create().get());
    ResourcePtr<ImageResource> originalImageResource = new ImageResource(BitmapImage::create(NativeImageSkia::create(m_bitmap)).get());
    image->setImageResource(originalImageResource.get());
    RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height()));
    ASSERT_EQ(imageBitmap->bitmapImage().get(), originalImageResource->image());
    ResourcePtr<ImageResource> newImageResource = new ImageResource(BitmapImage::create(NativeImageSkia::create(m_bitmap2)).get());
    image->setImageResource(newImageResource.get());
    ASSERT_NE(imageBitmap->bitmapImage().get(), originalImageResource->image());
    ASSERT_EQ(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap().pixelRef()->pixels(),
        originalImageResource->image()->nativeImageForCurrentFrame()->bitmap().pixelRef()->pixels());
    ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image());
    ASSERT_NE(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap().pixelRef()->pixels(),
        newImageResource->image()->nativeImageForCurrentFrame()->bitmap().pixelRef()->pixels());
}
TEST_F ( ImageBitmapTest , ImageBitmapSourceChanged ) { RefPtrWillBeRawPtr < HTMLImageElement > image = HTMLImageElement :: create ( * Document :: create ( ) . get ( ) ) ; ResourcePtr < ImageResource > originalImageResource = new ImageResource ( BitmapImage :: create ( NativeImageSkia :: create ( m_bitmap ) ) . get ( ) ) ; image -> setImageResource ( originalImageResource . get ( ) ) ; RefPtrWillBeRawPtr < ImageBitmap > imageBitmap = ImageBitmap :: create ( image . get ( ) , IntRect ( 0 , 0 , m_bitmap . width ( ) , m_bitmap . height ( ) ) ) ; ASSERT_EQ ( imageBitmap -> bitmapImage ( ) . get ( ) , originalImageResource -> image ( ) ) ; ResourcePtr < ImageResource > newImageResource = new ImageResource ( BitmapImage :: create ( NativeImageSkia :: create ( m_bitmap2 ) ) . get ( ) ) ; image -> setImageResource ( newImageResource . get ( ) ) ; ASSERT_NE ( imageBitmap -> bitmapImage ( ) . get ( ) , originalImageResource -> image ( ) ) ; ASSERT_EQ ( imageBitmap -> bitmapImage ( ) -> nativeImageForCurrentFrame ( ) -> bitmap ( ) . pixelRef ( ) -> pixels ( ) , originalImageResource -> image ( ) -> nativeImageForCurrentFrame ( ) -> bitmap ( ) . pixelRef ( ) -> pixels ( ) ) ; ASSERT_NE ( imageBitmap -> bitmapImage ( ) . get ( ) , newImageResource -> image ( ) ) ; ASSERT_NE ( imageBitmap -> bitmapImage ( ) -> nativeImageForCurrentFrame ( ) -> bitmap ( ) . pixelRef ( ) -> pixels ( ) , newImageResource -> image ( ) -> nativeImageForCurrentFrame ( ) -> bitmap ( ) . pixelRef ( ) -> pixels ( ) ) ; }
Verifies that ImageBitmaps constructed from HTMLImageElements hold a reference to the original Image if the HTMLImageElement src is changed.
Verifies that ImageBitmaps constructed from HTMLImageElements hold a reference to the original Image if the HTMLImageElement src is changed .
// The ImageBitmap should contain the same data as the original cached image but should no longer hold a reference.