Bug 789315, notify MutationObservers before running <script>, r=khuey

This commit is contained in:
Olli Pettay 2015-11-26 22:37:52 +02:00
parent 62b6224f7e
commit c8e3eee3aa
4 changed files with 55 additions and 11 deletions

View File

@ -969,6 +969,11 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
// The window may have gone away by this point, in which case there's no point
// in trying to run the script.
nsCOMPtr<nsIDocument> master = mDocument->MasterDocument();
{
// Try to perform a microtask checkpoint
nsAutoMicroTask mt;
}
nsPIDOMWindow *pwin = master->GetInnerWindow();
bool runScript = !!pwin;
if (runScript) {

View File

@ -677,6 +677,7 @@ skip-if = os == "mac" # fails intermittently - bug 1101288
[test_bug761120.html]
[test_bug782342.html]
[test_bug787778.html]
[test_bug789315.html]
[test_bug789856.html]
[test_bug804395.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #bug 901343, specialpowers.wrap issue createsystemxhr

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=789315
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 789315</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript">
(function() {
const observerConfig = {
childList: true,
};
var observer = new MutationObserver(onMutations);
observer.observe(document.head, observerConfig);
function onMutations(mutations) {
for (var i in mutations) {
var mutation = mutations[i];
for (var j in mutation.addedNodes) {
var addedNode = mutation.addedNodes[j];
addedNode.mutationObserverHasNotified = true;
}
}
}
})();
</script>
<link id="testnode" rel="localization" href="dummy"></link>
<script type="text/javascript">
var testNode = document.getElementById("testnode");
ok(testNode.mutationObserverHasNotified);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=789315">Mozilla Bug 789315</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -1,11 +0,0 @@
[MutationObserver-document.html]
type: testharness
[parser insertion mutations]
expected: FAIL
[parser script insertion mutation]
expected: FAIL
[removal of parent during parsing]
expected: FAIL