| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/ImageData.h" | 5 #include "core/html/ImageData.h" |
| 6 | 6 |
| 7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
| 8 #include "platform/geometry/IntSize.h" | 8 #include "platform/geometry/IntSize.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 imageData = ImageData::create(IntSize(-1, 10)); | 32 imageData = ImageData::create(IntSize(-1, 10)); |
| 33 EXPECT_EQ(imageData, nullptr); | 33 EXPECT_EQ(imageData, nullptr); |
| 34 | 34 |
| 35 imageData = ImageData::create(IntSize(10, -1)); | 35 imageData = ImageData::create(IntSize(10, -1)); |
| 36 EXPECT_EQ(imageData, nullptr); | 36 EXPECT_EQ(imageData, nullptr); |
| 37 | 37 |
| 38 imageData = ImageData::create(IntSize(-1, -1)); | 38 imageData = ImageData::create(IntSize(-1, -1)); |
| 39 EXPECT_EQ(imageData, nullptr); | 39 EXPECT_EQ(imageData, nullptr); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Under asan_clang_phone, the test crashes after the memory allocation |
| 43 // is not successful. It is probably related to the value of |
| 44 // allocator_may_return_null on trybots, which in this case causes ASAN |
| 45 // to terminate the process instead of returning null. |
| 46 // crbug.com/704948 |
| 47 #if defined(ADDRESS_SANITIZER) |
| 48 #define MAYBE_CreateImageDataTooBig DISABLED_CreateImageDataTooBig |
| 49 #else |
| 50 #define MAYBE_CreateImageDataTooBig CreateImageDataTooBig |
| 51 #endif |
| 52 |
| 42 // This test passes if it does not crash. If the required memory is not | 53 // This test passes if it does not crash. If the required memory is not |
| 43 // allocated to the ImageData, then an exception must raise. | 54 // allocated to the ImageData, then an exception must raise. |
| 44 TEST_F(ImageDataTest, CreateImageDataTooBig) { | 55 TEST_F(ImageDataTest, MAYBE_CreateImageDataTooBig) { |
| 45 DummyExceptionStateForTesting exceptionState; | 56 DummyExceptionStateForTesting exceptionState; |
| 46 ImageData* tooBigImageData = ImageData::create(32767, 32767, exceptionState); | 57 ImageData* tooBigImageData = ImageData::create(32767, 32767, exceptionState); |
| 47 if (!tooBigImageData) { | 58 if (!tooBigImageData) { |
| 48 EXPECT_TRUE(exceptionState.hadException()); | 59 EXPECT_TRUE(exceptionState.hadException()); |
| 49 EXPECT_EQ(exceptionState.code(), V8RangeError); | 60 EXPECT_EQ(exceptionState.code(), V8RangeError); |
| 50 } | 61 } |
| 51 } | 62 } |
| 52 | 63 |
| 53 } // namspace | 64 } // namspace |
| 54 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |