Update web-platform-tests to 5582e4d2bfcfd1fa9f105406b143170ee2af7db1

This commit is contained in:
James Graham 2016-03-31 17:56:59 +01:00 committed by Ms2ger
parent 9f892edd87
commit 78369e95cf
814 changed files with 57501 additions and 857 deletions

View file

@ -42,14 +42,53 @@ function createDiv(test, doc) {
var div = doc.createElement('div');
doc.body.appendChild(div);
test.add_cleanup(function() {
removeElement(div);
div.remove();
});
return div;
}
// Removes element
function removeElement(element) {
element.parentNode.removeChild(element);
// Creates a style element with the specified rules, appends it to the document
// head and removes the created element during test cleanup.
// |rules| is an object. For example:
// { '@keyframes anim': '' ,
// '.className': 'animation: anim 100s;' };
// or
// { '.className1::before': 'content: ""; width: 0px; transition: all 10s;',
// '.className2::before': 'width: 100px;' };
// The object property name could be a keyframes name, or a selector.
// The object property value is declarations which are property:value pairs
// split by a space.
function createStyle(test, rules, doc) {
if (!doc) {
doc = document;
}
var extraStyle = doc.createElement('style');
doc.head.appendChild(extraStyle);
if (rules) {
var sheet = extraStyle.sheet;
for (var selector in rules) {
sheet.insertRule(selector + '{' + rules[selector] + '}',
sheet.cssRules.length);
}
}
test.add_cleanup(function() {
extraStyle.remove();
});
}
// Create a pseudo element
function createPseudo(test, type) {
createStyle(test, { '@keyframes anim': '',
['.pseudo::' + type]: 'animation: anim 10s;' });
var div = createDiv(test);
div.classList.add('pseudo');
var anims = document.getAnimations();
assert_true(anims.length >= 1);
var anim = anims[anims.length - 1];
assert_equals(anim.effect.target.parentElement, div);
assert_equals(anim.effect.target.type, '::' + type);
anim.cancel();
return anim.effect.target;
}
// Returns the type name of given object
@ -113,3 +152,15 @@ function stepStart(nsteps) {
}
}
function waitForAnimationFrames(frameCount) {
return new Promise(function(resolve, reject) {
function handleFrame() {
if (--frameCount <= 0) {
resolve();
} else {
window.requestAnimationFrame(handleFrame); // wait another frame
}
}
window.requestAnimationFrame(handleFrame);
});
}