Bug 1093028 - Imports should block DOMContentLoaded of the parent. r=mrbkap
☠☠ backed out by aad11b8e24c3 ☠ ☠
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Wed, 05 Nov 2014 14:01:51 +0100
changeset 214071 1f590c2c40f0b850c4062ee651e1fb21a76dff8e
parent 214070 dd2b3e78b4259b0c2e9f1abd62a52b551be1758b
child 214072 21402c47765a5ab35ebcc7749822daa4aa2c6d15
push id51412
push usergkrizsanits@mozilla.com
push dateWed, 05 Nov 2014 13:02:39 +0000
treeherdermozilla-inbound@1f590c2c40f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1093028
milestone36.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 1093028 - Imports should block DOMContentLoaded of the parent. r=mrbkap
dom/base/ImportManager.cpp
dom/html/test/imports/file_blocking_DOMContentLoaded_A.html
dom/html/test/imports/file_blocking_DOMContentLoaded_B.html
dom/html/test/imports/file_blocking_DOMContentLoaded_C.html
dom/html/test/imports/file_blocking_DOMContentLoaded_D.html
dom/html/test/imports/mochitest.ini
dom/html/test/imports/test_blocking_DOMContentLoaded.html
--- a/dom/base/ImportManager.cpp
+++ b/dom/base/ImportManager.cpp
@@ -144,16 +144,17 @@ ImportLoader::Updater::UpdateMainReferre
   // This new link means we have to execute our scripts sooner...
   // Let's make sure that unblocking a loader does not trigger a script execution.
   // So we start with placing the new blockers and only then will we remove any
   // blockers.
   if (mLoader->IsBlocking()) {
     // Our import parent is changed, let's block the new one and later unblock
     // the old one.
     newMainReferrer->OwnerDoc()->ScriptLoader()->AddExecuteBlocker();
+    newMainReferrer->OwnerDoc()->BlockDOMContentLoaded();
   }
 
   if (mLoader->mDocument) {
     // Our nearest predecessor has changed. So let's add the ScriptLoader to the
     // new one if there is any. And remove it from the old one.
     nsRefPtr<ImportManager> manager = mLoader->Manager();
     nsScriptLoader* loader = mLoader->mDocument->ScriptLoader();
     ImportLoader*& pred = mLoader->mBlockingPredecessor;
@@ -163,16 +164,17 @@ ImportLoader::Updater::UpdateMainReferre
         newPred->AddBlockedScriptLoader(loader);
       }
       pred->RemoveBlockedScriptLoader(loader);
     }
   }
 
   if (mLoader->IsBlocking()) {
     mLoader->mImportParent->ScriptLoader()->RemoveExecuteBlocker();
+    mLoader->mImportParent->UnblockDOMContentLoaded();
   }
 
   // Finally update mMainReferrer to point to the newly added link.
   mLoader->mMainReferrer = aNewIdx;
   mLoader->mImportParent = newMainReferrer->OwnerDoc();
 }
 
 nsINode*
@@ -295,24 +297,26 @@ ImportLoader::ImportLoader(nsIURI* aURI,
 {
 }
 
 void
 ImportLoader::BlockScripts()
 {
   MOZ_ASSERT(!mBlockingScripts);
   mImportParent->ScriptLoader()->AddExecuteBlocker();
+  mImportParent->BlockDOMContentLoaded();
   mBlockingScripts = true;
 }
 
 void
 ImportLoader::UnblockScripts()
 {
   MOZ_ASSERT(mBlockingScripts);
   mImportParent->ScriptLoader()->RemoveExecuteBlocker();
+  mImportParent->UnblockDOMContentLoaded();
   for (uint32_t i = 0; i < mBlockedScriptLoaders.Length(); i++) {
     mBlockedScriptLoaders[i]->RemoveExecuteBlocker();
   }
   mBlockedScriptLoaders.Clear();
   mBlockingScripts = false;
 }
 
 void
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_A.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("AS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_B.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_B.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("BS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_C.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_C.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("CS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_D.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_D.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("DS0");
+  </script>
+</head>
+<body>
+</body>
+</html>
--- a/dom/html/test/imports/mochitest.ini
+++ b/dom/html/test/imports/mochitest.ini
@@ -28,19 +28,25 @@ support-files =
   file_cycle_3_C.html
   file_cycle_4_A.html
   file_cycle_4_B.html
   file_cycle_4_C.html
   file_cycle_4_D.html
   file_cycle_4_E.html
   file_encoding.html
   file_simple_import.html
+  file_blocking_DOMContentLoaded_A.html
+  file_blocking_DOMContentLoaded_B.html
+  file_blocking_DOMContentLoaded_C.html
+  file_blocking_DOMContentLoaded_D.html
 
 [test_cycle_1.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_2.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_3.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_4.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
+[test_blocking_DOMContentLoaded.html]
+skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_encoding.html]
 [test_defaultView.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/test_blocking_DOMContentLoaded.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1093028
+-->
+<head>
+  <title>Test for Bug 1093028</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+</head>
+<body>
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1093028">Mozilla Bug 1093028</a>
+  <script type="text/javascript">
+    SimpleTest.waitForExplicitFinish();
+    var counter = 0;
+    var fcounter = 0;
+    var order = [];
+    function loaded() {
+      counter++;
+    }
+    function failed() {
+      fcounter++;
+    }
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_A.html" onload="loaded()" onerror="failed()"></link>
+  <script type="text/javascript">
+    is(counter, 4, "Imports are loaded");
+    is(fcounter, 0, "No error in imports");
+    var expected = ["AS0","BS0","CS0","DS0"];
+    for (i in expected)
+      is(order[i], expected[i], "import " + i + " should be " + expected[i]);
+    SimpleTest.finish();
+  </script>
+</body>
+</html>