Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* Any copyright is dedicated to the public domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Bug 808231 - Add mozbrowsernextpaint event. |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 8 | browserElementTestHelpers.setEnabledPref(true); |
michael@0 | 9 | browserElementTestHelpers.addPermission(); |
michael@0 | 10 | |
michael@0 | 11 | function runTest() { |
michael@0 | 12 | var iframe = document.createElement('iframe'); |
michael@0 | 13 | SpecialPowers.wrap(iframe).mozbrowser = true; |
michael@0 | 14 | document.body.appendChild(iframe); |
michael@0 | 15 | |
michael@0 | 16 | // Add a first listener that we'll remove shortly after. |
michael@0 | 17 | iframe.addNextPaintListener(wrongListener); |
michael@0 | 18 | |
michael@0 | 19 | var gotFirstNextPaintEvent = false; |
michael@0 | 20 | iframe.addNextPaintListener(function () { |
michael@0 | 21 | ok(!gotFirstNextPaintEvent, 'got the first nextpaint event'); |
michael@0 | 22 | |
michael@0 | 23 | // Make sure we're only called once. |
michael@0 | 24 | gotFirstNextPaintEvent = true; |
michael@0 | 25 | |
michael@0 | 26 | iframe.addNextPaintListener(function () { |
michael@0 | 27 | info('got the second nextpaint event'); |
michael@0 | 28 | SimpleTest.finish(); |
michael@0 | 29 | }); |
michael@0 | 30 | |
michael@0 | 31 | // Force the iframe to repaint. |
michael@0 | 32 | SimpleTest.executeSoon(function () iframe.src += '#next'); |
michael@0 | 33 | }); |
michael@0 | 34 | |
michael@0 | 35 | // Remove the first listener to make sure it's not called. |
michael@0 | 36 | iframe.removeNextPaintListener(wrongListener); |
michael@0 | 37 | iframe.src = 'file_browserElement_NextPaint.html'; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function wrongListener() { |
michael@0 | 41 | ok(false, 'first listener should have been removed'); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | addEventListener('testready', runTest); |