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

Unified Diff: third_party/WebKit/LayoutTests/vr/requestAnimationFrame_unregister.html

Issue 2622943002: Fix WebVR requestAnimationFrame leaking (Closed)
Patch Set: Rebase to see if CQ failure fixed Created 3 years, 11 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
Index: third_party/WebKit/LayoutTests/vr/requestAnimationFrame_unregister.html
diff --git a/third_party/WebKit/LayoutTests/vr/requestAnimationFrame_unregister.html b/third_party/WebKit/LayoutTests/vr/requestAnimationFrame_unregister.html
new file mode 100644
index 0000000000000000000000000000000000000000..142d5838e33cbac57e8f3aae9bf66a8b36922815
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/vr/requestAnimationFrame_unregister.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/fake-vr-displays.js"></script>
+<script src="resources/mock-vr-service.js"></script>
+<script>
+let fakeDisplays = fakeVRDisplays();
+
+vr_test( (t) => {
+ return navigator.getVRDisplays().then( (displays) => {
+ let display = displays[0];
+
+ function onAnimationFrameBad() {
+ t.step( () => {
+ assert_unreached();
+ }, "Unregistered callback was called");
+ t.done();
+ }
+
+ let counter = 0;
+ function onAnimationFrameGood() {
+ counter++;
+ if (counter >= 4) {
+ t.done();
+ // Intentionally don't return immediately so that display.rAF gets
+ // called again to make sure it doesn't cause unexpected behavior like
+ // it did with crbug.com/679401
+ }
+ display.requestAnimationFrame(onAnimationFrameGood);
+ }
+
+ let handle = display.requestAnimationFrame(onAnimationFrameBad);
+ display.cancelAnimationFrame(handle);
+ display.requestAnimationFrame(onAnimationFrameGood);
+ }, (err) => {
+ t.step( () => {
+ assert_unreached("getVRDisplays rejected");
+ });
+ t.done();
+ });
+}, [fakeDisplays["Pixel"]],
+"requestAnimationFrame callbacks can be unregistered with cancelAnimationFrame");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698