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

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

Issue 2763613003: Fix signed integer overflow in ImageData (Closed)
Patch Set: Adding test for too big ImageData 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 TEST_F(ImageDataTest, CreateImageDataTooBig) {
43 DummyExceptionStateForTesting exceptionState;
44 ImageData* tooBigImageData = ImageData::create(32767, 32767, exceptionState);
Justin Novosad 2017/03/21 17:07:23 You need to add a comment here to explain the rati
45 EXPECT_EQ(tooBigImageData, nullptr);
46 EXPECT_TRUE(exceptionState.hadException());
47 EXPECT_EQ(exceptionState.code(), V8RangeError);
48 }
49
50 } // namspace
51 } // 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