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