CSS3 calc: identify divide by zero cases at parse time
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 23:45:05 +0000 (23:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 23:45:05 +0000 (23:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80411

Patch by Alan Cutter <alancutter@chromium.org> on 2013-03-04
Reviewed by Tony Chang.

Added tests to check whether divide by 0 cases are caught.

* css3/calc/catch-divide-by-0-expected.txt: Added.
* css3/calc/catch-divide-by-0.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144689 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/css3/calc/catch-divide-by-0-expected.txt [new file with mode: 0644]
LayoutTests/css3/calc/catch-divide-by-0.html [new file with mode: 0644]

index 5080ad6..5d1b707 100644 (file)
@@ -1,3 +1,15 @@
+2013-03-04  Alan Cutter  <alancutter@chromium.org>
+
+        CSS3 calc: identify divide by zero cases at parse time
+        https://bugs.webkit.org/show_bug.cgi?id=80411
+
+        Reviewed by Tony Chang.
+
+        Added tests to check whether divide by 0 cases are caught.
+
+        * css3/calc/catch-divide-by-0-expected.txt: Added.
+        * css3/calc/catch-divide-by-0.html: Added.
+
 2013-03-04  Julien Chaffraix  <jchaffraix@webkit.org>
 
         [CSS Grid Layout] Add parsing for grid-{start|before}
diff --git a/LayoutTests/css3/calc/catch-divide-by-0-expected.txt b/LayoutTests/css3/calc/catch-divide-by-0-expected.txt
new file mode 100644 (file)
index 0000000..af87d1d
--- /dev/null
@@ -0,0 +1,11 @@
+This tests catching of divide by 0 in calc() at parse time
+
+100px / 0 => 
+100px / (0) => 
+100px / (2 - 2) => 
+100px / (2 - (-62 + 64)) => 
+100px * (1 / 0) => 
+100px * (1 / (0)) => 
+100px * (1 / (2 - 2)) => 
+100px * (1 / (2 - (-62 + 64))) => 
+
diff --git a/LayoutTests/css3/calc/catch-divide-by-0.html b/LayoutTests/css3/calc/catch-divide-by-0.html
new file mode 100644 (file)
index 0000000..7a1a21b
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<div id="dummy"></div>
+<div id="results">This tests catching of divide by 0 in calc() at parse time<br><br></div>
+<script>
+if (window.testRunner)
+    window.testRunner.dumpAsText();
+
+var tests = [
+    "100px / 0",
+    "100px / (0)",
+    "100px / (2 - 2)",
+    "100px / (2 - (-62 + 64))",
+    "100px * (1 / 0)",
+    "100px * (1 / (0))",
+    "100px * (1 / (2 - 2))",
+    "100px * (1 / (2 - (-62 + 64)))",
+];
+
+var results = document.getElementById("results");
+var dummy = document.getElementById("dummy");
+for (var i = 0; i < tests.length; ++i) {
+    var expression = tests[i];
+    dummy.style.width = 'calc(' + expression + ')';
+    results.innerHTML += expression + " => " + dummy.style.width + "<br>";
+}
+</script>
\ No newline at end of file