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> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for windowless plugin invalidation and expose events in clips</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | <style> |
michael@0 | 8 | div#container { |
michael@0 | 9 | position: relative; |
michael@0 | 10 | height: 30px; |
michael@0 | 11 | background: blue; |
michael@0 | 12 | } |
michael@0 | 13 | div#clip { |
michael@0 | 14 | overflow:hidden; |
michael@0 | 15 | position:absolute; |
michael@0 | 16 | left: 10.3px; |
michael@0 | 17 | top: 9.7px; |
michael@0 | 18 | width: 10px; |
michael@0 | 19 | height: 0px; |
michael@0 | 20 | background: red; |
michael@0 | 21 | } |
michael@0 | 22 | embed { |
michael@0 | 23 | position:absolute; |
michael@0 | 24 | } |
michael@0 | 25 | embed#paint-waiter { |
michael@0 | 26 | top: 0px; |
michael@0 | 27 | left: 0px; |
michael@0 | 28 | width: 1px; |
michael@0 | 29 | height: 0px; |
michael@0 | 30 | } |
michael@0 | 31 | embed#clipped { |
michael@0 | 32 | left: -5.3px; |
michael@0 | 33 | top: -4.7px; |
michael@0 | 34 | width: 20px; |
michael@0 | 35 | height: 20px; |
michael@0 | 36 | } |
michael@0 | 37 | </style> |
michael@0 | 38 | </head> |
michael@0 | 39 | <body onload="initialize()"> |
michael@0 | 40 | |
michael@0 | 41 | <script type="application/javascript" src="utils.js"></script> |
michael@0 | 42 | <script type="application/javascript"> |
michael@0 | 43 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 44 | setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
michael@0 | 45 | |
michael@0 | 46 | var paint_waiter; |
michael@0 | 47 | var clip; |
michael@0 | 48 | var clipped; |
michael@0 | 49 | |
michael@0 | 50 | function initialize() { |
michael@0 | 51 | paint_waiter = document.getElementById("paint-waiter"); |
michael@0 | 52 | clip = document.getElementById("clip"); |
michael@0 | 53 | clipped = document.getElementById("clipped"); |
michael@0 | 54 | |
michael@0 | 55 | waitForPaint(show); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function show() { |
michael@0 | 59 | paintCountIs(clipped, 0, "fully clipped plugin not painted"); |
michael@0 | 60 | |
michael@0 | 61 | clip.style.height = "10px"; |
michael@0 | 62 | |
michael@0 | 63 | // Capturing an image (as in a reftest) would force a repaint and use |
michael@0 | 64 | // different paths for the image surface, so instead check the plugin's |
michael@0 | 65 | // paint count. |
michael@0 | 66 | waitForPaint(invalidate); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function invalidate() { |
michael@0 | 70 | paintCountIs(clipped, 1, "partially clipped plugin painted once"); |
michael@0 | 71 | |
michael@0 | 72 | clipped.setColor("FF00FF00"); // plugin invalidates |
michael@0 | 73 | |
michael@0 | 74 | waitForPaint(done); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | function done() { |
michael@0 | 78 | paintCountIs(clipped, 2, "painted after invalidate"); |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.finish(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function waitForPaint(func) { |
michael@0 | 84 | paint_waiter.last_paint_count = paint_waiter.getPaintCount(); |
michael@0 | 85 | // Ensure the waiter has had a style change, so that this will |
michael@0 | 86 | // change its size and cause a paint. |
michael@0 | 87 | paint_waiter.style.backgroundColor = paint_waiter.style.backgroundColor == "blue" ? "yellow" : "blue"; |
michael@0 | 88 | var flush = paint_waiter.offsetHeight; |
michael@0 | 89 | paint_waiter.style.height = "1px"; |
michael@0 | 90 | waitForPaintHelper(func); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | function waitForPaintHelper(func) { |
michael@0 | 94 | if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) { |
michael@0 | 95 | // hide the paint waiter |
michael@0 | 96 | paint_waiter.style.height = "0px"; |
michael@0 | 97 | setTimeout(func, 0); |
michael@0 | 98 | return; |
michael@0 | 99 | } |
michael@0 | 100 | setTimeout(function() { waitForPaintHelper(func); }, 1000); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | </script> |
michael@0 | 104 | |
michael@0 | 105 | <p id="display"></p> |
michael@0 | 106 | <div id="container"> |
michael@0 | 107 | <embed id="paint-waiter" type="application/x-test"/> |
michael@0 | 108 | <div id="clip"> |
michael@0 | 109 | <embed id="clipped" type="application/x-test" |
michael@0 | 110 | drawmode="solid" color="FF808080"/> |
michael@0 | 111 | </div> |
michael@0 | 112 | </div> |
michael@0 | 113 | <div id="content" style="display: none"> |
michael@0 | 114 | |
michael@0 | 115 | </div> |
michael@0 | 116 | <pre id="test"> |
michael@0 | 117 | </pre> |
michael@0 | 118 | |
michael@0 | 119 | </body> |
michael@0 | 120 | </html> |