Bug 789315, notify MutationObservers before running <script>, r=khuey
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -964,16 +964,21 @@ nsScriptLoader::ProcessRequest(nsScriptL
mCurrentParserInsertedScript = aRequest->mElement;
}
FireScriptAvailable(NS_OK, 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) {
nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
scriptElem,
NS_LITERAL_STRING("beforescriptexecute"),
true, true, &runScript);
}
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -672,16 +672,17 @@ skip-if = os == "mac" # fails intermitte
[test_bug737612.html]
[test_bug738108.html]
[test_bug744830.html]
[test_bug749367.html]
[test_bug753278.html]
[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
[test_bug809003.html]
[test_bug810494.html]
[test_bug811701.html]
[test_bug811701.xhtml]
[test_bug813919.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug789315.html
@@ -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>
deleted file mode 100644
--- a/testing/web-platform/meta/dom/nodes/MutationObserver-document.html.ini
+++ /dev/null
@@ -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
-