mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 742183 - Handle MicroTasks correctly with showModalDialog, r=sicking
This commit is contained in:
parent
45b584ef56
commit
19b67623db
@ -286,6 +286,7 @@ _TEST_FILES1 = \
|
||||
file_XHRDocURI.text^headers^ \
|
||||
test_DOMException.html \
|
||||
test_mutationobservers.html \
|
||||
mutationobserver_dialog.html \
|
||||
$(NULL)
|
||||
|
||||
_TEST_FILES2 = \
|
||||
|
62
content/base/test/mutationobserver_dialog.html
Normal file
62
content/base/test/mutationobserver_dialog.html
Normal file
@ -0,0 +1,62 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script>
|
||||
|
||||
var div = document.createElement("div");
|
||||
|
||||
var M;
|
||||
if ("MozMutationObserver" in window) {
|
||||
M = window.MozMutationObserver;
|
||||
} else if ("WebKitMutationObserver" in window) {
|
||||
M = window.WebKitMutationObserver;
|
||||
} else {
|
||||
M = window.MutationObserver;
|
||||
}
|
||||
|
||||
var didCall1 = false;
|
||||
var didCall2 = false;
|
||||
function testMutationObserverInDialog() {
|
||||
div.innerHTML = "<span>1</span><span>2</span>";
|
||||
m = new M(function(records, observer) {
|
||||
opener.is(records[0].type, "childList", "Should have got childList");
|
||||
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
|
||||
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
didCall1 = true;
|
||||
});
|
||||
m.observe(div, { childList: true });
|
||||
div.innerHTML = "<span><span>foo</span></span>";
|
||||
}
|
||||
|
||||
function testMutationObserverInDialog2() {
|
||||
div.innerHTML = "<span>1</span><span>2</span>";
|
||||
m = new M(function(records, observer) {
|
||||
opener.is(records[0].type, "childList", "Should have got childList");
|
||||
opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
|
||||
opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
didCall2 = true;
|
||||
});
|
||||
m.observe(div, { childList: true });
|
||||
div.innerHTML = "<span><span>foo</span></span>";
|
||||
}
|
||||
|
||||
window.addEventListener("load", testMutationObserverInDialog);
|
||||
window.addEventListener("load", testMutationObserverInDialog2);
|
||||
window.addEventListener("load",
|
||||
function() {
|
||||
opener.ok(didCall1, "Should have called 1st mutation callback");
|
||||
opener.ok(didCall2, "Should have called 2nd mutation callback");
|
||||
window.close();
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<input type="button" onclick="window.close()" value="close">
|
||||
</body>
|
||||
</html>
|
@ -459,6 +459,24 @@ function testSyncXHR() {
|
||||
|
||||
function testSyncXHR2() {
|
||||
ok(callbackHandled, "Should have called the mutation callback!");
|
||||
then(testModalDialog);
|
||||
}
|
||||
|
||||
function testModalDialog() {
|
||||
var didHandleCallback = false;
|
||||
div.innerHTML = "<span>1</span><span>2</span>";
|
||||
m = new M(function(records, observer) {
|
||||
is(records[0].type, "childList", "Should have got childList");
|
||||
is(records[0].removedNodes.length, 2, "Should have got removedNodes");
|
||||
is(records[0].addedNodes.length, 1, "Should have got addedNodes");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
didHandleCallback = true;
|
||||
});
|
||||
m.observe(div, { childList: true });
|
||||
div.innerHTML = "<span><span>foo</span></span>";
|
||||
window.showModalDialog("mutationobserver_dialog.html");
|
||||
ok(didHandleCallback, "Should have called the callback while showing modal dialog!");
|
||||
then();
|
||||
}
|
||||
|
||||
|
@ -7154,6 +7154,8 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs,
|
||||
options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0");
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> callerWin = EnterModalState();
|
||||
PRUint32 oldMicroTaskLevel = nsContentUtils::MicroTaskLevel();
|
||||
nsContentUtils::SetMicroTaskLevel(0);
|
||||
nsresult rv = OpenInternal(aURI, EmptyString(), options,
|
||||
false, // aDialog
|
||||
true, // aContentModal
|
||||
@ -7163,6 +7165,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs,
|
||||
GetPrincipal(), // aCalleePrincipal
|
||||
nsnull, // aJSCallerContext
|
||||
getter_AddRefs(dlgWin));
|
||||
nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel);
|
||||
LeaveModalState(callerWin);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -1736,6 +1736,7 @@ nsPresContext::MediaFeatureValuesChanged(bool aCallerWillRebuildStyleData)
|
||||
|
||||
for (PRUint32 i = 0, i_end = notifyList.Length(); i != i_end; ++i) {
|
||||
if (pusher.RePush(et)) {
|
||||
nsAutoMicroTask mt;
|
||||
nsDOMMediaQueryList::HandleChangeData &d = notifyList[i];
|
||||
d.listener->HandleChange(d.mql);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user