summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/crashtests/598862.html
blob: 9b1ad38d75dec1200365bc80661162535a5b13f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE HTML>
<html class="reftest-wait">
  <head>
    <script>
var unusedScreenX;
function XSync() {
  unusedScreenX = window.screenX;
}

function finish() {
  document.documentElement.removeAttribute("class");
}

function cleanup() {
  try {
    document.getElementById("plugin").crash();
  } catch (dontcare) {
  }
  window.setTimeout(finish, 100);
}

function scrollOfDeath() {
  // Add a listener for the MozAfterPaint after the scrollTo below.
  // If we don't crash during the scroll, we'll get the
  // MozAfterPaint.
  window.addEventListener("MozAfterPaint", cleanup, false);
  window.scrollTo(0, 50);
}

//
// The sequence of events we expect is
//
//   load (including initial paints of plugin that are cached)
//   destroy X resources
//   [X server has time to observe resource destruction]
//   scrollTo
//   [repaint using cached plugin surface: BOOM if buggy]
//   MozAfterPaint
//   cleanup
//
// However, this test is fundamentally nondeterministic.  There are
// two main "failure" modes
//   (1) X server doesn't have time to observer resource destruction
//       before paint-after-scroll
//   (2) plugin's crash notification arrives before
//       paint-after-scroll
// Both result in spurious passes.
//
// This test is anal about cleanup because it must be pretty sure that
// the plugin subprocess is gone before starting the next test.  We
// double-check that the plugin is gone by the time we're done by 
// trying to crash it again, after we expect it to have crashed already.
//
function runTest() {
  // Have the plugin throw away its X resources, one of which is
  // probably a drawable to which we hold a reference
  document.getElementById("plugin").destroySharedGfxStuff();

  // Do something that's (hopefully) equivalent to an XSync() to allow
  // the resource destruction to propagate to the server
  XSync();

  // Set up a scroll to happen soon
  window.setTimeout(scrollOfDeath, 100);
}

window.addEventListener("MozReftestInvalidate", runTest, false);
    </script>
  </head>

  <body style="width: 400px; height: 10000px;">
    <embed id="plugin" type="application/x-test"
           style="position:absolute;
                  top:100px; left:50px; width:200px; height:200px;">
    </embed>
  </body>
</html>