2012-09-05 18:34:06 +04:00
|
|
|
/* Any copyright is dedicated to the public domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
// Bug 787378 - Add mozbrowserfirstpaint event.
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-03-28 23:51:10 +04:00
|
|
|
browserElementTestHelpers.setEnabledPref(true);
|
|
|
|
browserElementTestHelpers.addPermission();
|
2012-09-05 18:34:06 +04:00
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
var iframe = document.createElement('iframe');
|
2014-10-31 05:39:15 +03:00
|
|
|
iframe.setAttribute('mozbrowser', 'true');
|
2012-09-05 18:34:06 +04:00
|
|
|
|
|
|
|
var gotFirstPaint = false;
|
|
|
|
var gotFirstLocationChange = false;
|
|
|
|
iframe.addEventListener('mozbrowserfirstpaint', function(e) {
|
|
|
|
ok(!gotFirstPaint, "Got only one first paint.");
|
|
|
|
gotFirstPaint = true;
|
|
|
|
|
|
|
|
if (gotFirstLocationChange) {
|
2013-06-05 05:58:53 +04:00
|
|
|
iframe.src = browserElementTestHelpers.emptyPage1 + '?2';
|
2012-09-05 18:34:06 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
iframe.addEventListener('mozbrowserlocationchange', function(e) {
|
|
|
|
if (e.detail == browserElementTestHelpers.emptyPage1) {
|
|
|
|
gotFirstLocationChange = true;
|
|
|
|
if (gotFirstPaint) {
|
2013-06-05 05:58:53 +04:00
|
|
|
iframe.src = browserElementTestHelpers.emptyPage1 + '?2';
|
2012-09-05 18:34:06 +04:00
|
|
|
}
|
|
|
|
}
|
2013-06-05 05:58:53 +04:00
|
|
|
else if (e.detail.endsWith('?2')) {
|
2012-09-05 18:34:06 +04:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
document.body.appendChild(iframe);
|
|
|
|
|
|
|
|
iframe.src = browserElementTestHelpers.emptyPage1;
|
|
|
|
}
|
|
|
|
|
2013-03-28 23:51:10 +04:00
|
|
|
addEventListener('testready', runTest);
|