Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html class="reftest-wait"> |
michael@0 | 3 | <head> |
michael@0 | 4 | <script> |
michael@0 | 5 | var unusedScreenX; |
michael@0 | 6 | function XSync() { |
michael@0 | 7 | unusedScreenX = window.screenX; |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | function finish() { |
michael@0 | 11 | document.documentElement.removeAttribute("class"); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function cleanup() { |
michael@0 | 15 | try { |
michael@0 | 16 | document.getElementById("plugin").crash(); |
michael@0 | 17 | } catch (dontcare) { |
michael@0 | 18 | } |
michael@0 | 19 | window.setTimeout(finish, 100); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function scrollOfDeath() { |
michael@0 | 23 | // Add a listener for the MozAfterPaint after the scrollTo below. |
michael@0 | 24 | // If we don't crash during the scroll, we'll get the |
michael@0 | 25 | // MozAfterPaint. |
michael@0 | 26 | window.addEventListener("MozAfterPaint", cleanup, false); |
michael@0 | 27 | window.scrollTo(0, 50); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | // |
michael@0 | 31 | // The sequence of events we expect is |
michael@0 | 32 | // |
michael@0 | 33 | // load (including initial paints of plugin that are cached) |
michael@0 | 34 | // destroy X resources |
michael@0 | 35 | // [X server has time to observe resource destruction] |
michael@0 | 36 | // scrollTo |
michael@0 | 37 | // [repaint using cached plugin surface: BOOM if buggy] |
michael@0 | 38 | // MozAfterPaint |
michael@0 | 39 | // cleanup |
michael@0 | 40 | // |
michael@0 | 41 | // However, this test is fundamentally nondeterministic. There are |
michael@0 | 42 | // two main "failure" modes |
michael@0 | 43 | // (1) X server doesn't have time to observer resource destruction |
michael@0 | 44 | // before paint-after-scroll |
michael@0 | 45 | // (2) plugin's crash notification arrives before |
michael@0 | 46 | // paint-after-scroll |
michael@0 | 47 | // Both result in spurious passes. |
michael@0 | 48 | // |
michael@0 | 49 | // This test is anal about cleanup because it must be pretty sure that |
michael@0 | 50 | // the plugin subprocess is gone before starting the next test. We |
michael@0 | 51 | // double-check that the plugin is gone by the time we're done by |
michael@0 | 52 | // trying to crash it again, after we expect it to have crashed already. |
michael@0 | 53 | // |
michael@0 | 54 | function runTest() { |
michael@0 | 55 | // Have the plugin throw away its X resources, one of which is |
michael@0 | 56 | // probably a drawable to which we hold a reference |
michael@0 | 57 | document.getElementById("plugin").destroySharedGfxStuff(); |
michael@0 | 58 | |
michael@0 | 59 | // Do something that's (hopefully) equivalent to an XSync() to allow |
michael@0 | 60 | // the resource destruction to propagate to the server |
michael@0 | 61 | XSync(); |
michael@0 | 62 | |
michael@0 | 63 | // Set up a scroll to happen soon |
michael@0 | 64 | window.setTimeout(scrollOfDeath, 100); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | window.addEventListener("MozReftestInvalidate", runTest, false); |
michael@0 | 68 | </script> |
michael@0 | 69 | </head> |
michael@0 | 70 | |
michael@0 | 71 | <body style="width: 400px; height: 10000px;"> |
michael@0 | 72 | <embed id="plugin" type="application/x-test" |
michael@0 | 73 | style="position:absolute; |
michael@0 | 74 | top:100px; left:50px; width:200px; height:200px;"> |
michael@0 | 75 | </embed> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |