Bug 1297305 - Move the test of document-timeline to web platform tests, r?birtles
MozReview-Commit-ID: Ke2ntCuDb4K
deleted file mode 100644
--- a/dom/animation/test/document-timeline/file_document-timeline.html
+++ /dev/null
@@ -1,135 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>Web Animations API: DocumentTimeline tests</title>
-<script src="../testcommon.js"></script>
-<iframe src="data:text/html;charset=utf-8," width="10" height="10" id="iframe"></iframe>
-<iframe src="data:text/html;charset=utf-8,%3Chtml%20style%3D%22display%3Anone%22%3E%3C%2Fhtml%3E" width="10" height="10" id="hidden-iframe"></iframe>
-<script>
-'use strict';
-
-test(function() {
- assert_equals(document.timeline, document.timeline,
- 'document.timeline returns the same object every time');
- var iframe = document.getElementById('iframe');
- assert_not_equals(document.timeline, iframe.contentDocument.timeline,
- 'document.timeline returns a different object for each document');
- assert_not_equals(iframe.contentDocument.timeline, null,
- 'document.timeline on an iframe is not null');
-},
-'document.timeline identity tests',
-{
- help: 'http://dev.w3.org/fxtf/web-animations/#the-document-timeline',
- assert: [ 'Each document has a timeline called the document timeline' ],
- author: 'Brian Birtles'
-});
-
-async_test(function(t) {
- assert_true(document.timeline.currentTime > 0,
- 'document.timeline.currentTime is positive');
- // document.timeline.currentTime should be set even before document
- // load fires. We expect this code to be run before document load and hence
- // the above assertion is sufficient.
- // If the following assertion fails, this test needs to be redesigned.
- assert_true(document.readyState !== 'complete',
- 'Test is running prior to document load');
-
- // Test that the document timeline's current time is measured from
- // navigationStart.
- //
- // We can't just compare document.timeline.currentTime to
- // window.performance.now() because currentTime is only updated on a sample
- // so we use requestAnimationFrame instead.
- window.requestAnimationFrame(t.step_func(function(rafTime) {
- assert_equals(document.timeline.currentTime, rafTime,
- 'document.timeline.currentTime matches' +
- ' requestAnimationFrame time');
- t.done();
- }));
-},
-'document.timeline.currentTime value tests',
-{
- help: [
- 'http://dev.w3.org/fxtf/web-animations/#the-global-clock',
- 'http://dev.w3.org/fxtf/web-animations/#the-document-timeline'
- ],
- assert: [
- 'The global clock is a source of monotonically increasing time values',
- 'The time values of the document timeline are calculated as a fixed' +
- ' offset from the global clock',
- 'the zero time corresponds to the navigationStart moment',
- 'the time value of each document timeline must be equal to the time ' +
- 'passed to animation frame request callbacks for that browsing context'
- ],
- author: 'Brian Birtles'
-});
-
-async_test(function(t) {
- var valueAtStart = document.timeline.currentTime;
- var timeAtStart = window.performance.now();
- while (window.performance.now() - timeAtStart < 100) {
- // Wait 100ms
- }
- assert_equals(document.timeline.currentTime, valueAtStart,
- 'document.timeline.currentTime does not change within a script block');
- window.requestAnimationFrame(t.step_func(function() {
- assert_true(document.timeline.currentTime > valueAtStart,
- 'document.timeline.currentTime increases between script blocks');
- t.done();
- }));
-},
-'document.timeline.currentTime liveness tests',
-{
- help: 'http://dev.w3.org/fxtf/web-animations/#script-execution-and-live-updates-to-the-model',
- assert: [ 'The value returned by the currentTime attribute of a' +
- ' document timeline will not change within a script block' ],
- author: 'Brian Birtles'
-});
-
-test(function() {
- var hiddenIFrame = document.getElementById('hidden-iframe');
- assert_equals(typeof hiddenIFrame.contentDocument.timeline.currentTime,
- 'number',
- 'currentTime of an initially hidden subframe\'s timeline is a number');
- assert_true(hiddenIFrame.contentDocument.timeline.currentTime >= 0,
- 'currentTime of an initially hidden subframe\'s timeline is >= 0');
-}, 'document.timeline.currentTime hidden subframe test');
-
-async_test(function(t) {
- var hiddenIFrame = document.getElementById('hidden-iframe');
-
- // Don't run the test until after the iframe has completed loading or else the
- // contentDocument may change.
- var testToRunOnLoad = t.step_func(function() {
- // Remove display:none
- hiddenIFrame.style.display = 'block';
- window.getComputedStyle(hiddenIFrame).display;
-
- window.requestAnimationFrame(t.step_func(function() {
- assert_true(hiddenIFrame.contentDocument.timeline.currentTime > 0,
- 'document.timeline.currentTime is positive after removing'
- + ' display:none');
- var previousValue = hiddenIFrame.contentDocument.timeline.currentTime;
-
- // Re-introduce display:none
- hiddenIFrame.style.display = 'none';
- window.getComputedStyle(hiddenIFrame).display;
-
- window.requestAnimationFrame(t.step_func(function() {
- assert_true(
- hiddenIFrame.contentDocument.timeline.currentTime >= previousValue,
- 'document.timeline.currentTime does not go backwards after'
- + ' re-setting display:none');
- t.done();
- }));
- }));
- });
-
- if (hiddenIFrame.contentDocument.readyState === 'complete') {
- testToRunOnLoad();
- } else {
- hiddenIFrame.addEventListener("load", testToRunOnLoad);
- }
-}, 'document.timeline.currentTime hidden subframe dynamic test');
-
-done();
-</script>
deleted file mode 100644
--- a/dom/animation/test/document-timeline/test_document-timeline.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-'use strict';
-setup({explicit_done: true});
-SpecialPowers.pushPrefEnv(
- { "set": [["dom.animations-api.core.enabled", true]]},
- function() {
- window.open("file_document-timeline.html");
- });
-</script>
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -29,17 +29,16 @@ support-files =
css-transitions/file_animation-ready.html
css-transitions/file_animation-starttime.html
css-transitions/file_csstransition-transitionproperty.html
css-transitions/file_document-get-animations.html
css-transitions/file_effect-target.html
css-transitions/file_element-get-animations.html
css-transitions/file_keyframeeffect-getkeyframes.html
css-transitions/file_pseudoElement-get-animations.html
- document-timeline/file_document-timeline.html
mozilla/file_cubic_bezier_limits.html
mozilla/file_deferred_start.html
mozilla/file_disabled_properties.html
mozilla/file_document-timeline-origin-time-range.html
mozilla/file_hide_and_show.html
mozilla/file_partial_keyframes.html
mozilla/file_transform_limits.html
mozilla/file_underlying-discrete-value.html
@@ -75,17 +74,16 @@ skip-if = buildapp == 'mulet'
[css-transitions/test_animation-starttime.html]
[css-transitions/test_csstransition-transitionproperty.html]
[css-transitions/test_document-get-animations.html]
[css-transitions/test_effect-target.html]
[css-transitions/test_element-get-animations.html]
skip-if = buildapp == 'mulet'
[css-transitions/test_keyframeeffect-getkeyframes.html]
[css-transitions/test_pseudoElement-get-animations.html]
-[document-timeline/test_document-timeline.html]
[document-timeline/test_request_animation_frame.html]
skip-if = buildapp == 'mulet'
[mozilla/test_cubic_bezier_limits.html]
[mozilla/test_deferred_start.html]
skip-if = (toolkit == 'gonk' && debug)
[mozilla/test_disabled_properties.html]
[mozilla/test_document-timeline-origin-time-range.html]
[mozilla/test_hide_and_show.html]
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -30449,20 +30449,28 @@
"path": "web-animations/interfaces/AnimationTimeline/idlharness.html",
"url": "/web-animations/interfaces/AnimationTimeline/idlharness.html"
},
{
"path": "web-animations/interfaces/Document/getAnimations.html",
"url": "/web-animations/interfaces/Document/getAnimations.html"
},
{
+ "path": "web-animations/interfaces/Document/timeline.html",
+ "url": "/web-animations/interfaces/Document/timeline.html"
+ },
+ {
"path": "web-animations/interfaces/DocumentTimeline/constructor.html",
"url": "/web-animations/interfaces/DocumentTimeline/constructor.html"
},
{
+ "path": "web-animations/interfaces/DocumentTimeline/currentTime.html",
+ "url": "/web-animations/interfaces/DocumentTimeline/currentTime.html"
+ },
+ {
"path": "web-animations/interfaces/KeyframeEffect/constructor.html",
"url": "/web-animations/interfaces/KeyframeEffect/constructor.html"
},
{
"path": "web-animations/interfaces/KeyframeEffect/effect-easing.html",
"url": "/web-animations/interfaces/KeyframeEffect/effect-easing.html"
},
{
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/web-animations/interfaces/DocumentTimeline/currentTime.html.ini
@@ -0,0 +1,6 @@
+[currentTime.html]
+ type: testharness
+ [document.timeline.currentTime hidden subframe test]
+ expected: FAIL
+ bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1298573
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/interfaces/Document/timeline.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Web Animations API: document.timeline tests</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#the-documents-default-timeline">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<iframe src="data:text/html;charset=utf-8," width="10" height="10" id="iframe"></iframe>
+<script>
+'use strict';
+
+test(function() {
+ assert_equals(document.timeline, document.timeline,
+ 'document.timeline returns the same object every time');
+ var iframe = document.getElementById('iframe');
+ assert_not_equals(document.timeline, iframe.contentDocument.timeline,
+ 'document.timeline returns a different object for each document');
+ assert_not_equals(iframe.contentDocument.timeline, null,
+ 'document.timeline on an iframe is not null');
+},
+'document.timeline identity tests');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/interfaces/DocumentTimeline/currentTime.html
@@ -0,0 +1,102 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Web Animations API: DocumentTimeline.currentTime tests</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#document-timelines">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<iframe src="data:text/html;charset=utf-8,%3Chtml%20style%3D%22display%3Anone%22%3E%3C%2Fhtml%3E" width="10" height="10" id="hidden-iframe"></iframe>
+<script>
+'use strict';
+
+promise_test(function(t) {
+ assert_true(document.timeline.currentTime > 0,
+ 'document.timeline.currentTime is positive');
+ // document.timeline.currentTime should be set even before document
+ // load fires. We expect this code to be run before document load and hence
+ // the above assertion is sufficient.
+ // If the following assertion fails, this test needs to be redesigned.
+ assert_true(document.readyState !== 'complete',
+ 'Test is running prior to document load');
+
+ // Test that the document timeline's current time is measured from
+ // navigationStart.
+ //
+ // We can't just compare document.timeline.currentTime to
+ // window.performance.now() because currentTime is only updated on a sample
+ // so we use requestAnimationFrame instead.
+ return waitForAnimationFrames(1).then(function(rafTime) {
+ assert_equals(document.timeline.currentTime, rafTime,
+ 'document.timeline.currentTime matches' +
+ ' requestAnimationFrame time');
+ });
+},
+'document.timeline.currentTime value tests');
+
+promise_test(function(t) {
+ var valueAtStart = document.timeline.currentTime;
+ var timeAtStart = window.performance.now();
+ while (window.performance.now() - timeAtStart < 100) {
+ // Wait 100ms
+ }
+ assert_equals(document.timeline.currentTime, valueAtStart,
+ 'document.timeline.currentTime does not change within a script block');
+ return waitForAnimationFrames(1).then(function () {
+ assert_true(document.timeline.currentTime > valueAtStart,
+ 'document.timeline.currentTime increases between script blocks');
+ });
+},
+'document.timeline.currentTime liveness tests');
+
+test(function() {
+ var hiddenIFrame = document.getElementById('hidden-iframe');
+ assert_equals(typeof hiddenIFrame.contentDocument.timeline.currentTime,
+ 'number',
+ 'currentTime of an initially hidden subframe\'s timeline is a number');
+ assert_true(hiddenIFrame.contentDocument.timeline.currentTime >= 0,
+ 'currentTime of an initially hidden subframe\'s timeline is >= 0');
+}, 'document.timeline.currentTime hidden subframe test');
+
+promise_test(function(t) {
+ var hiddenIFrame = document.getElementById('hidden-iframe');
+
+ // Don't run the test until after the iframe has completed loading or else the
+ // contentDocument may change.
+ var testToRunOnLoad = function() {
+ // Remove display:none
+ hiddenIFrame.style.display = 'block';
+ window.getComputedStyle(hiddenIFrame).display;
+
+ return waitForAnimationFrames(1).then(function () {
+ assert_true(hiddenIFrame.contentDocument.timeline.currentTime > 0,
+ 'document.timeline.currentTime is positive after removing'
+ + ' display:none');
+ }).then(function () {
+ var previousValue = hiddenIFrame.contentDocument.timeline.currentTime;
+
+ // Re-introduce display:none
+ hiddenIFrame.style.display = 'none';
+ window.getComputedStyle(hiddenIFrame).display;
+
+ return waitForAnimationFrames(1).then(function () {
+ assert_true(
+ hiddenIFrame.contentDocument.timeline.currentTime >= previousValue,
+ 'document.timeline.currentTime does not go backwards after'
+ + ' re-setting display:none');
+ });
+ });
+ };
+
+ if (hiddenIFrame.contentDocument.readyState === 'complete') {
+ return testToRunOnLoad();
+ } else {
+ return new Promise(function (resolve) {
+ hiddenIFrame.addEventListener("load", function () {
+ testToRunOnLoad().then(resolve);
+ });
+ });
+ }
+}, 'document.timeline.currentTime hidden subframe dynamic test');
+
+</script>
--- a/testing/web-platform/tests/web-animations/testcommon.js
+++ b/testing/web-platform/tests/web-animations/testcommon.js
@@ -143,18 +143,18 @@ function stepStart(nsteps) {
return function stepStartClosure(x) {
var result = Math.floor(x * nsteps + 1.0) / nsteps;
return (result > 1.0) ? 1.0 : result;
}
}
function waitForAnimationFrames(frameCount) {
return new Promise(function(resolve, reject) {
- function handleFrame() {
+ function handleFrame(timestamp) {
if (--frameCount <= 0) {
- resolve();
+ resolve(timestamp);
} else {
window.requestAnimationFrame(handleFrame); // wait another frame
}
}
window.requestAnimationFrame(handleFrame);
});
}