michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Bug 808231 - Add mozbrowsernextpaint event. michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: function runTest() { michael@0: var iframe = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe).mozbrowser = true; michael@0: document.body.appendChild(iframe); michael@0: michael@0: // Add a first listener that we'll remove shortly after. michael@0: iframe.addNextPaintListener(wrongListener); michael@0: michael@0: var gotFirstNextPaintEvent = false; michael@0: iframe.addNextPaintListener(function () { michael@0: ok(!gotFirstNextPaintEvent, 'got the first nextpaint event'); michael@0: michael@0: // Make sure we're only called once. michael@0: gotFirstNextPaintEvent = true; michael@0: michael@0: iframe.addNextPaintListener(function () { michael@0: info('got the second nextpaint event'); michael@0: SimpleTest.finish(); michael@0: }); michael@0: michael@0: // Force the iframe to repaint. michael@0: SimpleTest.executeSoon(function () iframe.src += '#next'); michael@0: }); michael@0: michael@0: // Remove the first listener to make sure it's not called. michael@0: iframe.removeNextPaintListener(wrongListener); michael@0: iframe.src = 'file_browserElement_NextPaint.html'; michael@0: } michael@0: michael@0: function wrongListener() { michael@0: ok(false, 'first listener should have been removed'); michael@0: } michael@0: michael@0: addEventListener('testready', runTest);