1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_windowed_invalidate.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +<html> 1.5 +<head> 1.6 + <title>Test NPN_Invalidate working for a windowed plugin</title> 1.7 + <script type="text/javascript" 1.8 + src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="utils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" 1.11 + href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body onload="runTests()"> 1.14 + <script class="testbody" type="application/javascript"> 1.15 + SimpleTest.waitForExplicitFinish(); 1.16 + setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.17 + 1.18 + var lastPaintCount; 1.19 + var p = null; 1.20 + 1.21 + function checkPainted() { 1.22 + if (p.getPaintCount() > lastPaintCount) { 1.23 + ok(true, "Plugin did repaint"); 1.24 + SimpleTest.finish(); 1.25 + } else { 1.26 + setTimeout(checkPainted, 100); 1.27 + } 1.28 + } 1.29 + 1.30 + function doTest() { 1.31 + // Cause the plugin to invalidate itself using NPN_Invalidate, 1.32 + // and then wait for the plugin's paintCount to increase. This is the 1.33 + // simplest way to check that a windowed plugin has repainted. 1.34 + p.setColor("FF00FF00"); 1.35 + checkPainted(); 1.36 + } 1.37 + 1.38 + function checkPaintCountStabilized() { 1.39 + // Wait for the paint count to stabilize (i.e. doesn't change for a full 1.40 + // second), so that all buffered-up painting is hopefully finished, 1.41 + // before running the test 1.42 + lastPaintCount = p.getPaintCount(); 1.43 + setTimeout(function() { 1.44 + var newCount = p.getPaintCount(); 1.45 + if (newCount == lastPaintCount) { 1.46 + doTest(); 1.47 + } else { 1.48 + checkPaintCountStabilized(); 1.49 + } 1.50 + }, 1000); 1.51 + } 1.52 + 1.53 + function runTests() { 1.54 + p = document.getElementById("p"); 1.55 + checkPaintCountStabilized(); 1.56 + } 1.57 + </script> 1.58 + 1.59 + <p id="display"></p> 1.60 + 1.61 + <embed id="p" type="application/x-test" wmode="window" drawmode="solid" 1.62 + color="FFFF0000"> 1.63 + </embed> 1.64 + 1.65 + <div id="verbose"> 1.66 + </div> 1.67 + </body> 1.68 + </html>