summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/reftest/update-1.html
blob: cff85bc9f0869c2700620c14abdd81c9f8d10dae (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
<!DOCTYPE html>
<html class="reftest-wait">
<head>
  <title>Test for bugs 807728 and 810426</title>
  <script src="utils.js">
  </script>
  <script>
function start()
{
    document.removeEventListener("MozReftestInvalidate", start);

    var plugin = document.getElementById("plugin");
    var color = "FF000000";
    var color_count = 0;
    var last_paint_count = 0;
    // Enough paints to test reusing a surface after it has been
    // moved from front to back buffer.
    // FIXME: Stop using mozPaintCount for this test.
    //        Can't make it a chrome:// url because it needs http, thus no
    //        SpecialPowers :/
    var final_paint_count = window.mozPaintCount + 10;
    var final_color = "FFFF0000";

    // Using mozPaintCount to track when content has been updated as an
    // indication that the browser has received updates, instead of
    // plugin.getPaintCount() which tracks when the plugin sends updates or
    // MozAfterPaint events which track OS paints.  Not using
    // MozPaintWaitFinished because invalidation causes no geometry changes.
    function wait_for_paints() {
        var paint_count = window.mozPaintCount;
        if (paint_count >= final_paint_count && color == final_color) {
            document.documentElement.removeAttribute("class");
            return;
        }
        if (paint_count != last_paint_count) {
            last_paint_count = paint_count;
            if (paint_count + 1 >= final_paint_count) {
                color = final_color;
                // Wait for the paint with the final color
                final_paint_count = paint_count + 1;
            } else {
                ++color_count;
                color = "FF00000" + color_count;
            }
            plugin.setColor(color);
        }       
        setTimeout(wait_for_paints, 0);
    }

    wait_for_paints();
}

// MozReftestInvalidate is delivered after initial painting has settled.
document.addEventListener("MozReftestInvalidate", start);
  </script>
</head>
<body onLoad="forceLoadPlugin('plugin', true)">
  <embed id="plugin" type="application/x-test"
         drawmode="solid" color="FF000000" width="30" height="50">
  </embed>
</body>
</html>