| Index: LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
|
| diff --git a/LayoutTests/fast/forms/formmethod-attribute-input-html.html b/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
|
| similarity index 12%
|
| copy from LayoutTests/fast/forms/formmethod-attribute-input-html.html
|
| copy to LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
|
| index bb44664a46215ee8ba405b8280a85413e0ab8e8a..8f1d8a9aaf30e61e7605f127c013c5bff79e609b 100644
|
| --- a/LayoutTests/fast/forms/formmethod-attribute-input-html.html
|
| +++ b/LayoutTests/fast/canvas/canvas-lose-restore-googol-size.html
|
| @@ -4,31 +4,66 @@
|
| <script src="../../resources/js-test.js"></script>
|
| </head>
|
| <body>
|
| -<p id="description"></p>
|
| -<div id="console"></div>
|
| -<form method="get" action="?">
|
| - <input type="hidden" name="hidden" value="I am hidden" />
|
| - <input id="button" formmethod="post" type="submit" name="button" />
|
| -</form>
|
| <script>
|
| -description("Test for the formmethod attribute in input tags.");
|
| +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 button = document.getElementById('button');
|
| +var canvas = document.createElement('canvas')
|
| +canvas.addEventListener('contextlost', contextLost);
|
| +canvas.addEventListener('contextrestored', contextRestored);
|
| +var ctx = canvas.getContext('2d');
|
| +var lostEventHasFired = false;
|
| +verifyContextLost(false);
|
| +
|
| +var googol = Math.pow(10,100);
|
| +canvas.width = googol;
|
| +canvas.height = googol;
|
| +verifyContextLost(true);
|
| +canvas.width = googol;
|
| +verifyContextLost(true);
|
| +canvas.width = 100;
|
| +canvas.height = 100;
|
| +verifyContextLost(true); // Restoration is async.
|
| +
|
| +// Restore a sane dimension
|
|
|
| -if (document.URL.substring(0, 4) == "file") {
|
| - if (document.URL.indexOf('?') == -1) {
|
| - button.click();
|
| +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 {
|
| - if (document.URL.substring(document.URL.indexOf('?') + 1, document.URL.length) == "")
|
| - testPassed('The formmethod attribute was successfully used');
|
| - else
|
| - testFailed('The formmethod attribute was not used');
|
| + shouldBeFalse('contextLostTest');
|
| + shouldBeFalse('ctx.isContextLost()');
|
| + }
|
| +}
|
|
|
| - if (window.testRunner)
|
| - testRunner.notifyDone();
|
| +function contextLost() {
|
| + if (lostEventHasFired) {
|
| + testFailed('Context lost event was dispatched more than once.');
|
| + } else {
|
| + testPassed('Graphics context lost event dispatched.');
|
| + }
|
| + 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();
|
| }
|
| }
|
| </script>
|
|
|