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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageData.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/ImageDataTest.cpp
diff --git a/third_party/WebKit/Source/core/html/ImageDataTest.cpp b/third_party/WebKit/Source/core/html/ImageDataTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a8b80af2f9e4e748787fb5ca8750a85d8b8c658
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/ImageDataTest.cpp
@@ -0,0 +1,51 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/ImageData.h"
+
+#include "core/dom/ExceptionCode.h"
+#include "platform/geometry/IntSize.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+namespace {
+
+class ImageDataTest : public ::testing::Test {
+ protected:
+ ImageDataTest(){};
+ void TearDown(){};
+};
+
+TEST_F(ImageDataTest, NegativeAndZeroIntSizeTest) {
+ ImageData* imageData;
+
+ imageData = ImageData::create(IntSize(0, 10));
+ EXPECT_EQ(imageData, nullptr);
+
+ imageData = ImageData::create(IntSize(10, 0));
+ EXPECT_EQ(imageData, nullptr);
+
+ imageData = ImageData::create(IntSize(0, 0));
+ EXPECT_EQ(imageData, nullptr);
+
+ imageData = ImageData::create(IntSize(-1, 10));
+ EXPECT_EQ(imageData, nullptr);
+
+ imageData = ImageData::create(IntSize(10, -1));
+ EXPECT_EQ(imageData, nullptr);
+
+ imageData = ImageData::create(IntSize(-1, -1));
+ EXPECT_EQ(imageData, nullptr);
+}
+
+TEST_F(ImageDataTest, CreateImageDataTooBig) {
+ DummyExceptionStateForTesting exceptionState;
+ 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
+ EXPECT_EQ(tooBigImageData, nullptr);
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(exceptionState.code(), V8RangeError);
+}
+
+} // namspace
+} // namespace blink
« 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