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

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: adding missing file Created 6 years, 9 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 // WebIDL defines width and height as int. 2147483647 is int max.
Stephen White 2014/03/25 23:25:04 Nit: but the test is googol-sized, not int max?
22 if (document.URL.indexOf('?') == -1) { 23 var googol = Math.pow(10,100);
23 button.click(); 24 canvas.width = googol;
25 canvas.height = googol;
26 verifyContextLost(true);
27 canvas.width = googol;
28 verifyContextLost(true);
29 canvas.width = 100;
30 canvas.height = 100;
31 verifyContextLost(true); // Restoration is async.
32
33 // Restore a sane dimension
34
35 function verifyContextLost(shouldBeLost) {
36 // Verify context loss experimentally as well as isContextLost()
37 ctx.fillStyle = '#0f0';
38 ctx.fillRect(0, 0, 1, 1);
39 contextLostTest = ctx.getImageData(0, 0, 1, 1).data[1] == 0;
40 if (shouldBeLost) {
41 shouldBeTrue('contextLostTest');
42 shouldBeTrue('ctx.isContextLost()');
24 } else { 43 } else {
25 if (document.URL.substring(document.URL.indexOf('?') + 1, document.URL.l ength) == "") 44 shouldBeFalse('contextLostTest');
26 testPassed('The formmethod attribute was successfully used'); 45 shouldBeFalse('ctx.isContextLost()');
27 else 46 }
28 testFailed('The formmethod attribute was not used'); 47 }
29 48
30 if (window.testRunner) 49 function contextLost() {
31 testRunner.notifyDone(); 50 if (lostEventHasFired) {
51 testFailed('Context lost event was dispatched more than once.');
52 } else {
53 testPassed('Graphics context lost event dispatched.');
54 }
55 lostEventHasFired = true;
56 verifyContextLost(true);
57 }
58
59 function contextRestored() {
60 if (lostEventHasFired) {
61 testPassed('Context restored event dispatched after context lost.');
62 } else {
63 testFailed('Context restored event was dispatched before a context lost event.');
64 }
65 verifyContextLost(false);
66 » if (window.testRunner) {
67 » testRunner.notifyDone();
32 } 68 }
33 } 69 }
34 </script> 70 </script>
35 </body> 71 </body>
36 </html> 72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698