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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 1558503003: Internals: throw an exception when page height or width is 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: third_party/WebKit/Source/core/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index fa9e10694eb5b6b4a97c70c45e3be9c870d0b68b..e790d9a3f1bd895213f6d1e52ce30f9d39b59689 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -1736,11 +1736,16 @@ String Internals::counterValue(Element* element)
return counterValueForElement(element);
}
-int Internals::pageNumber(Element* element, float pageWidth, float pageHeight)
+int Internals::pageNumber(Element* element, float pageWidth, float pageHeight, ExceptionState& exceptionState)
{
if (!element)
return 0;
+ if (pageWidth <= 0 || pageHeight <= 0) {
+ exceptionState.throwDOMException(V8TypeError, "Page width and height must be larger than 0.");
+ return 0;
+ }
+
return PrintContext::pageNumberForElement(element, FloatSize(pageWidth, pageHeight));
}
@@ -1765,11 +1770,16 @@ Vector<String> Internals::allIconURLs(Document* document) const
return iconURLs(document, Favicon | TouchIcon | TouchPrecomposedIcon);
}
-int Internals::numberOfPages(float pageWidth, float pageHeight)
+int Internals::numberOfPages(float pageWidth, float pageHeight, ExceptionState& exceptionState)
{
if (!frame())
return -1;
+ if (pageWidth <= 0 || pageHeight <= 0) {
+ exceptionState.throwDOMException(V8TypeError, "Page width and height must be larger than 0.");
+ return -1;
+ }
+
return PrintContext::numberOfPages(frame(), FloatSize(pageWidth, pageHeight));
}
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.h ('k') | third_party/WebKit/Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698