Commit 55d5bb6b authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Change t.step() to t.step_func() from animations/prefixed

This is a follow-up CL of [1]. It changes t.step() to t.step_func()
from animations/prefixed and address review comments from [1].

[1] https://crrev.com/c/1525789

Bug: 936364
Change-Id: Ica1d58cd903ec8429f0ceac93a3ff3f1e514082b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1530358
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642404}
parent 69b653a3
...@@ -41,19 +41,17 @@ document.addEventListener('webkitAnimationEnd', () => { ...@@ -41,19 +41,17 @@ document.addEventListener('webkitAnimationEnd', () => {
}); });
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
t.step(() => { // Animation begins once we append the DOM node to the document.
// Animation begins once we append the DOM node to the document. var boxNode = document.createElement('div');
var boxNode = document.createElement('div'); boxNode.id = 'box';
boxNode.id = 'box'; boxNode.className = 'animate';
boxNode.className = 'animate'; document.body.appendChild(boxNode);
document.body.appendChild(boxNode);
document.addEventListener('webkitAnimationIteration', () => { document.addEventListener('webkitAnimationIteration', t.step_func_done(() => {
assert_true (startEventReceived && endEventReceived); assert_true(startEventReceived);
t.done(); assert_true(endEventReceived);
}); }));
}); }));
});
}, "Tests that prefixed animation events are correctly fired"); }, "Tests that prefixed animation events are correctly fired");
</script> </script>
...@@ -55,18 +55,17 @@ document.addEventListener('animationend', () => { ...@@ -55,18 +55,17 @@ document.addEventListener('animationend', () => {
}); });
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
t.step(() => { // Animation begins once we append the DOM node to the document.
// Animation begins once we append the DOM node to the document. var boxNode = document.createElement('div');
var boxNode = document.createElement('div'); boxNode.id = 'box';
boxNode.id = 'box'; boxNode.className = 'animate';
boxNode.className = 'animate'; document.body.appendChild(boxNode);
document.body.appendChild(boxNode); document.addEventListener('animationiteration', t.step_func_done(() => {
document.addEventListener('animationiteration', () => { assert_true(startEventReceived);
assert_true(startEventReceived && endEventReceived && prefixedEventReceived == 0); assert_true(endEventReceived);
t.done(); assert_equals(prefixedEventReceived, 0);
}); }));
}); }));
});
}, "Tests that unprefixed animation events are correctly fired when listeners are on both versions"); }, "Tests that unprefixed animation events are correctly fired when listeners are on both versions");
</script> </script>
...@@ -42,15 +42,13 @@ function recordAnimationEnd() { ...@@ -42,15 +42,13 @@ function recordAnimationEnd() {
} }
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
const box = document.getElementById('box'); const box = document.getElementById('box');
box.addEventListener("animationiteration", () => { box.addEventListener("animationiteration", t.step_func_done(() => {
t.step(() => { assert_true(startEventReceived);
assert_true(startEventReceived && endEventReceived); assert_true(endEventReceived);
t.done(); }));
}); }));
});
});
}, "Prefixed animation events should be fired with html event listeners"); }, "Prefixed animation events should be fired with html event listeners");
</script> </script>
<div id="box" onwebkitanimationstart="recordAnimationStart();" <div id="box" onwebkitanimationstart="recordAnimationStart();"
......
...@@ -6,33 +6,22 @@ ...@@ -6,33 +6,22 @@
var webkitAnimationStartReceived = false; var webkitAnimationStartReceived = false;
var webkitAnimationIterationReceived = false; var webkitAnimationIterationReceived = false;
document.addEventListener('animationstart', () => {
assert_unreached("animationstart event listener should not have been called");
});
document.addEventListener('webkitAnimationStart', () => { document.addEventListener('webkitAnimationStart', () => {
webkitAnimationStartReceived = true; webkitAnimationStartReceived = true;
}); });
document.addEventListener('animationiteration', () => {
assert_unreached("animationiteration event listener should not have been called");
});
document.addEventListener('webkitAnimationIteration', () => { document.addEventListener('webkitAnimationIteration', () => {
webkitAnimationIterationReceived = true; webkitAnimationIterationReceived = true;
}); });
document.addEventListener('animationend', () => {
assert_unreached("animationend event listener should not have been called");
});
async_test(t => { async_test(t => {
document.addEventListener('webkitAnimationEnd', () => { document.addEventListener('animationstart', t.unreached_func('animationstart event listener should not have been called'));
t.step(() => { document.addEventListener('animationiteration', t.unreached_func('animationiteration event listener should not have been called'));
assert_true(webkitAnimationIterationReceived && webkitAnimationIterationReceived); document.addEventListener('animationend', t.unreached_func('animationend event listener should not have been called'));
t.done(); document.addEventListener('webkitAnimationEnd', t.step_func_done(() => {
}); assert_true(webkitAnimationStartReceived);
}); assert_true(webkitAnimationIterationReceived);
}));
var custom = document.createEvent('CustomEvent'); var custom = document.createEvent('CustomEvent');
custom.initCustomEvent('webkitAnimationStart', true, true, null); custom.initCustomEvent('webkitAnimationStart', true, true, null);
......
...@@ -41,18 +41,16 @@ document.addEventListener('animationend', () => { ...@@ -41,18 +41,16 @@ document.addEventListener('animationend', () => {
}); });
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
t.step(() => { // Animation begins once we append the DOM node to the document.
// Animation begins once we append the DOM node to the document. var boxNode = document.createElement('div');
var boxNode = document.createElement('div'); boxNode.id = 'box';
boxNode.id = 'box'; boxNode.className = 'animate';
boxNode.className = 'animate'; document.body.appendChild(boxNode);
document.body.appendChild(boxNode); document.addEventListener('animationiteration', t.step_func_done(() => {
document.addEventListener('animationiteration', () => { assert_true(startEventReceived);
assert_true(startEventReceived && endEventReceived); assert_true(endEventReceived);
t.done(); }));
}); }));
});
});
}, "Tests that unprefixed animation events are correctly fired"); }, "Tests that unprefixed animation events are correctly fired");
</script> </script>
...@@ -41,15 +41,13 @@ function recordAnimationEnd() { ...@@ -41,15 +41,13 @@ function recordAnimationEnd() {
} }
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
const box = document.getElementById('box'); const box = document.getElementById('box');
box.addEventListener("animationiteration", () => { box.addEventListener("animationiteration", t.step_func_done(() => {
t.step(() => { assert_true(startEventReceived);
assert_true(startEventReceived && endEventReceived); assert_true(endEventReceived);
t.done(); }));
}); }));
});
});
}, "Tests that unprefixed animation events are correctly fired when using html event listeners"); }, "Tests that unprefixed animation events are correctly fired when using html event listeners");
</script> </script>
<div id="box" onanimationstart="recordAnimationStart();" onanimationend="recordAnimationEnd();" class="animate"></div> <div id="box" onanimationstart="recordAnimationStart();" onanimationend="recordAnimationEnd();" class="animate"></div>
...@@ -46,15 +46,14 @@ function recordAnimationEnd() { ...@@ -46,15 +46,14 @@ function recordAnimationEnd() {
} }
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func(() => {
const box = document.getElementById('box'); const box = document.getElementById('box');
box.addEventListener("animationiteration", () => { box.addEventListener("animationiteration", t.step_func_done(() => {
t.step(() => { assert_true(startEventReceived);
assert_true(startEventReceived && endEventReceived && prefixedEventReceived == 0); assert_true(endEventReceived);
t.done(); assert_equals(prefixedEventReceived, 0);
}); }));
}); }));
});
}, "Tests that unprefixed animation events are correctly fired when using html event listeners (only unprefixed should be fired)"); }, "Tests that unprefixed animation events are correctly fired when using html event listeners (only unprefixed should be fired)");
</script> </script>
<div id="box" onwebkitanimationstart="recordPrefixedEvent();" onwebkitanimationend="recordPrefixedEvent();" onwebkitanimationiteration="recordPrefixedEvent();" onanimationstart="recordAnimationStart();" onanimationend="recordAnimationEnd();" class="animate"></div> <div id="box" onwebkitanimationstart="recordPrefixedEvent();" onwebkitanimationend="recordPrefixedEvent();" onwebkitanimationiteration="recordPrefixedEvent();" onanimationstart="recordAnimationStart();" onanimationend="recordAnimationEnd();" class="animate"></div>
...@@ -10,29 +10,19 @@ document.addEventListener('animationstart', () => { ...@@ -10,29 +10,19 @@ document.addEventListener('animationstart', () => {
animationStartReceived = true; animationStartReceived = true;
}); });
document.addEventListener('webkitAnimationStart', () => {
assert_unreached("webkitAnimationStart event listener should not have been called");
});
document.addEventListener('animationiteration', () => { document.addEventListener('animationiteration', () => {
animationIterationReceived = true; animationIterationReceived = true;
}); });
document.addEventListener('webkitAnimationIteration', () => {
assert_unreached("webkitAnimationIteration event listener should not have been called");
});
document.addEventListener('webkitAnimationEnd', function(e) {
assert_unreached("webkitAnimationEnd event listener should not have been called");
});
async_test(t => { async_test(t => {
document.addEventListener('animationend', () => { document.addEventListener('webkitAnimationStart', t.unreached_func('webkitAnimationStart event listener should not have been called'));
t.step(() => { document.addEventListener('webkitAnimationIteration', t.unreached_func('webkitAnimationIteration event listener should not have been called'));
assert_true(animationStartReceived && animationIterationReceived); document.addEventListener('webkitAnimationEnd', t.unreached_func('webkitAnimationEnd event listener should not have been called'));
t.done();
}); document.addEventListener('animationend', t.step_func_done(() => {
}); assert_true(animationStartReceived);
assert_true(animationIterationReceived);
}));
var custom = document.createEvent('CustomEvent'); var custom = document.createEvent('CustomEvent');
custom.initCustomEvent('animationstart', true, true, null); custom.initCustomEvent('animationstart', true, true, null);
......
...@@ -74,18 +74,13 @@ function start() ...@@ -74,18 +74,13 @@ function start()
for (var i=0; i < kProperties.length; i++) { for (var i=0; i < kProperties.length; i++) {
var computedValue = elStyle[kProperties[i]]; var computedValue = elStyle[kProperties[i]];
var expectedValue = curItem.values[i]; var expectedValue = curItem.values[i];
assert_true(computedValue == expectedValue); assert_equals(computedValue, expectedValue);
} }
}); });
} }
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func_done(start));
t.step(() => {
start();
t.done();
});
});
}, "Test animation shorthand property prefixed"); }, "Test animation shorthand property prefixed");
</script> </script>
<div id="a" class="box"></div> <div id="a" class="box"></div>
......
...@@ -74,18 +74,13 @@ function start() ...@@ -74,18 +74,13 @@ function start()
for (var i=0; i < kProperties.length; i++) { for (var i=0; i < kProperties.length; i++) {
var computedValue = elStyle[kProperties[i]]; var computedValue = elStyle[kProperties[i]];
var expectedValue = curItem.values[i]; var expectedValue = curItem.values[i];
assert_true(computedValue == expectedValue); assert_equals(computedValue, expectedValue);
} }
}); });
} }
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func_done(start));
t.step(() => {
start();
t.done();
});
});
}, "Test animation shorthand property unprefixed"); }, "Test animation shorthand property unprefixed");
</script> </script>
<div id="a" class="box"></div> <div id="a" class="box"></div>
......
...@@ -19,46 +19,43 @@ ...@@ -19,46 +19,43 @@
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script> <script>
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func_done(() => {
t.step(() => { var testContainer = document.createElement("div");
var testContainer = document.createElement("div"); document.body.appendChild(testContainer);
document.body.appendChild(testContainer);
testContainer.innerHTML = '<div style="width:500px;height:500px"><div id="test">hello</div></div>'; testContainer.innerHTML = '<div style="width:500px;height:500px"><div id="test">hello</div></div>';
e = document.getElementById('test'); e = document.getElementById('test');
var lastSheet = document.styleSheets[document.styleSheets.length - 1]; var lastSheet = document.styleSheets[document.styleSheets.length - 1];
lastSheet.insertRule("@-webkit-keyframes anim { from { left: 200px; } to { left: 300px;} }", lastSheet.cssRules.length); lastSheet.insertRule("@-webkit-keyframes anim { from { left: 200px; } to { left: 300px;} }", lastSheet.cssRules.length);
var keyframeRule = lastSheet.cssRules[lastSheet.cssRules.length - 1]; var keyframeRule = lastSheet.cssRules[lastSheet.cssRules.length - 1];
assert_equals(keyframeRule.toString(), "[object CSSKeyframesRule]"); assert_equals(keyframeRule.toString(), "[object CSSKeyframesRule]");
assert_equals(keyframeRule.type, 7); assert_equals(keyframeRule.type, 7);
assert_equals(keyframeRule.name, "anim"); assert_equals(keyframeRule.name, "anim");
assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.findRule('to').cssText, "100% { left: 300px; }"); assert_equals(keyframeRule.findRule('to').cssText, "100% { left: 300px; }");
keyframeRule.deleteRule("from"); keyframeRule.deleteRule("from");
assert_equals(keyframeRule.findRule('from'), null); assert_equals(keyframeRule.findRule('from'), null);
keyframeRule.appendRule("from { left: 200px; }"); keyframeRule.appendRule("from { left: 200px; }");
assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.cssRules[0].toString(), "[object CSSKeyframeRule]"); assert_equals(keyframeRule.cssRules[0].toString(), "[object CSSKeyframeRule]");
assert_equals(keyframeRule.cssRules[0].cssText, "100% { left: 300px; }"); assert_equals(keyframeRule.cssRules[0].cssText, "100% { left: 300px; }");
assert_equals(keyframeRule.cssRules[0].keyText, "100%"); assert_equals(keyframeRule.cssRules[0].keyText, "100%");
assert_equals(keyframeRule.cssRules[0].style.cssText, "left: 300px;"); assert_equals(keyframeRule.cssRules[0].style.cssText, "left: 300px;");
assert_equals(keyframeRule.cssRules[1].toString(), "[object CSSKeyframeRule]"); assert_equals(keyframeRule.cssRules[1].toString(), "[object CSSKeyframeRule]");
assert_equals(keyframeRule.cssRules[1].cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.cssRules[1].cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.cssRules[1].keyText, "0%"); assert_equals(keyframeRule.cssRules[1].keyText, "0%");
assert_equals(keyframeRule.cssRules[1].style.cssText, "left: 200px;"); assert_equals(keyframeRule.cssRules[1].style.cssText, "left: 200px;");
try { try {
new CSSKeyframesRule().name; new CSSKeyframesRule().name;
} catch (e) { } catch (e) {
assert_equals(e.message, "Illegal constructor"); assert_equals(e.message, "Illegal constructor");
} }
document.body.removeChild(testContainer); document.body.removeChild(testContainer);
t.done(); }));
});
});
}, "Test the CSSOM of @-webkit-keyframes"); }, "Test the CSSOM of @-webkit-keyframes");
</script> </script>
</body> </body>
......
...@@ -17,45 +17,42 @@ ...@@ -17,45 +17,42 @@
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script> <script>
async_test(t => { async_test(t => {
window.addEventListener("load", () => { window.addEventListener("load", t.step_func_done(() => {
t.step(() => { var testContainer = document.createElement("div");
var testContainer = document.createElement("div"); document.body.appendChild(testContainer);
document.body.appendChild(testContainer);
testContainer.innerHTML = '<div style="width:500px;height:500px"><div id="test">hello</div></div>'; testContainer.innerHTML = '<div style="width:500px;height:500px"><div id="test">hello</div></div>';
e = document.getElementById('test'); e = document.getElementById('test');
var lastSheet = document.styleSheets[document.styleSheets.length - 1]; var lastSheet = document.styleSheets[document.styleSheets.length - 1];
lastSheet.insertRule("@keyframes anim { from { left: 200px; } to { left: 300px;} }", lastSheet.cssRules.length); lastSheet.insertRule("@keyframes anim { from { left: 200px; } to { left: 300px;} }", lastSheet.cssRules.length);
var keyframeRule = lastSheet.cssRules[lastSheet.cssRules.length - 1]; var keyframeRule = lastSheet.cssRules[lastSheet.cssRules.length - 1];
assert_equals(keyframeRule.toString(), "[object CSSKeyframesRule]"); assert_equals(keyframeRule.toString(), "[object CSSKeyframesRule]");
assert_equals(keyframeRule.type, 7); assert_equals(keyframeRule.type, 7);
assert_equals(keyframeRule.name, "anim"); assert_equals(keyframeRule.name, "anim");
assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.findRule('to').cssText, "100% { left: 300px; }"); assert_equals(keyframeRule.findRule('to').cssText, "100% { left: 300px; }");
keyframeRule.deleteRule("from"); keyframeRule.deleteRule("from");
assert_equals(keyframeRule.findRule('from'), null); assert_equals(keyframeRule.findRule('from'), null);
keyframeRule.appendRule("from { left: 200px; }"); keyframeRule.appendRule("from { left: 200px; }");
assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.findRule('from').cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.cssRules[0].toString(), "[object CSSKeyframeRule]"); assert_equals(keyframeRule.cssRules[0].toString(), "[object CSSKeyframeRule]");
assert_equals(keyframeRule.cssRules[0].cssText, "100% { left: 300px; }"); assert_equals(keyframeRule.cssRules[0].cssText, "100% { left: 300px; }");
assert_equals(keyframeRule.cssRules[0].keyText, "100%"); assert_equals(keyframeRule.cssRules[0].keyText, "100%");
assert_equals(keyframeRule.cssRules[0].style.cssText, "left: 300px;"); assert_equals(keyframeRule.cssRules[0].style.cssText, "left: 300px;");
assert_equals(keyframeRule.cssRules[1].toString(), "[object CSSKeyframeRule]"); assert_equals(keyframeRule.cssRules[1].toString(), "[object CSSKeyframeRule]");
assert_equals(keyframeRule.cssRules[1].cssText, "0% { left: 200px; }"); assert_equals(keyframeRule.cssRules[1].cssText, "0% { left: 200px; }");
assert_equals(keyframeRule.cssRules[1].keyText, "0%"); assert_equals(keyframeRule.cssRules[1].keyText, "0%");
assert_equals(keyframeRule.cssRules[1].style.cssText, "left: 200px;"); assert_equals(keyframeRule.cssRules[1].style.cssText, "left: 200px;");
try { try {
new CSSKeyframesRule().name; new CSSKeyframesRule().name;
} catch (e) { } catch (e) {
assert_equals(e.message, "Illegal constructor"); assert_equals(e.message, "Illegal constructor");
} }
document.body.removeChild(testContainer); document.body.removeChild(testContainer);
t.done(); }));
});
});
}, "Test the CSSOM of @keyframes"); }, "Test the CSSOM of @keyframes");
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment