1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_painting.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for windowless plugin invalidation and expose events in clips</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 + <style> 1.11 + div#container { 1.12 + position: relative; 1.13 + height: 30px; 1.14 + background: blue; 1.15 + } 1.16 + div#clip { 1.17 + overflow:hidden; 1.18 + position:absolute; 1.19 + left: 10.3px; 1.20 + top: 9.7px; 1.21 + width: 10px; 1.22 + height: 0px; 1.23 + background: red; 1.24 + } 1.25 + embed { 1.26 + position:absolute; 1.27 + } 1.28 + embed#paint-waiter { 1.29 + top: 0px; 1.30 + left: 0px; 1.31 + width: 1px; 1.32 + height: 0px; 1.33 + } 1.34 + embed#clipped { 1.35 + left: -5.3px; 1.36 + top: -4.7px; 1.37 + width: 20px; 1.38 + height: 20px; 1.39 + } 1.40 + </style> 1.41 +</head> 1.42 +<body onload="initialize()"> 1.43 + 1.44 +<script type="application/javascript" src="utils.js"></script> 1.45 +<script type="application/javascript"> 1.46 +SimpleTest.waitForExplicitFinish(); 1.47 +setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.48 + 1.49 +var paint_waiter; 1.50 +var clip; 1.51 +var clipped; 1.52 + 1.53 +function initialize() { 1.54 + paint_waiter = document.getElementById("paint-waiter"); 1.55 + clip = document.getElementById("clip"); 1.56 + clipped = document.getElementById("clipped"); 1.57 + 1.58 + waitForPaint(show); 1.59 +} 1.60 + 1.61 +function show() { 1.62 + paintCountIs(clipped, 0, "fully clipped plugin not painted"); 1.63 + 1.64 + clip.style.height = "10px"; 1.65 + 1.66 + // Capturing an image (as in a reftest) would force a repaint and use 1.67 + // different paths for the image surface, so instead check the plugin's 1.68 + // paint count. 1.69 + waitForPaint(invalidate); 1.70 +} 1.71 + 1.72 +function invalidate() { 1.73 + paintCountIs(clipped, 1, "partially clipped plugin painted once"); 1.74 + 1.75 + clipped.setColor("FF00FF00"); // plugin invalidates 1.76 + 1.77 + waitForPaint(done); 1.78 +} 1.79 + 1.80 +function done() { 1.81 + paintCountIs(clipped, 2, "painted after invalidate"); 1.82 + 1.83 + SimpleTest.finish(); 1.84 +} 1.85 + 1.86 +function waitForPaint(func) { 1.87 + paint_waiter.last_paint_count = paint_waiter.getPaintCount(); 1.88 + // Ensure the waiter has had a style change, so that this will 1.89 + // change its size and cause a paint. 1.90 + paint_waiter.style.backgroundColor = paint_waiter.style.backgroundColor == "blue" ? "yellow" : "blue"; 1.91 + var flush = paint_waiter.offsetHeight; 1.92 + paint_waiter.style.height = "1px"; 1.93 + waitForPaintHelper(func); 1.94 +} 1.95 + 1.96 +function waitForPaintHelper(func) { 1.97 + if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) { 1.98 + // hide the paint waiter 1.99 + paint_waiter.style.height = "0px"; 1.100 + setTimeout(func, 0); 1.101 + return; 1.102 + } 1.103 + setTimeout(function() { waitForPaintHelper(func); }, 1000); 1.104 +} 1.105 + 1.106 +</script> 1.107 + 1.108 +<p id="display"></p> 1.109 +<div id="container"> 1.110 + <embed id="paint-waiter" type="application/x-test"/> 1.111 + <div id="clip"> 1.112 + <embed id="clipped" type="application/x-test" 1.113 + drawmode="solid" color="FF808080"/> 1.114 + </div> 1.115 +</div> 1.116 +<div id="content" style="display: none"> 1.117 + 1.118 +</div> 1.119 +<pre id="test"> 1.120 +</pre> 1.121 + 1.122 +</body> 1.123 +</html>