mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 829486 - Fire documentfirstpaint every time a window created. r=jlebar
This commit is contained in:
parent
2ff0659932
commit
58975ea2ce
@ -155,8 +155,11 @@ BrowserElementChild.prototype = {
|
||||
this._keyEventHandler.bind(this),
|
||||
/* useCapture = */ true);
|
||||
els.addSystemEventListener(global, 'DOMWindowClose',
|
||||
this._closeHandler.bind(this),
|
||||
this._windowCloseHandler.bind(this),
|
||||
/* useCapture = */ false);
|
||||
els.addSystemEventListener(global, 'DOMWindowCreated',
|
||||
this._windowCreatedHandler.bind(this),
|
||||
/* useCapture = */ true);
|
||||
els.addSystemEventListener(global, 'contextmenu',
|
||||
this._contextmenuHandler.bind(this),
|
||||
/* useCapture = */ false);
|
||||
@ -401,7 +404,7 @@ BrowserElementChild.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_closeHandler: function(e) {
|
||||
_windowCloseHandler: function(e) {
|
||||
let win = e.target;
|
||||
if (win != content || e.defaultPrevented) {
|
||||
return;
|
||||
@ -414,6 +417,23 @@ BrowserElementChild.prototype = {
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
_windowCreatedHandler: function(e) {
|
||||
let targetDocShell = e.target.defaultView
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
if (targetDocShell != docShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
let uri = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
|
||||
debug("Window created: " + uri.spec);
|
||||
if (uri.spec != "about:blank") {
|
||||
this._addMozAfterPaintHandler(function () {
|
||||
sendAsyncMsg('documentfirstpaint');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_contextmenuHandler: function(e) {
|
||||
debug("Got contextmenu");
|
||||
|
||||
|
@ -214,6 +214,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
|
||||
addMessageListener("error", this._fireEventFromMsg);
|
||||
addMessageListener("scroll", this._fireEventFromMsg);
|
||||
addMessageListener("firstpaint", this._fireEventFromMsg);
|
||||
addMessageListener("documentfirstpaint", this._fireEventFromMsg);
|
||||
addMessageListener("nextpaint", this._recvNextPaint);
|
||||
addMessageListener("keyevent", this._fireKeyEvent);
|
||||
addMessageListener("showmodalprompt", this._handleShowModalPrompt);
|
||||
|
@ -159,6 +159,8 @@ MOCHITEST_FILES = \
|
||||
browserElement_ReloadPostRequest.js \
|
||||
browserElement_PurgeHistory.js \
|
||||
test_browserElement_inproc_PurgeHistory.html \
|
||||
browserElement_DocumentFirstPaint.js \
|
||||
test_browserElement_inproc_DocumentFirstPaint.html \
|
||||
$(NULL)
|
||||
|
||||
# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
|
||||
@ -222,6 +224,7 @@ MOCHITEST_FILES += \
|
||||
test_browserElement_oop_FrameWrongURI.html \
|
||||
test_browserElement_oop_ReloadPostRequest.html \
|
||||
test_browserElement_oop_PurgeHistory.html \
|
||||
test_browserElement_oop_DocumentFirstPaint.html \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2)
|
||||
|
@ -0,0 +1,70 @@
|
||||
/* Any copyright is dedicated to the public domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Bug 829486 - Add mozdocumentbrowserfirstpaint event.
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var iframe;
|
||||
|
||||
function runTestQueue(queue) {
|
||||
if (queue.length == 0) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var gotFirstPaint = false;
|
||||
var gotFirstLocationChange = false;
|
||||
var test = queue.shift();
|
||||
|
||||
function runNext() {
|
||||
iframe.removeEventListener('mozbrowserdocumentfirstpaint', documentfirstpainthandler);
|
||||
iframe.removeEventListener('mozbrowserloadend', loadendhandler);
|
||||
runTestQueue(queue);
|
||||
}
|
||||
|
||||
function documentfirstpainthandler(e) {
|
||||
ok(!gotFirstPaint, "Got firstpaint only once");
|
||||
gotFirstPaint = true;
|
||||
if (gotFirstLocationChange) {
|
||||
runNext();
|
||||
}
|
||||
}
|
||||
|
||||
function loadendhandler(e) {
|
||||
gotFirstLocationChange = true;
|
||||
if (gotFirstPaint) {
|
||||
runNext();
|
||||
}
|
||||
}
|
||||
|
||||
iframe.addEventListener('mozbrowserdocumentfirstpaint', documentfirstpainthandler);
|
||||
iframe.addEventListener('mozbrowserloadend', loadendhandler);
|
||||
|
||||
test();
|
||||
}
|
||||
|
||||
function testChangeLocation() {
|
||||
iframe.src = browserElementTestHelpers.emptyPage1 + "?2";
|
||||
}
|
||||
|
||||
function testReload() {
|
||||
iframe.reload();
|
||||
}
|
||||
|
||||
function testFirstLoad() {
|
||||
document.body.appendChild(iframe);
|
||||
iframe.src = browserElementTestHelpers.emptyPage1;
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.mozbrowser = true;
|
||||
|
||||
runTestQueue([testFirstLoad, testReload, testChangeLocation]);
|
||||
}
|
||||
|
||||
runTest();
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Bug 829486</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_DocumentFirstPaint.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Bug 829486</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_DocumentFirstPaint.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user