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

Side by Side Diff: third_party/WebKit/Source/core/html/ImageDataTest.cpp

Issue 2763613003: Fix signed integer overflow in ImageData (Closed)
Patch Set: Addressing comments Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageData.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/html/ImageData.h"
6
7 #include "core/dom/ExceptionCode.h"
8 #include "platform/geometry/IntSize.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace blink {
12 namespace {
13
14 class ImageDataTest : public ::testing::Test {
15 protected:
16 ImageDataTest(){};
17 void TearDown(){};
18 };
19
20 TEST_F(ImageDataTest, NegativeAndZeroIntSizeTest) {
21 ImageData* imageData;
22
23 imageData = ImageData::create(IntSize(0, 10));
24 EXPECT_EQ(imageData, nullptr);
25
26 imageData = ImageData::create(IntSize(10, 0));
27 EXPECT_EQ(imageData, nullptr);
28
29 imageData = ImageData::create(IntSize(0, 0));
30 EXPECT_EQ(imageData, nullptr);
31
32 imageData = ImageData::create(IntSize(-1, 10));
33 EXPECT_EQ(imageData, nullptr);
34
35 imageData = ImageData::create(IntSize(10, -1));
36 EXPECT_EQ(imageData, nullptr);
37
38 imageData = ImageData::create(IntSize(-1, -1));
39 EXPECT_EQ(imageData, nullptr);
40 }
41
42 // This test passes if it does not crash. If the required memory is not
43 // allocated to the ImageData, then an exception must raise.
44 TEST_F(ImageDataTest, CreateImageDataTooBig) {
45 DummyExceptionStateForTesting exceptionState;
46 ImageData* tooBigImageData = ImageData::create(32767, 32767, exceptionState);
47 if (!tooBigImageData) {
48 EXPECT_TRUE(exceptionState.hadException());
49 EXPECT_EQ(exceptionState.code(), V8RangeError);
50 }
51 }
52
53 } // namspace
54 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698