Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Unified Diff: third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration.html

Issue 2745823002: [animation-worklet] Implement registerAnimator in worklet scope (Closed)
Patch Set: Address nhiroki feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration.html
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration.html b/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration.html
new file mode 100644
index 0000000000000000000000000000000000000000..3747631b4f6399771405dd3d379b5db22614fb1b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+
+<script id="duplicate" type="text/worklet">
+try {
+ registerAnimator("duplicate", class { animate() {} });
+ registerAnimator("duplicate", class { animate() {} });
+} catch(e) { console.log(e); }
+</script>
+
+<script id="no_class" type="text/worklet">
+try {
+ registerAnimator("no_class", "");
+} catch(e) { console.log(e); }
+</script>
+
+<script id="empty_string" type="text/worklet">
+try {
+ registerAnimator("", class { animate() {} });
+} catch(e) { console.log(e); }
+</script>
+
+<script id="empty_string" type="text/worklet">
+registerAnimator("test", class {
+ constructor() {
+ console.log("test animator constructor called.");
+ }
+ animate() {
+ console.log("test animator animate called.");
+ }
+});
+</script>
+
+<script>
+// TODO(majidvp): The try/catch in above test cases should not be needed but at the moment
+// threaded worklet does not correctly pass error to its parent context. It crashes in
+// https://codesearch.chromium.org/chromium/src/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp?sq=package:chromium&dr&l=320
+
+function runInAnimationWorklet(code) {
+ return window.animationWorklet.addModule(
+ URL.createObjectURL(new Blob([code], {type: 'text/javascript'}))
+ );
+}
+
+// Load test cases in worklet context in sequence and wait until they are resolved.
+function runTests(testcases) {
+ if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ }
+
+ const runInSequence = testcases.reduce((chain, testcase) => {
+ return chain.then( _ => {
+ return runInAnimationWorklet(testcase);
+ });
+ }, Promise.resolve());
+
+ // TODO(majidvp): Figure out how to wait on AnimationWorklet, which runs on a separate thread,
+ // to complete its tasks instead of a timeout.
+ runInSequence.then(_ => {
+ setTimeout(_ => {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 100);
+ });
+}
+
+const testcases = Array.prototype.map.call(document.querySelectorAll('script[type$=worklet]'), ($el) => {
+ return $el.textContent;
+});
+
+runTests(testcases);
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/animation-worklet-animator-registration-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698