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

Side by Side Diff: LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html

Issue 211503006: Implementation of 2D canvas context lost/restored events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <form method="get" action="?">
10 <input type="hidden" name="hidden" value="I am hidden" />
11 <input id="button" formmethod="post" type="submit" name="button" />
12 </form>
13 <script> 7 <script>
14 description("Test for the formmethod attribute in input tags."); 8 description("Tests to ensure correct behaviour of canvas loss and restoration wh en size is extremely large then, restored to a reasonable value.");
9
15 if (window.testRunner) { 10 if (window.testRunner) {
11 testRunner.dumpAsText();
16 testRunner.waitUntilDone(); 12 testRunner.waitUntilDone();
17 } 13 }
18 14
19 var button = document.getElementById('button'); 15 var canvas = document.createElement('canvas')
16 canvas.addEventListener('contextlost', contextLost);
17 canvas.addEventListener('contextrestored', contextRestored);
18 var ctx = canvas.getContext('2d');
19 var lostEventHasFired = false;
20 verifyContextLost(false);
20 21
21 if (document.URL.substring(0, 4) == "file") { 22 var googol = Math.pow(10,100);
22 if (document.URL.indexOf('?') == -1) { 23 canvas.width = googol;
23 button.click(); 24 canvas.height = googol;
25 verifyContextLost(true);
26 canvas.width = googol;
27 verifyContextLost(true);
28 canvas.width = 100;
29 canvas.height = 100;
30 verifyContextLost(true); // Restoration is async.
31
32 // Restore a sane dimension
33
34 function verifyContextLost(shouldBeLost) {
35 // Verify context loss experimentally as well as isContextLost()
36 ctx.fillStyle = '#0f0';
37 ctx.fillRect(0, 0, 1, 1);
38 contextLostTest = ctx.getImageData(0, 0, 1, 1).data[1] == 0;
39 if (shouldBeLost) {
40 shouldBeTrue('contextLostTest');
41 shouldBeTrue('ctx.isContextLost()');
24 } else { 42 } else {
25 if (document.URL.substring(document.URL.indexOf('?') + 1, document.URL.l ength) == "") 43 shouldBeFalse('contextLostTest');
26 testPassed('The formmethod attribute was successfully used'); 44 shouldBeFalse('ctx.isContextLost()');
27 else 45 }
28 testFailed('The formmethod attribute was not used'); 46 }
29 47
30 if (window.testRunner) 48 function contextLost() {
31 testRunner.notifyDone(); 49 if (lostEventHasFired) {
50 testFailed('Context lost event was dispatched more than once.');
51 } else {
52 testPassed('Graphics context lost event dispatched.');
53 }
54 lostEventHasFired = true;
55 verifyContextLost(true);
56 }
57
58 function contextRestored() {
59 if (lostEventHasFired) {
60 testPassed('Context restored event dispatched after context lost.');
61 } else {
62 testFailed('Context restored event was dispatched before a context lost event.');
63 }
64 verifyContextLost(false);
65 » if (window.testRunner) {
66 » testRunner.notifyDone();
32 } 67 }
33 } 68 }
34 </script> 69 </script>
35 </body> 70 </body>
36 </html> 71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698