michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Bug 829486 - Add mozdocumentbrowserfirstpaint event. michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: var iframe; michael@0: michael@0: function runTestQueue(queue) { michael@0: if (queue.length == 0) { michael@0: SimpleTest.finish(); michael@0: return; michael@0: } michael@0: michael@0: var gotFirstPaint = false; michael@0: var gotFirstLocationChange = false; michael@0: var test = queue.shift(); michael@0: michael@0: function runNext() { michael@0: iframe.removeEventListener('mozbrowserdocumentfirstpaint', documentfirstpainthandler); michael@0: iframe.removeEventListener('mozbrowserloadend', loadendhandler); michael@0: runTestQueue(queue); michael@0: } michael@0: michael@0: function documentfirstpainthandler(e) { michael@0: ok(!gotFirstPaint, "Got firstpaint only once"); michael@0: gotFirstPaint = true; michael@0: if (gotFirstLocationChange) { michael@0: runNext(); michael@0: } michael@0: } michael@0: michael@0: function loadendhandler(e) { michael@0: gotFirstLocationChange = true; michael@0: if (gotFirstPaint) { michael@0: runNext(); michael@0: } michael@0: } michael@0: michael@0: iframe.addEventListener('mozbrowserdocumentfirstpaint', documentfirstpainthandler); michael@0: iframe.addEventListener('mozbrowserloadend', loadendhandler); michael@0: michael@0: test(); michael@0: } michael@0: michael@0: function testChangeLocation() { michael@0: iframe.src = browserElementTestHelpers.emptyPage1 + "?2"; michael@0: } michael@0: michael@0: function testReload() { michael@0: iframe.reload(); michael@0: } michael@0: michael@0: function testFirstLoad() { michael@0: document.body.appendChild(iframe); michael@0: iframe.src = browserElementTestHelpers.emptyPage1; michael@0: } michael@0: michael@0: function runTest() { michael@0: iframe = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe).mozbrowser = true; michael@0: michael@0: runTestQueue([testFirstLoad, testReload, testChangeLocation]); michael@0: } michael@0: michael@0: addEventListener('testready', runTest);