Bug 869903 - Report background color on mozbrowserfirstpaint, r=jlebar

This commit is contained in:
Michael Wu 2013-06-06 17:40:49 -04:00
parent 81b2688654
commit 5c3b61df6b
4 changed files with 19 additions and 2 deletions

View File

@ -187,7 +187,9 @@ BrowserElementChild.prototype = {
// Registers a MozAfterPaint handler for the very first paint.
this._addMozAfterPaintHandler(function () {
sendAsyncMsg('firstpaint');
let bgColor = content.getComputedStyle(content.document.body)
.getPropertyValue('background-color');
sendAsyncMsg('firstpaint', {backgroundColor: bgColor});
});
let self = this;

View File

@ -69,6 +69,7 @@ MOCHITEST_FILES = \
file_browserElement_XFrameOptionsAllowFrom.html \
file_browserElement_XFrameOptionsAllowFrom.sjs \
browserElement_FirstPaint.js \
file_browserElement_FirstPaint.html \
test_browserElement_inproc_FirstPaint.html \
browserElement_NextPaint.js \
test_browserElement_inproc_NextPaint.html \

View File

@ -10,7 +10,9 @@ browserElementTestHelpers.addPermission();
function runTest() {
var iframe = document.createElement('iframe');
var iframe2 = document.createElement('iframe');
SpecialPowers.wrap(iframe).mozbrowser = true;
SpecialPowers.wrap(iframe2).mozbrowser = true;
var gotFirstPaint = false;
var gotFirstLocationChange = false;
@ -18,6 +20,8 @@ function runTest() {
ok(!gotFirstPaint, "Got only one first paint.");
gotFirstPaint = true;
is(e.detail.backgroundColor, "transparent", "Got the expected background color.");
if (gotFirstLocationChange) {
iframe.src = browserElementTestHelpers.emptyPage1 + '?2';
}
@ -31,10 +35,16 @@ function runTest() {
}
}
else if (e.detail.endsWith('?2')) {
SimpleTest.finish();
document.body.appendChild(iframe2);
}
});
iframe2.addEventListener('mozbrowserfirstpaint', function(e) {
is(e.detail.backgroundColor, "rgb(0, 128, 0)", "Got the expected background color.");
SimpleTest.finish();
});
iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_FirstPaint.html';
document.body.appendChild(iframe);
iframe.src = browserElementTestHelpers.emptyPage1;

View File

@ -0,0 +1,4 @@
<html>
<body style="background-color:green;">
</body>
</html>