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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html

Issue 2799893002: Rewrite flaky canvas test to testharness.js to sidestep issue (Closed)
Patch Set: rebase Created 3 years, 8 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/fast/canvas/canvas-lose-restore-googol-size.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
index f8d7bd12fe96006419438e64465bc2102263226a..e13341c96fc65976366eaa620c85654138d2d1b6 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
@@ -1,71 +1,46 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
+<!doctype html>
+<title>Canvas loss and restoration when size is extremely large and then restored to a reasonable value</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<script>
-description("Tests to ensure correct behaviour of canvas loss and restoration when size is extremely large then, restored to a reasonable value.");
-
-if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
-}
-
-var canvas = document.createElement('canvas')
-canvas.addEventListener('contextlost', contextLost);
-canvas.addEventListener('contextrestored', contextRestored);
-var ctx = canvas.getContext('2d');
-var lostEventHasFired = false;
-verifyContextLost(false);
-
-var bigsize = 1000000000;
-canvas.width = bigsize;
-canvas.height = bigsize;
-verifyContextLost(true);
-canvas.width = bigsize;
-verifyContextLost(true);
-canvas.width = 100;
-canvas.height = 100;
-verifyContextLost(true); // Restoration is async.
+async_test(t => {
+ var canvas = document.createElement('canvas')
+ canvas.addEventListener('contextlost', t.step_func(contextLost));
+ canvas.addEventListener('contextrestored', t.step_func(contextRestored));
+ var ctx = canvas.getContext('2d');
+ var lostEventHasFired = false;
+ verifyContextLost(false);
-// Restore a sane dimension
+ var bigsize = 1000000000;
+ canvas.width = bigsize;
+ canvas.height = bigsize;
+ verifyContextLost(true);
+ canvas.width = bigsize;
+ verifyContextLost(true);
+ // Restore a reasonable dimension
+ canvas.width = 100;
+ canvas.height = 100;
+ verifyContextLost(true); // Restoration is async.
-function verifyContextLost(shouldBeLost) {
- // Verify context loss experimentally as well as isContextLost()
- ctx.fillStyle = '#0f0';
- ctx.fillRect(0, 0, 1, 1);
- contextLostTest = ctx.getImageData(0, 0, 1, 1).data[1] == 0;
- if (shouldBeLost) {
- shouldBeTrue('contextLostTest');
- shouldBeTrue('ctx.isContextLost()');
- } else {
- shouldBeFalse('contextLostTest');
- shouldBeFalse('ctx.isContextLost()');
+ function verifyContextLost(shouldBeLost) {
+ // Verify context loss experimentally as well as isContextLost()
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 1, 1);
+ var contextLostTest = ctx.getImageData(0, 0, 1, 1).data[1] == 0;
+ assert_equals(contextLostTest, shouldBeLost, 'image data is blank');
+ assert_equals(ctx.isContextLost(), shouldBeLost, 'context is lost');
}
-}
-function contextLost() {
- if (lostEventHasFired) {
- testFailed('Context lost event was dispatched more than once.');
- } else {
- testPassed('Graphics context lost event dispatched.');
+ function contextLost() {
+ assert_false(lostEventHasFired, 'contextlost event has fired');
+ lostEventHasFired = true;
+ verifyContextLost(true);
}
- lostEventHasFired = true;
- verifyContextLost(true);
-}
-function contextRestored() {
- if (lostEventHasFired) {
- testPassed('Context restored event dispatched after context lost.');
- } else {
- testFailed('Context restored event was dispatched before a context lost event.');
- }
- verifyContextLost(false);
- if (window.testRunner) {
- testRunner.notifyDone();
+ function contextRestored() {
+ assert_true(lostEventHasFired, 'contextlost event has fired');
+ verifyContextLost(false);
+ t.done();
}
-}
+});
</script>
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698