mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
Update web-platform-tests to 5582e4d2bfcfd1fa9f105406b143170ee2af7db1
This commit is contained in:
parent
9f892edd87
commit
78369e95cf
814 changed files with 57501 additions and 857 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue