2008-09-29 Chris Marrin <cmarrin@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Sep 2008 21:09:18 +0000 (21:09 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Sep 2008 21:09:18 +0000 (21:09 +0000)
        Reviewed by Darin Adler

        Testcase for crash when parsing keyframes from an @imported
        CSS file
        https://bugs.webkit.org/show_bug.cgi?id=20855

         * animations/import-crash-expected.txt: Added.
         * animations/import-crash.html: Added.
         * animations/import-expected.txt: Added.
         * animations/import.html: Added.
         * animations/resources/keyframes.css: Added.

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

LayoutTests/ChangeLog
LayoutTests/animations/import-crash-expected.txt [new file with mode: 0644]
LayoutTests/animations/import-crash.html [new file with mode: 0644]
LayoutTests/animations/import-expected.txt [new file with mode: 0644]
LayoutTests/animations/import.html [new file with mode: 0644]
LayoutTests/animations/resources/keyframes.css [new file with mode: 0644]

index bdd26b9..e76369c 100644 (file)
@@ -1,3 +1,17 @@
+2008-09-29  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Darin Adler
+
+        Testcase for crash when parsing keyframes from an @imported
+        CSS file
+        https://bugs.webkit.org/show_bug.cgi?id=20855
+        
+         * animations/import-crash-expected.txt: Added.
+         * animations/import-crash.html: Added.
+         * animations/import-expected.txt: Added.
+         * animations/import.html: Added.
+         * animations/resources/keyframes.css: Added.
+
 2008-09-26  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/animations/import-crash-expected.txt b/LayoutTests/animations/import-crash-expected.txt
new file mode 100644 (file)
index 0000000..62a7bd4
--- /dev/null
@@ -0,0 +1 @@
+This test simply loads a sheet using @import that contains keyframes, to see if https://bugs.webkit.org/show_bug.cgi?id=20855 is fixed.
diff --git a/LayoutTests/animations/import-crash.html b/LayoutTests/animations/import-crash.html
new file mode 100644 (file)
index 0000000..b4d1f8f
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Test that @import rule importing keyframes does not crash</title>
+  <style type="text/css"> @import "resources/keyframes.css"; </style>
+  <style type="text/css" media="screen">
+    #box {
+        position: absolute;
+        left: 0;
+        top: 100px;
+        height: 100px;
+        width: 100px;
+        background-color: blue;
+        -webkit-animation-duration: 1s;
+        -webkit-animation-timing-function: linear;
+        -webkit-animation-name: "anim";
+    }
+    </style>
+    <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+  </script>
+</head>
+<body>
+This test simply loads a sheet using @import that contains keyframes, to see if https://bugs.webkit.org/show_bug.cgi?id=20855
+is fixed.
+</body>
+</html>
diff --git a/LayoutTests/animations/import-expected.txt b/LayoutTests/animations/import-expected.txt
new file mode 100644 (file)
index 0000000..4b36e82
--- /dev/null
@@ -0,0 +1,2 @@
+This test performs an animation of the left property. It should stop for 100ms at 100px and 200px We test for those values 50ms after it has stopped at each position. The keyframes are imported so this tests whether they come in correctly.
+PASS
diff --git a/LayoutTests/animations/import.html b/LayoutTests/animations/import.html
new file mode 100644 (file)
index 0000000..3286f20
--- /dev/null
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Test of @import rule for importing keyframes</title>
+  <style type="text/css"> @import "resources/keyframes.css"; </style>
+  <style type="text/css" media="screen">
+    #box {
+        position: absolute;
+        left: 0;
+        top: 100px;
+        height: 100px;
+        width: 100px;
+        background-color: blue;
+        -webkit-animation-duration: 1s;
+        -webkit-animation-timing-function: linear;
+        -webkit-animation-name: "anim";
+    }
+    </style>
+    <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    result = "PASS";
+    const defaultTolerance = 0.2;
+    
+    function isEqual(actual, desired, tolerance)
+    {
+        if (tolerance == undefined || tolerance == 0)
+            tolerance = defaultTolerance;
+        var diff = Math.abs(actual - desired);
+        return diff < tolerance;
+    }
+    
+    function snapshot(which)
+    {
+        if (result != "PASS")
+            return;
+            
+        var left = parseInt(window.getComputedStyle(document.getElementById('box')).left);
+        var expected = which ? 200 : 100;
+        if (!isEqual(left, expected))
+            result = "FAIL(was:"+left+", expected:"+expected+")";
+    }
+
+    function start()
+    {
+        setTimeout("snapshot(0)", 300);
+        setTimeout("snapshot(1)", 700);
+        
+        window.setTimeout(function() {
+            document.getElementById('result').innerHTML = result;
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }, 800);
+    }
+    
+    document.addEventListener('webkitAnimationStart', start, false);
+    
+  </script>
+</head>
+<body>
+This test performs an animation of the left property. It should stop for 100ms at 100px and 200px
+We test for those values 50ms after it has stopped at each position. The keyframes are imported
+so this tests whether they come in correctly.
+<div id="box">
+</div>
+<div id="result">
+</div>
+</body>
+</html>
diff --git a/LayoutTests/animations/resources/keyframes.css b/LayoutTests/animations/resources/keyframes.css
new file mode 100644 (file)
index 0000000..49d7f67
--- /dev/null
@@ -0,0 +1,8 @@
+@-webkit-keyframes "anim" {
+    from { left: 50px; }
+    20%  { left: 100px; }
+    40%  { left: 100px; }
+    60%  { left: 200px; }
+    80%  { left: 200px; }
+    to   { left: 300px; }
+}