Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / canvas-lose-restore-max-int-size.html
blobec412cb3393c4658b566bfbe61225df7a71243fe
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Tests to ensure correct behaviour of canvas loss and restoration when size is extremely large then, restored to a reasonable value.");
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
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);
22 // WebIDL defines width and height as int. 2147483647 is int max.
23 var extremelyLargeNumber = 2147483647;
24 canvas.width = extremelyLargeNumber;
25 canvas.height = extremelyLargeNumber;
26 verifyContextLost(true);
27 canvas.width = extremelyLargeNumber;
28 verifyContextLost(true);
29 canvas.width = 100;
30 canvas.height = 100;
31 verifyContextLost(true); // Restoration is async.
32 // Restore a sane dimension
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()');
42 } else {
43 shouldBeFalse('contextLostTest');
44 shouldBeFalse('ctx.isContextLost()');
48 function contextLost() {
49 if (lostEventHasFired) {
50 testFailed('Context lost event was dispatched more than once.');
51 } else {
52 testPassed('Graphics context lost event dispatched.');
54 lostEventHasFired = true;
55 verifyContextLost(true);
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.');
64 verifyContextLost(false);
65 if (window.testRunner) {
66 testRunner.notifyDone();
69 </script>
70 </body>
71 </html>