Bug 789315, notify MutationObservers before running <script>, r=khuey
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 26 Nov 2015 22:37:52 +0200
changeset 308539 ff34a06cb439e6988e91cc78f3999e8012b7f835
parent 308538 d5be1774b0badd1a6def3a5c8a2e0c6c99128a6e
child 308540 11ede1cca0069fb3bfb8164ec3ada4a54fb4e7a4
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs789315
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 789315, notify MutationObservers before running <script>, r=khuey
dom/base/nsScriptLoader.cpp
dom/base/test/mochitest.ini
dom/base/test/test_bug789315.html
testing/web-platform/meta/dom/nodes/MutationObserver-document.html.ini
--- 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
-