Import apng testcases from WPT.
https://bugs.webkit.org/show_bug.cgi?id=202783

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Import apng tests from WTP.

* resources/import-expectations.json:
* web-platform-tests/apng/META.yml: Added.
* web-platform-tests/apng/animated-png-timeout-expected.html: Added.
* web-platform-tests/apng/animated-png-timeout.html: Added.
* web-platform-tests/apng/supported-in-source-type-expected.txt: Added.
* web-platform-tests/apng/supported-in-source-type.html: Added.
* web-platform-tests/apng/w3c-import.log: Added.

LayoutTests:

Import apng tests from WTP

* TestExpectations: Mark the new imported test as failing. One already
has a fix and the other would pass once the support for reftest-wait
is implemented in the tooling.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 024dd76..60c6160 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-15  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        Import apng testcases from WPT.
+        https://bugs.webkit.org/show_bug.cgi?id=202783
+
+        Reviewed by Simon Fraser.
+
+        Import apng tests from WTP
+
+        * TestExpectations: Mark the new imported test as failing. One already
+        has a fix and the other would pass once the support for reftest-wait
+        is implemented in the tooling.
+
 2019-10-15  Peng Liu  <peng.liu6@apple.com>
 
         [Picture-in-Picture Web API] Implement HTMLVideoElement.requestPictureInPicture() / Document.exitPictureInPicture()
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 727348f..3e86673 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -1218,6 +1218,7 @@
 webkit.org/b/186045 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/available-images.html [ Pass ImageOnlyFailure ]
 webkit.org/b/186045 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/sizes-dynamic-001.html [ ImageOnlyFailure ]
 webkit.org/b/186045 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/sizes-dynamic-002.html [ ImageOnlyFailure ]
+webkit.org/b/186045 imported/w3c/web-platform-tests/apng/animated-png-timeout.html [ Skip ]
 
 # These W3C tests time out.
 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/autoplay-overrides-preload.html [ Skip ]
@@ -3881,3 +3882,5 @@
 webkit.org/b/200208 imported/w3c/web-platform-tests/css/css-images/gradients-with-transparent.html [ ImageOnlyFailure ]
 webkit.org/b/200209 imported/w3c/web-platform-tests/css/css-images/multiple-position-color-stop-radial.html [ ImageOnlyFailure ]
 webkit.org/b/202813 imported/w3c/web-platform-tests/css/css-images/multiple-position-color-stop-conic.html [ ImageOnlyFailure ]
+
+webkit.org/b/202785 imported/w3c/web-platform-tests/apng/supported-in-source-type.html [ Failure ]
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 4ebbc2d..af171e6 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,20 @@
+2019-10-15  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        Import apng testcases from WPT.
+        https://bugs.webkit.org/show_bug.cgi?id=202783
+
+        Reviewed by Simon Fraser.
+
+        Import apng tests from WTP.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/apng/META.yml: Added.
+        * web-platform-tests/apng/animated-png-timeout-expected.html: Added.
+        * web-platform-tests/apng/animated-png-timeout.html: Added.
+        * web-platform-tests/apng/supported-in-source-type-expected.txt: Added.
+        * web-platform-tests/apng/supported-in-source-type.html: Added.
+        * web-platform-tests/apng/w3c-import.log: Added.
+
 2019-10-15  Peng Liu  <peng.liu6@apple.com>
 
         [Picture-in-Picture Web API] Implement HTMLVideoElement.requestPictureInPicture() / Document.exitPictureInPicture()
diff --git a/LayoutTests/imported/w3c/resources/import-expectations.json b/LayoutTests/imported/w3c/resources/import-expectations.json
index cdf2b268..2f1af87 100644
--- a/LayoutTests/imported/w3c/resources/import-expectations.json
+++ b/LayoutTests/imported/w3c/resources/import-expectations.json
@@ -1,4 +1,5 @@
 {
+    "apng": "import", 
     "css/geometry": "import", 
     "custom-elements": "import", 
     "shadow-dom": "import", 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/META.yml b/LayoutTests/imported/w3c/web-platform-tests/apng/META.yml
new file mode 100644
index 0000000..a660c7e
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/META.yml
@@ -0,0 +1,5 @@
+spec: https://wiki.mozilla.org/APNG_Specification
+suggested_reviewers:
+  - stuartparmenter
+  - svgeesus
+  - leonscroggins
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout-expected.html b/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout-expected.html
new file mode 100644
index 0000000..c46bb90
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout-expected.html
@@ -0,0 +1 @@
+<img src=../images/green.png>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout.html b/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout.html
new file mode 100644
index 0000000..6975bd9
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout.html
@@ -0,0 +1,11 @@
+<html class="reftest-wait">
+<title>APNG: Second frame displays quickly, replacing red with green.</title>
+<link rel="match" href="animated-png-timeout-ref.html"/>
+<img src=../images/apng.png onload="loaded()"/>
+<script>
+  function loaded() {
+    setTimeout(function() {
+      document.documentElement.classList.remove("reftest-wait");
+    }, 1000);
+  }
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type-expected.txt
new file mode 100644
index 0000000..9873302
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type-expected.txt
@@ -0,0 +1,3 @@
+
+PASS Animated PNG MIME type (image/apng) is recognized by <source type> 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type.html b/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type.html
new file mode 100644
index 0000000..0a4d232
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<title>Animated PNG MIME type (image/apng) is recognized by &lt;source type></title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+function resolveUrl(relativeUrl) {
+  var a = document.createElement('a');
+  a.href = relativeUrl;
+  return a.href;
+}
+
+async_test(t => {
+  window.onload = t.step_func_done(() => {
+    let image = document.querySelector('img');
+    let apngSrc = document.querySelector('source');
+    assert_equals(image.currentSrc, resolveUrl(apngSrc.srcset));
+  });
+});
+</script>
+<picture>
+  <source srcset="/images/anim-gr.png" type="image/apng">
+  <img src="/images/anim-gr.gif" style="visibility: hidden">
+</picture>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/apng/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/apng/w3c-import.log
new file mode 100644
index 0000000..0824715
--- /dev/null
+++ b/LayoutTests/imported/w3c/web-platform-tests/apng/w3c-import.log
@@ -0,0 +1,20 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+	https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/apng/META.yml
+/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/apng/animated-png-timeout.html
+/LayoutTests/imported/w3c/web-platform-tests/apng/supported-in-source-type.html